Skip to content

Commit 188be58

Browse files
Integrate with openshift-monitoring at secure(https) metrics endpoint
1 parent 4d28c89 commit 188be58

7 files changed

+67
-10
lines changed

install/0000_30_machine-api-operator_09_rbac.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,14 @@ kind: ClusterRole
200200
metadata:
201201
name: machine-api-operator
202202
rules:
203-
203+
- apiGroups: ["authentication.k8s.io"]
204+
resources:
205+
- tokenreviews
206+
verbs: ["create"]
207+
- apiGroups: ["authorization.k8s.io"]
208+
resources:
209+
- subjectaccessreviews
210+
verbs: ["create"]
204211
- apiGroups:
205212
- config.openshift.io
206213
resources:
@@ -319,6 +326,12 @@ metadata:
319326
name: prometheus-k8s-machine-api-operator
320327
namespace: openshift-machine-api
321328
rules:
329+
- apiGroups:
330+
- ""
331+
resources:
332+
- namespace/metrics
333+
verbs:
334+
- get
322335
- apiGroups:
323336
- ""
324337
resources:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: kube-rbac-proxy
5+
namespace: openshift-machine-api
6+
data:
7+
config-file.yaml: |+
8+
authorization:
9+
resourceAttributes:
10+
apiVersion: v1
11+
resource: namespace
12+
subresource: metrics
13+
namespace: openshift-machine-api
14+

install/0000_30_machine-api-operator_10_service.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ kind: Service
44
metadata:
55
name: machine-api-operator
66
namespace: openshift-machine-api
7+
annotations:
8+
service.alpha.openshift.io/serving-cert-secret-name: machine-api-operator-tls
79
labels:
810
k8s-app: machine-api-operator
911
spec:
1012
type: ClusterIP
1113
ports:
12-
- name: metrics
13-
port: 8080
14-
targetPort: metrics
15-
protocol: TCP
14+
- name: https
15+
port: 8443
16+
targetPort: https
1617
selector:
1718
k8s-app: machine-api-operator
1819
sessionAffinity: None

install/0000_30_machine-api-operator_11_deployment.yaml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ spec:
1818
priorityClassName: system-node-critical
1919
serviceAccountName: machine-api-operator
2020
containers:
21+
- name: kube-rbac-proxy
22+
image: quay.io/openshift/origin-kube-rbac-proxy:4.2.0
23+
args:
24+
- "--secure-listen-address=0.0.0.0:8443"
25+
- "--upstream=http://127.0.0.1:8080/"
26+
- "--tls-cert-file=/etc/tls/private/tls.crt"
27+
- "--tls-private-key-file=/etc/tls/private/tls.key"
28+
- "--config-file=/etc/kube-rbac-proxy/config-file.yaml"
29+
- "--logtostderr=true"
30+
- "--v=10"
31+
ports:
32+
- containerPort: 8443
33+
name: https
34+
volumeMounts:
35+
- name: config
36+
mountPath: /etc/kube-rbac-proxy
37+
- mountPath: /etc/tls/private
38+
name: machine-api-operator-tls
2139
- name: machine-api-operator
2240
image: docker.io/openshift/origin-machine-api-operator:v4.0.0
2341
command:
@@ -36,9 +54,6 @@ spec:
3654
fieldPath: metadata.namespace
3755
- name: METRICS_PORT
3856
value: "8080"
39-
ports:
40-
- name: metrics
41-
containerPort: 8080
4257
resources:
4358
requests:
4459
cpu: 10m
@@ -65,6 +80,12 @@ spec:
6580
effect: "NoExecute"
6681
tolerationSeconds: 120
6782
volumes:
83+
- name: config
84+
configMap:
85+
name: kube-rbac-proxy
6886
- name: images
6987
configMap:
7088
name: machine-api-operator-images
89+
- name: machine-api-operator-tls
90+
secret:
91+
secretName: machine-api-operator-tls

install/0000_30_machine-api-operator_13_servicemonitor.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ spec:
99
endpoints:
1010
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
1111
interval: 30s
12-
port: metrics
13-
scheme: http
12+
port: https
13+
scheme: https
14+
tlsConfig:
15+
caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
16+
serverName: machine-api-operator.openshift-machine-api.svc
1417
namespaceSelector:
1518
matchNames:
1619
- openshift-machine-api

install/image-references

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ spec:
5454
from:
5555
kind: DockerImage
5656
name: quay.io/openshift/origin-ironic-static-ip-manager:v4.2.0
57+
- name: kube-rbac-proxy
58+
from:
59+
kind: DockerImage
60+
name: quay.io/openshift/origin-kube-rbac-proxy:4.2.0

kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ resources:
2626
- install/0000_30_machine-api-operator_07_machinehealthcheck.crd.yaml
2727
- install/0000_30_machine-api-operator_08_machinedisruptionbudget.crd.yaml
2828
- install/0000_30_machine-api-operator_09_rbac.yaml
29+
- install/0000_30_machine-api-operator_10_kube-rbac-proxy-config.yaml
2930
- install/0000_30_machine-api-operator_10_service.yaml
3031
- install/0000_30_machine-api-operator_11_deployment.yaml
3132
- install/0000_30_machine-api-operator_12_clusteroperator.yaml

0 commit comments

Comments
 (0)