diff --git a/charts/nginx-gateway-fabric/README.md b/charts/nginx-gateway-fabric/README.md index c93d25a508..47ed55c412 100644 --- a/charts/nginx-gateway-fabric/README.md +++ b/charts/nginx-gateway-fabric/README.md @@ -246,7 +246,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri | `nginx.usage.resolver` | The nameserver used to resolve the NGINX Plus usage reporting endpoint. Used with NGINX Instance Manager. | string | `""` | | `nginx.usage.secretName` | The name of the Secret containing the JWT for NGINX Plus usage reporting. Must exist in the same namespace that the NGINX Gateway Fabric control plane is running in (default namespace: nginx-gateway). | string | `"nplus-license"` | | `nginx.usage.skipVerify` | Disable client verification of the NGINX Plus usage reporting server certificate. | bool | `false` | -| `nginxGateway` | The nginxGateway section contains configuration for the NGINX Gateway Fabric control plane deployment. | object | `{"affinity":{},"autoscaling":{"enable":false},"config":{"logging":{"level":"info"}},"configAnnotations":{},"extraVolumeMounts":[],"extraVolumes":[],"gatewayClassAnnotations":{},"gatewayClassName":"nginx","gatewayControllerName":"gateway.nginx.org/nginx-gateway-controller","gwAPIExperimentalFeatures":{"enable":false},"gwAPIInferenceExtension":{"enable":false,"endpointPicker":{"disableTLS":false,"skipVerify":true}},"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric","tag":"edge"},"kind":"deployment","labels":{},"leaderElection":{"enable":true,"lockName":""},"lifecycle":{},"metrics":{"enable":true,"port":9113,"secure":false},"name":"","nodeSelector":{},"podAnnotations":{},"priorityClassName":"","productTelemetry":{"enable":true},"readinessProbe":{"enable":true,"initialDelaySeconds":3,"port":8081},"replicas":1,"resources":{},"service":{"annotations":{},"labels":{}},"serviceAccount":{"annotations":{},"imagePullSecret":"","imagePullSecrets":[],"name":""},"snippetsFilters":{"enable":false},"terminationGracePeriodSeconds":30,"tolerations":[],"topologySpreadConstraints":[]}` | +| `nginxGateway` | The nginxGateway section contains configuration for the NGINX Gateway Fabric control plane deployment. | object | `{"affinity":{},"autoscaling":{"enable":false},"config":{"logging":{"level":"info"}},"configAnnotations":{},"extraVolumeMounts":[],"extraVolumes":[],"gatewayClassAnnotations":{},"gatewayClassName":"nginx","gatewayControllerName":"gateway.nginx.org/nginx-gateway-controller","gwAPIExperimentalFeatures":{"enable":false},"gwAPIInferenceExtension":{"enable":false,"endpointPicker":{"disableTLS":false,"skipVerify":true}},"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric","tag":"edge"},"kind":"deployment","labels":{},"leaderElection":{"enable":true,"lockName":""},"lifecycle":{},"metrics":{"enable":true,"port":9113,"secure":false,"serviceMonitor":{"create":false,"endpoints":[{"name":"metrics"}]}},"name":"","nodeSelector":{},"podAnnotations":{},"priorityClassName":"","productTelemetry":{"enable":true},"readinessProbe":{"enable":true,"initialDelaySeconds":3,"port":8081},"replicas":1,"resources":{},"service":{"annotations":{},"labels":{}},"serviceAccount":{"annotations":{},"imagePullSecret":"","imagePullSecrets":[],"name":""},"snippetsFilters":{"enable":false},"terminationGracePeriodSeconds":30,"tolerations":[],"topologySpreadConstraints":[]}` | | `nginxGateway.affinity` | The affinity of the NGINX Gateway Fabric control plane pod. | object | `{}` | | `nginxGateway.autoscaling` | Autoscaling configuration for the NGINX Gateway Fabric control plane. | object | `{"enable":false}` | | `nginxGateway.autoscaling.enable` | Enable or disable Horizontal Pod Autoscaler for the control plane. | bool | `false` | @@ -272,6 +272,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri | `nginxGateway.metrics.enable` | Enable exposing metrics in the Prometheus format. | bool | `true` | | `nginxGateway.metrics.port` | Set the port where the Prometheus metrics are exposed. | int | `9113` | | `nginxGateway.metrics.secure` | Enable serving metrics via https. By default metrics are served via http. Please note that this endpoint will be secured with a self-signed certificate. | bool | `false` | +| `nginxGateway.metrics.serviceMonitor.create` | Creates a serviceMonitor to expose metrics on the kubernetes pods. | bool | `false` | | `nginxGateway.name` | The name of the NGINX Gateway Fabric deployment - if not present, then by default uses release name given during installation. | string | `""` | | `nginxGateway.nodeSelector` | The nodeSelector of the NGINX Gateway Fabric control plane pod. | object | `{}` | | `nginxGateway.podAnnotations` | Set of custom annotations for the NGINX Gateway Fabric pods. | object | `{}` | diff --git a/charts/nginx-gateway-fabric/templates/service.yaml b/charts/nginx-gateway-fabric/templates/service.yaml index 988398d421..2f6326b938 100644 --- a/charts/nginx-gateway-fabric/templates/service.yaml +++ b/charts/nginx-gateway-fabric/templates/service.yaml @@ -23,3 +23,9 @@ spec: port: 443 protocol: TCP targetPort: 8443 +{{- if .Values.nginxGateway.metrics.enable }} + - name: metrics + port: {{ .Values.nginxGateway.metrics.port }} + protocol: TCP + targetPort: {{ .Values.nginxGateway.metrics.port }} +{{- end }} diff --git a/charts/nginx-gateway-fabric/templates/servicemonitor.yaml b/charts/nginx-gateway-fabric/templates/servicemonitor.yaml new file mode 100644 index 0000000000..b8fc062325 --- /dev/null +++ b/charts/nginx-gateway-fabric/templates/servicemonitor.yaml @@ -0,0 +1,18 @@ +{{- if and .Values.nginxGateway.metrics.enable .Values.nginxGateway.metrics.serviceMonitor.create }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "nginx-gateway.fullname" . }}-metrics + namespace: {{ .Release.Namespace }} + labels: + {{- include "nginx-gateway.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + app.kubernetes.io/component: {{ include "nginx-gateway.fullname" . }}-metrics + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + endpoints: + {{- toYaml .Values.nginxGateway.metrics.serviceMonitor.endpoints | nindent 4 }} +{{- end }} diff --git a/charts/nginx-gateway-fabric/values.schema.json b/charts/nginx-gateway-fabric/values.schema.json index 9cbf4dce38..0158541f48 100644 --- a/charts/nginx-gateway-fabric/values.schema.json +++ b/charts/nginx-gateway-fabric/values.schema.json @@ -1004,6 +1004,43 @@ "required": [], "title": "secure", "type": "boolean" + }, + "serviceMonitor": { + "properties": { + "create": { + "default": false, + "description": "Creates a serviceMonitor to expose metrics on the kubernetes pods.", + "required": [], + "title": "create", + "type": "boolean" + }, + "endpoints": { + "description": "A list of endpoints allowed as part of this ServiceMonitor.", + "items": { + "anyOf": [ + { + "properties": { + "name": { + "default": "metrics", + "required": [], + "title": "name", + "type": "string" + } + }, + "required": [], + "type": "object" + } + ], + "required": [] + }, + "required": [], + "title": "endpoints", + "type": "array" + } + }, + "required": [], + "title": "serviceMonitor", + "type": "object" } }, "required": [], diff --git a/charts/nginx-gateway-fabric/values.yaml b/charts/nginx-gateway-fabric/values.yaml index 1964b7209a..dcc3351e4a 100644 --- a/charts/nginx-gateway-fabric/values.yaml +++ b/charts/nginx-gateway-fabric/values.yaml @@ -208,6 +208,14 @@ nginxGateway: # Please note that this endpoint will be secured with a self-signed certificate. secure: false + serviceMonitor: + # -- Creates a serviceMonitor to expose metrics on the kubernetes pods. + create: false + + # A list of endpoints allowed as part of this ServiceMonitor. + endpoints: + - name: metrics + gwAPIExperimentalFeatures: # -- Enable the experimental features of Gateway API which are supported by NGINX Gateway Fabric. Requires the Gateway # APIs installed from the experimental channel.