Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for prometheus exporter for NGINX #346

Merged
merged 3 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -182,3 +194,4 @@ Delete the `nginx-ingress` namespace to uninstall the Ingress controller along w
```
$ kubectl delete namespace nginx-ingress
```

2 changes: 1 addition & 1 deletion docs/nginx-ingress-controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions helm-chart/templates/controller-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
10 changes: 8 additions & 2 deletions helm-chart/templates/controller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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 }}"
Expand All @@ -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 }}
7 changes: 7 additions & 0 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
55 changes: 55 additions & 0 deletions install/daemon-set/nginx-ingress-with-prometheus.yaml
Original file line number Diff line number Diff line change
@@ -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

54 changes: 54 additions & 0 deletions install/deployment/nginx-ingress-with-prometheus.yaml
Original file line number Diff line number Diff line change
@@ -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