diff --git a/docs/installation.md b/docs/installation.md index 34e6db0274c..bdc8dfd9a00 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -166,7 +166,19 @@ For NGINX Plus, you can access the live activity monitoring dashboard: ## Support For Prometheus Monitoring -If you are using [Prometheus](https://prometheus.io/), you can deploy the NGINX Plus Ingress controller with the Prometheus exporter for NGINX Plus. The exporter will export NGINX Plus metrics into your Prometheus. To deploy the Ingress controller with the exporter, use the modified manifests: +If you are using [Prometheus](https://prometheus.io/), you can deploy the NGINX Ingress controller with the [Prometheus exporter](https://github.com/nginxinc/nginx-prometheus-exporter) for NGINX. The exporter will export NGINX metrics into your Prometheus. + +To deploy the NGINX Ingress controller with the exporter, use the modified manifests: +* For a deployment, run: + ``` + $ kubectl apply -f deployment/nginx-ingress-with-prometheus.yaml + ``` +* For a daemonset, run: + ``` + $ kubectl apply -f daemon-set/nginx-ingress-with-prometheus.yaml + ``` + +To deploy the NGINX Plus Ingress controller with the exporter, use the modified manifests: * For a deployment, run: ``` $ kubectl apply -f deployment/nginx-plus-ingress-with-prometheus.yaml @@ -182,3 +194,4 @@ Delete the `nginx-ingress` namespace to uninstall the Ingress controller along w ``` $ kubectl delete namespace nginx-ingress ``` + diff --git a/docs/nginx-ingress-controllers.md b/docs/nginx-ingress-controllers.md index 2020119e1ad..adf0b88fa4e 100644 --- a/docs/nginx-ingress-controllers.md +++ b/docs/nginx-ingress-controllers.md @@ -33,7 +33,7 @@ The table below summarizes the key difference between nginxinc/kubernetes-ingres | **Operational** | | Reporting the IP address(es) of the Ingress controller into Ingress resources | Supported | Supported | Supported | | Extended Status | Supported via a third-party module | Not supported | Supported | -| Prometheus Integration | Supported | Not supported | Supported | +| Prometheus Integration | Supported | Supported | Supported | | Dynamic reconfiguration of endpoints (no configuration reloading) | Supported with a third-party Lua module | Not supported | Supported | Notes: diff --git a/helm-chart/README.md b/helm-chart/README.md index b95bc7ebc64..92f6dfd231c 100644 --- a/helm-chart/README.md +++ b/helm-chart/README.md @@ -89,7 +89,7 @@ Parameter | Description | Default `controller.reportIngressStatus.externalService` | Specifies the name of the service with the type LoadBalancer through which the Ingress controller is exposed externally. The external address of the service is used when reporting the status of Ingress resources. `controller.reportIngressStatus.enable` must be set to `true`. | nginx-ingress `controller.reportIngressStatus.enableLeaderElection` | Enable Leader election to avoid multiple replicas of the controller reporting the status of Ingress resources. `controller.reportIngressStatus.enable` must be set to `true`. | true `rbac.create` | Configures RBAC. | true -`prometheues.create` | Deploys a Prometheus exporter container within the Ingress controller pod. Requires NGINX Plus. `controller.nginxplus` must be set to `true`. | false +`prometheues.create` | Deploys a Prometheus exporter container within the Ingress controller pod. | false `prometheus.port` | Configures the port to scrape the metrics. | 9113 `prometheus.image.repository` | The image repository of the Prometheus exporter. | nginx/nginx-prometheus-exporter `prometheus.image.tag` | The tag of the Prometheus exporter image. | 0.1.0 diff --git a/helm-chart/templates/controller-daemonset.yaml b/helm-chart/templates/controller-daemonset.yaml index c561e71b109..2bf720aad95 100644 --- a/helm-chart/templates/controller-daemonset.yaml +++ b/helm-chart/templates/controller-daemonset.yaml @@ -17,7 +17,7 @@ spec: labels: app: {{ .Values.controller.name | trunc 63 }} {{- if .Values.prometheus }} -{{- if and (.Values.controller.nginxplus) (.Values.prometheus.create) }} +{{- if .Values.prometheus.create }} annotations: prometheus.io/scrape: "true" prometheus.io/port: "{{ .Values.prometheus.port }}" @@ -93,7 +93,7 @@ spec: {{- end }} {{- end }} {{- if .Values.prometheus }} -{{- if and (.Values.controller.nginxplus) (.Values.prometheus.create) }} +{{- if .Values.prometheus.create }} - image: "{{ .Values.prometheus.image.repository }}:{{ .Values.prometheus.image.tag }}" imagePullPolicy: "{{ .Values.prometheus.image.pullPolicy }}" name: nginx-prometheus-exporter @@ -103,9 +103,15 @@ spec: args: - -web.listen-address - :{{ .Values.prometheus.port }} +{{- if .Values.controller.nginxplus }} - -nginx.plus +{{- end }} - -nginx.scrape-uri +{{- if .Values.controller.nginxplus }} - http://127.0.0.1:8080/api +{{ else }} + - http://127.0.0.1:8080/stub_status +{{- end }} {{- end }} {{- end }} {{- end }} diff --git a/helm-chart/templates/controller-deployment.yaml b/helm-chart/templates/controller-deployment.yaml index a37300a10b3..62c67d31912 100644 --- a/helm-chart/templates/controller-deployment.yaml +++ b/helm-chart/templates/controller-deployment.yaml @@ -18,7 +18,7 @@ spec: labels: app: {{ .Values.controller.name | trunc 63 }} {{- if .Values.prometheus }} -{{- if and (.Values.controller.nginxplus) (.Values.prometheus.create) }} +{{- if .Values.prometheus.create }} annotations: prometheus.io/scrape: "true" prometheus.io/port: "{{ .Values.prometheus.port }}" @@ -79,7 +79,7 @@ spec: {{- end }} {{- end }} {{- if .Values.prometheus }} -{{- if and (.Values.controller.nginxplus) (.Values.prometheus.create) }} +{{- if .Values.prometheus.create }} - image: "{{ .Values.prometheus.image.repository }}:{{ .Values.prometheus.image.tag }}" name: nginx-prometheus-exporter imagePullPolicy: "{{ .Values.prometheus.image.pullPolicy }}" @@ -89,9 +89,15 @@ spec: args: - -web.listen-address - :{{ .Values.prometheus.port }} +{{- if .Values.controller.nginxplus }} - -nginx.plus +{{- end }} - -nginx.scrape-uri +{{- if .Values.controller.nginxplus }} - http://127.0.0.1:8080/api +{{ else }} + - http://127.0.0.1:8080/stub_status +{{- end }} {{- end }} {{- end }} {{- end }} diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index 428a5fcb0b8..786beb5fb4f 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -34,3 +34,10 @@ controller: enableLeaderElection: true rbac: create: true +prometheus: + create: false + port: 9113 + image: + repository: nginx/nginx-prometheus-exporter + tag: "0.1.0" + pullPolicy: IfNotPresent diff --git a/install/daemon-set/nginx-ingress-with-prometheus.yaml b/install/daemon-set/nginx-ingress-with-prometheus.yaml new file mode 100644 index 00000000000..eabaf93a0a5 --- /dev/null +++ b/install/daemon-set/nginx-ingress-with-prometheus.yaml @@ -0,0 +1,55 @@ +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + name: nginx-ingress + namespace: nginx-ingress +spec: + selector: + matchLabels: + app: nginx-ingress + template: + metadata: + labels: + app: nginx-ingress + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9113" + spec: + serviceAccountName: nginx-ingress + containers: + - image: nginx/nginx-ingress:1.3.0 + name: nginx-ingress + ports: + - name: http + containerPort: 80 + hostPort: 80 + - name: https + containerPort: 443 + hostPort: 443 + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + args: + - -nginx-configmaps=$(POD_NAMESPACE)/nginx-config + - -default-server-tls-secret=$(POD_NAMESPACE)/default-server-secret + #- -v=3 # Enables extensive logging. Useful for trooublshooting. + #- -report-ingress-status + #- -external-service=nginx-ingress + #- -enable-leader-election + - image: nginx/nginx-prometheus-exporter:0.1.0 + name: nginx-prometheus-exporter + ports: + - name: prometheus + containerPort: 9113 + args: + - -web.listen-address + - :9113 + - -nginx.scrape-uri + - http://127.0.0.1:8080/stub_status + diff --git a/install/deployment/nginx-ingress-with-prometheus.yaml b/install/deployment/nginx-ingress-with-prometheus.yaml new file mode 100644 index 00000000000..051d5b660cb --- /dev/null +++ b/install/deployment/nginx-ingress-with-prometheus.yaml @@ -0,0 +1,54 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: nginx-ingress + namespace: nginx-ingress +spec: + replicas: 1 + selector: + matchLabels: + app: nginx-ingress + template: + metadata: + labels: + app: nginx-ingress + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9113" + spec: + serviceAccountName: nginx-ingress + containers: + - image: nginx/nginx-ingress:1.3.0 + name: nginx-ingress + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + args: + - -nginx-configmaps=$(POD_NAMESPACE)/nginx-config + - -default-server-tls-secret=$(POD_NAMESPACE)/default-server-secret + #- -v=3 # Enables extensive logging. Useful for trooublshooting. + #- -report-ingress-status + #- -external-service=nginx-ingress + #- -enable-leader-election + - image: nginx/nginx-prometheus-exporter:0.1.0 + name: nginx-prometheus-exporter + ports: + - name: prometheus + containerPort: 9113 + args: + - -web.listen-address + - :9113 + - nginx.scrape-uri + - http://127.0.0.1:8080/stub_status +