diff --git a/deployments/helm-chart/templates/_helpers.tpl b/deployments/helm-chart/templates/_helpers.tpl index b1351130a0..5372053b0c 100644 --- a/deployments/helm-chart/templates/_helpers.tpl +++ b/deployments/helm-chart/templates/_helpers.tpl @@ -129,3 +129,7 @@ Expand image name. {{- printf "%s:%s" .Values.controller.image.repository (include "nginx-ingress.tag" .) -}} {{- end -}} {{- end -}} + +{{- define "nginx-ingress.prometheus.serviceName" -}} +{{- printf "%s-%s" (include "nginx-ingress.fullname" .) "prometheus-service" -}} +{{- end -}} diff --git a/deployments/helm-chart/templates/controller-prometheus-service.yaml b/deployments/helm-chart/templates/controller-prometheus-service.yaml new file mode 100644 index 0000000000..d36514284b --- /dev/null +++ b/deployments/helm-chart/templates/controller-prometheus-service.yaml @@ -0,0 +1,21 @@ +{{- if and .Values.prometheus.create .Values.prometheus.service.create}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "nginx-ingress.prometheus.serviceName" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "nginx-ingress.labels" . | nindent 4 }} + {{- if .Values.prometheus.service.labels -}} + {{- toYaml .Values.prometheus.service.labels | nindent 4 }} + {{- end }} +spec: + clusterIP: None + ports: + - name: prometheus + protocol: TCP + port: {{ .Values.prometheus.port }} + targetPort: {{ .Values.prometheus.port }} + selector: + {{- include "nginx-ingress.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/deployments/helm-chart/values.schema.json b/deployments/helm-chart/values.schema.json index dd43083a78..b8efc0b713 100644 --- a/deployments/helm-chart/values.schema.json +++ b/deployments/helm-chart/values.schema.json @@ -1504,6 +1504,26 @@ "examples": [ "http" ] + }, + "service": { + "type": "object", + "default": {}, + "properties": { + "create": { + "type": "boolean", + "default": false, + "title": "The create", + "examples": [ + true + ] + }, + "labels": { + "type": "object", + "default": {}, + "title": "The labels Schema", + "$ref": "https://raw.githubusercontent.com/nginxinc/kubernetes-json-schema/master/v1.27.4/_definitions.json#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta/properties/labels" + } + } } }, "examples": [ @@ -1755,7 +1775,11 @@ "create": true, "port": 9113, "secret": "", - "scheme": "http" + "scheme": "http", + "service": { + "create": false, + "labels": {} + } }, "serviceInsight": { "create": true, diff --git a/deployments/helm-chart/values.yaml b/deployments/helm-chart/values.yaml index 62fe88e0fd..a6c38a76cc 100644 --- a/deployments/helm-chart/values.yaml +++ b/deployments/helm-chart/values.yaml @@ -382,19 +382,6 @@ controller: ## Secret must exist in the same namespace as the helm release. imagePullSecretName: "" - serviceMonitor: - ## Creates a serviceMonitor to expose statistics on the kubernetes pods. - create: false - - ## Kubernetes object labels to attach to the serviceMonitor object. - labels: {} - - ## A set of labels to allow the selection of endpoints for the ServiceMonitor. - selectorMatchLabels: {} - - ## A list of endpoints allowed as part of this ServiceMonitor. - endpoints: [] - reportIngressStatus: ## Updates the address field in the status of Ingress resources with an external address of the Ingress Controller. ## You must also specify the source of the external address either through an external service via controller.reportIngressStatus.externalService, @@ -452,6 +439,19 @@ controller: ## Configure root filesystem as read-only and add volumes for temporary data. readOnlyRootFilesystem: false + serviceMonitor: + ## Creates a serviceMonitor to expose statistics on the kubernetes pods. + create: false + + ## Kubernetes object labels to attach to the serviceMonitor object. + labels: {} + + ## A set of labels to allow the selection of endpoints for the ServiceMonitor. + selectorMatchLabels: {} + + ## A list of endpoints allowed as part of this ServiceMonitor. + endpoints: [] + rbac: ## Configures RBAC. create: true @@ -469,6 +469,13 @@ prometheus: ## Configures the HTTP scheme used. scheme: http + service: + ## Creates a ClusterIP Service to expose Prometheus metrics internally + ## Requires prometheus.create=true + create: false + + labels: {} + serviceInsight: ## Expose NGINX Plus Service Insight endpoint. create: false