Skip to content

Commit faff148

Browse files
authored
Merge pull request #2065 from johanneswuerbach/improve-service-monitor
🐛 default service monitor configuration to use https
2 parents 406d79d + f81fb0d commit faff148

File tree

13 files changed

+56
-8
lines changed

13 files changed

+56
-8
lines changed

docs/book/src/component-config-tutorial/testdata/project/config/prometheus/monitor.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ spec:
1111
endpoints:
1212
- path: /metrics
1313
port: https
14+
scheme: https
15+
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
16+
tlsConfig:
17+
insecureSkipVerify: true
1418
selector:
1519
matchLabels:
1620
control-plane: controller-manager

docs/book/src/cronjob-tutorial/testdata/project/config/prometheus/monitor.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ spec:
1111
endpoints:
1212
- path: /metrics
1313
port: https
14+
scheme: https
15+
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
16+
tlsConfig:
17+
insecureSkipVerify: true
1418
selector:
1519
matchLabels:
1620
control-plane: controller-manager

docs/book/src/multiversion-tutorial/testdata/project/config/prometheus/monitor.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ spec:
1111
endpoints:
1212
- path: /metrics
1313
port: https
14+
scheme: https
15+
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
16+
tlsConfig:
17+
insecureSkipVerify: true
1418
selector:
1519
matchLabels:
1620
control-plane: controller-manager

docs/book/src/reference/metrics.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ can be found at `config/rbac/auth_proxy_client_clusterrole.yaml`.
1212
You will need to grant permissions to your Prometheus server so that it can
1313
scrape the protected metrics. To achieve that, you can create a
1414
`clusterRoleBinding` to bind the `clusterRole` to the service account that your
15-
Prometheus server uses.
15+
Prometheus server uses. If you are using `kube-prometheus`, this cluster binding already exists.
1616

1717
You can run the following kubectl command to create it. If using kubebuilder
1818
`<project-prefix>` is the `namePrefix` field in `config/default/kustomization.yaml`.
@@ -26,7 +26,7 @@ kubectl create clusterrolebinding metrics --clusterrole=<project-prefix>-metrics
2626
Follow the steps below to export the metrics using the Prometheus Operator:
2727

2828
1. Install Prometheus and Prometheus Operator.
29-
We recommend using [kube-prometheus](https://github.com/coreos/kube-prometheus#installing)
29+
We recommend using [kube-prometheus](https://github.com/coreos/kube-prometheus#installing)
3030
in production if you don't have your own monitoring system.
3131
If you are just experimenting, you can only install Prometheus and Prometheus Operator.
3232
2. Uncomment the line `- ../prometheus` in the `config/default/kustomization.yaml`.
@@ -38,21 +38,21 @@ It creates the `ServiceMonitor` resource which enables exporting the metrics.
3838
```
3939
4040
Note that, when you install your project in the cluster, it will create the
41-
`ServiceMonitor` to export the metrics. To check the ServiceMonitor,
41+
`ServiceMonitor` to export the metrics. To check the ServiceMonitor,
4242
run `kubectl get ServiceMonitor -n <project>-system`. See an example:
4343

4444
```
45-
$ kubectl get ServiceMonitor -n monitor-system
45+
$ kubectl get ServiceMonitor -n monitor-system
4646
NAME AGE
4747
monitor-controller-manager-metrics-monitor 2m8s
4848
```
4949

5050
Also, notice that the metrics are exported by default through port `8443`. In this way,
51-
you are able to check the Prometheus metrics in its dashboard. To verify it, search
52-
for the metrics exported from the namespace where the project is running
53-
`{namespace="<project>-system"}`. See an example:
51+
you are able to check the Prometheus metrics in its dashboard. To verify it, search
52+
for the metrics exported from the namespace where the project is running
53+
`{namespace="<project>-system"}`. See an example:
5454

55-
<img width="1680" alt="Screenshot 2019-10-02 at 13 07 13" src="https://user-images.githubusercontent.com/7708031/66042888-a497da80-e515-11e9-9d77-d8a9fc1159a5.png">
55+
<img width="1680" alt="Screenshot 2019-10-02 at 13 07 13" src="https://user-images.githubusercontent.com/7708031/66042888-a497da80-e515-11e9-9d77-d8a9fc1159a5.png">
5656

5757
## Publishing Additional Metrics
5858

pkg/plugins/golang/v2/scaffolds/internal/templates/config/prometheus/monitor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ spec:
5353
endpoints:
5454
- path: /metrics
5555
port: https
56+
scheme: https
57+
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
58+
tlsConfig:
59+
insecureSkipVerify: true
5660
selector:
5761
matchLabels:
5862
control-plane: controller-manager

pkg/plugins/golang/v3/scaffolds/internal/templates/config/prometheus/monitor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ spec:
5353
endpoints:
5454
- path: /metrics
5555
port: https
56+
scheme: https
57+
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
58+
tlsConfig:
59+
insecureSkipVerify: true
5660
selector:
5761
matchLabels:
5862
control-plane: controller-manager

testdata/project-v2-addon/config/prometheus/monitor.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ spec:
1111
endpoints:
1212
- path: /metrics
1313
port: https
14+
scheme: https
15+
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
16+
tlsConfig:
17+
insecureSkipVerify: true
1418
selector:
1519
matchLabels:
1620
control-plane: controller-manager

testdata/project-v2-multigroup/config/prometheus/monitor.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ spec:
1111
endpoints:
1212
- path: /metrics
1313
port: https
14+
scheme: https
15+
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
16+
tlsConfig:
17+
insecureSkipVerify: true
1418
selector:
1519
matchLabels:
1620
control-plane: controller-manager

testdata/project-v2/config/prometheus/monitor.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ spec:
1111
endpoints:
1212
- path: /metrics
1313
port: https
14+
scheme: https
15+
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
16+
tlsConfig:
17+
insecureSkipVerify: true
1418
selector:
1519
matchLabels:
1620
control-plane: controller-manager

testdata/project-v3-addon/config/prometheus/monitor.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ spec:
1111
endpoints:
1212
- path: /metrics
1313
port: https
14+
scheme: https
15+
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
16+
tlsConfig:
17+
insecureSkipVerify: true
1418
selector:
1519
matchLabels:
1620
control-plane: controller-manager

0 commit comments

Comments
 (0)