Skip to content

Commit

Permalink
Added operator metrics ssl and auth configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierCazade committed Mar 9, 2023
1 parent 7213a26 commit 5db2a1c
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
control-plane: controller-manager
name: netobserv-metrics-monitor
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
interval: 30s
path: /metrics
port: https
scheme: https
tlsConfig:
caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
serverName: metrics.netobserv-metrics-service.svc
selector:
matchLabels:
control-plane: controller-manager
2 changes: 2 additions & 0 deletions bundle/manifests/netobserv-metrics-service_v1_service.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.openshift.io/serving-cert-secret-name: manager-metrics-tls
creationTimestamp: null
labels:
control-plane: controller-manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ spec:
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
- --v=10
- --ignore-paths=/metrics
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0
name: kube-rbac-proxy
ports:
Expand Down
1 change: 0 additions & 1 deletion config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ spec:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8080/"
- "--logtostderr=true"
- "--ignore-paths=/metrics"
- "--v=10"
ports:
- containerPort: 8443
Expand Down
1 change: 0 additions & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ spec:
- "--upstream=http://127.0.0.1:8080/"
- "--logtostderr=true"
- "--v=10"
- "--ignore-paths=/metrics"
ports:
- containerPort: 8443
protocol: TCP
Expand Down
11 changes: 7 additions & 4 deletions config/openshift/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ namespace: netobserv
# field above.
namePrefix: netobserv-

# Labels to add to all resources and selectors.
#commonLabels:
# someName: someValue
resources:
- monitor.yaml

patches:
- path: ./monitoring-patch.yaml
target:
kind: Deployment
name: controller-manager
bases:
- ../crd
- ../rbac
- ../manager
- ../webhook
- ../prometheus
- namespace.yaml
patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Prometheus Monitor Service (Metrics)
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
Expand All @@ -9,11 +8,14 @@ metadata:
namespace: system
spec:
endpoints:
- path: /metrics
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
path: /metrics
interval: 30s
port: https
scheme: https
tlsConfig:
insecureSkipVerify: true
caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
serverName: netobserv-metrics-service.netobserv.svc
selector:
matchLabels:
control-plane: controller-manager
27 changes: 27 additions & 0 deletions config/openshift/monitoring-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Check that the 0 container is the expected one
- op: test
path: /spec/template/spec/containers/1/name
value: kube-rbac-proxy

- op: add
path: "/spec/template/spec/volumes/-"
value:
name: manager-metric-tls
secret:
secretName: manager-metrics-tls
defaultMode: 420

- op: add
path: "/spec/template/spec/containers/1/volumeMounts"
value:
- name: manager-metric-tls
readOnly: true
mountPath: /etc/tls/private

- op: add
path: "/spec/template/spec/containers/1/args/-"
value: '--tls-cert-file=/etc/tls/private/tls.crt'

- op: add
path: "/spec/template/spec/containers/1/args/-"
value: '--tls-private-key-file=/etc/tls/private/tls.key'
2 changes: 0 additions & 2 deletions config/prometheus/kustomization.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions config/rbac/auth_proxy_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kind: Service
metadata:
labels:
control-plane: controller-manager
annotations:
service.beta.openshift.io/serving-cert-secret-name: manager-metrics-tls
name: metrics-service
namespace: system
spec:
Expand Down

0 comments on commit 5db2a1c

Please sign in to comment.