Skip to content

Commit 00c9a1c

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

6 files changed

+56
-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: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ 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
23+
args:
24+
- "--secure-listen-address=0.0.0.0:8443"
25+
- "--upstream=http://127.0.0.1:8080/"
26+
- "--config-file=/etc/kube-rbac-proxy/config-file.yaml"
27+
- "--logtostderr=true"
28+
- "--v=10"
29+
ports:
30+
- containerPort: 8443
31+
name: https
32+
volumeMounts:
33+
- name: config
34+
mountPath: /etc/kube-rbac-proxy
2135
- name: machine-api-operator
2236
image: docker.io/openshift/origin-machine-api-operator:v4.0.0
2337
command:
@@ -36,9 +50,6 @@ spec:
3650
fieldPath: metadata.namespace
3751
- name: METRICS_PORT
3852
value: "8080"
39-
ports:
40-
- name: metrics
41-
containerPort: 8080
4253
resources:
4354
requests:
4455
cpu: 10m
@@ -65,6 +76,9 @@ spec:
6576
effect: "NoExecute"
6677
tolerationSeconds: 120
6778
volumes:
79+
- name: config
80+
configMap:
81+
name: kube-rbac-proxy
6882
- name: images
6983
configMap:
7084
name: machine-api-operator-images

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

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)