File tree Expand file tree Collapse file tree 2 files changed +113
-0
lines changed Expand file tree Collapse file tree 2 files changed +113
-0
lines changed Original file line number Diff line number Diff line change 1+ # NGINX Prometheus Exporter in Kubernetes
2+
3+ This example shows how to run NGINX Prometheus Exporter in a Kubernetes cluster.
4+
5+ ## Prerequisites
6+
7+ - [ kubectl] ( https://kubernetes.io/docs/tasks/tools/#kubectl ) installed.
8+ - [ kind] ( https://kind.sigs.k8s.io/ ) installed.
9+
10+ ## Create a kind cluster
11+
12+ You can create a kind cluster with the following command:
13+
14+ ``` console
15+ kind create cluster
16+ ```
17+
18+ For details, see the [ kind documentation] ( https://kind.sigs.k8s.io/docs/user/quick-start/#creating-a-cluster ) .
19+
20+ ## Deploy the NGINX Hello application and NGINX Prometheus Exporter
21+
22+ You can deploy the NGINX Hello application and NGINX Prometheus Exporter with the following command:
23+
24+ ``` console
25+ kubectl apply -f nginx-hello.yaml
26+ ```
27+
28+ ## Configure port forwarding
29+
30+ Port forwarding is used to access the NGINX Hello application and NGINX Prometheus Exporter from your local machine.
31+
32+ You can configure port forwarding with the following command:
33+
34+ ``` console
35+ kubectl port-forward service/nginx-demo 8080:80 9113:9113
36+ ```
37+
38+ ## Verification
39+
40+ You can access the NGINX Hello application at [ http://localhost:8080 ] ( http://localhost:8080 ) and the
41+ NGINX Prometheus Exporter at [ http://localhost:9113 ] ( http://localhost:9113 ) .
Original file line number Diff line number Diff line change 1+ apiVersion : apps/v1
2+ kind : Deployment
3+ metadata :
4+ labels :
5+ app.kubernetes.io/name : nginx-demo
6+ name : nginx-demo
7+ spec :
8+ replicas : 1
9+ selector :
10+ matchLabels :
11+ app.kubernetes.io/name : nginx-demo
12+ template :
13+ metadata :
14+ labels :
15+ app.kubernetes.io/name : nginx-demo
16+ annotations :
17+ prometheus.io/scrape : " true"
18+ prometheus.io/port : " 9113"
19+ spec :
20+ containers :
21+ - image : nginxdemos/hello:latest
22+ name : nginx-demo
23+ ports :
24+ - name : http
25+ containerPort : 80
26+ volumeMounts :
27+ - name : config-volume
28+ mountPath : /etc/nginx/conf.d/status.conf
29+ subPath : status.conf
30+ - image : nginx/nginx-prometheus-exporter:latest
31+ name : nginx-prometheus-exporter
32+ args :
33+ - " --nginx.scrape-uri=http://localhost:8080/stub_status"
34+ ports :
35+ - name : metrics
36+ containerPort : 9113
37+ volumes :
38+ - name : config-volume
39+ configMap :
40+ name : status-config
41+ ---
42+ apiVersion : v1
43+ kind : Service
44+ metadata :
45+ name : nginx-demo
46+ spec :
47+ type : NodePort
48+ selector :
49+ app.kubernetes.io/name : nginx-demo
50+ ports :
51+ - port : 80
52+ targetPort : 80
53+ protocol : TCP
54+ name : http
55+ - port : 9113
56+ targetPort : 9113
57+ name : metrics
58+ ---
59+ apiVersion : v1
60+ kind : ConfigMap
61+ metadata :
62+ name : status-config
63+ data :
64+ status.conf : |-
65+ server {
66+ listen 8080;
67+
68+ location /stub_status {
69+ stub_status;
70+ }
71+
72+ }
You can’t perform that action at this time.
0 commit comments