-
Notifications
You must be signed in to change notification settings - Fork 230
USHIFT-6951: Add metrics exporters as optional MicroShift components #6763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2123961
042524a
51fb036
1903642
52adc9c
25ea1dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| namespace: openshift-monitoring | ||
| name: metrics-server-kubelet-ca | ||
| annotations: | ||
| openshift.io/owning-component: metrics-server | ||
| data: | ||
| ca-bundle.crt: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| namespace: openshift-monitoring | ||
| name: metrics-server-kubelet-client | ||
| annotations: | ||
| openshift.io/owning-component: metrics-server | ||
| type: kubernetes.io/tls | ||
| data: | ||
| tls.crt: | ||
| tls.key: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: kube-state-metrics | ||
| namespace: openshift-monitoring |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: kube-state-metrics | ||
| rules: | ||
| - apiGroups: [""] | ||
| resources: | ||
| - configmaps | ||
| - secrets | ||
| - nodes | ||
| - pods | ||
| - services | ||
| - serviceaccounts | ||
| - resourcequotas | ||
| - replicationcontrollers | ||
| - limitranges | ||
| - persistentvolumeclaims | ||
| - persistentvolumes | ||
| - namespaces | ||
| - endpoints | ||
| - events | ||
| verbs: ["list", "watch"] | ||
| - apiGroups: ["apps"] | ||
| resources: | ||
| - statefulsets | ||
| - daemonsets | ||
| - deployments | ||
| - replicasets | ||
| verbs: ["list", "watch"] | ||
| - apiGroups: ["batch"] | ||
| resources: | ||
| - cronjobs | ||
| - jobs | ||
| verbs: ["list", "watch"] | ||
| - apiGroups: ["autoscaling"] | ||
| resources: | ||
| - horizontalpodautoscalers | ||
| verbs: ["list", "watch"] | ||
| - apiGroups: ["storage.k8s.io"] | ||
| resources: | ||
| - storageclasses | ||
| - volumeattachments | ||
| verbs: ["list", "watch"] | ||
| - apiGroups: ["networking.k8s.io"] | ||
| resources: | ||
| - networkpolicies | ||
| - ingresses | ||
| verbs: ["list", "watch"] | ||
| - apiGroups: ["coordination.k8s.io"] | ||
| resources: | ||
| - leases | ||
| verbs: ["list", "watch"] | ||
| - apiGroups: ["policy"] | ||
| resources: | ||
| - poddisruptionbudgets | ||
| verbs: ["list", "watch"] | ||
| - apiGroups: ["certificates.k8s.io"] | ||
| resources: | ||
| - certificatesigningrequests | ||
| verbs: ["list", "watch"] | ||
| - apiGroups: ["discovery.k8s.io"] | ||
| resources: | ||
| - endpointslices | ||
| verbs: ["list", "watch"] | ||
| - apiGroups: ["admissionregistration.k8s.io"] | ||
| resources: | ||
| - mutatingwebhookconfigurations | ||
| - validatingwebhookconfigurations | ||
| verbs: ["list", "watch"] | ||
| - apiGroups: ["authentication.k8s.io"] | ||
| resources: | ||
| - tokenreviews | ||
| verbs: ["create"] | ||
| - apiGroups: ["authorization.k8s.io"] | ||
| resources: | ||
| - subjectaccessreviews | ||
| verbs: ["create"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: kube-state-metrics | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: kube-state-metrics | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: kube-state-metrics | ||
| namespace: openshift-monitoring |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: kube-state-metrics | ||
| namespace: openshift-monitoring | ||
| labels: | ||
| app.kubernetes.io/name: kube-state-metrics | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app.kubernetes.io/name: kube-state-metrics | ||
| strategy: | ||
| type: Recreate | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app.kubernetes.io/name: kube-state-metrics | ||
| annotations: | ||
| target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}' | ||
| openshift.io/required-scc: restricted-v2 | ||
| spec: | ||
| serviceAccountName: kube-state-metrics | ||
| priorityClassName: system-cluster-critical | ||
| containers: | ||
| - name: kube-state-metrics | ||
| image: quay.io/openshift/kube-state-metrics:latest | ||
| imagePullPolicy: IfNotPresent | ||
| args: | ||
| - --host=127.0.0.1 | ||
| - --port=8081 | ||
| - --telemetry-host=127.0.0.1 | ||
| - --telemetry-port=8082 | ||
| resources: | ||
| requests: | ||
| cpu: 10m | ||
| memory: 64Mi | ||
| securityContext: | ||
| allowPrivilegeEscalation: false | ||
| readOnlyRootFilesystem: true | ||
| runAsNonRoot: true | ||
|
Comment on lines
+38
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop all Linux capabilities explicitly. The container security contexts harden privilege escalation and filesystem writes, but they still leave the default capability set intact. Add As per coding guidelines, "Drop ALL capabilities, add only what is required". Also applies to: 60-63, 88-91 🤖 Prompt for AI Agents |
||
| - name: kube-rbac-proxy-main | ||
| image: quay.io/openshift/kube-rbac-proxy:latest | ||
| imagePullPolicy: IfNotPresent | ||
| args: | ||
| - --secure-listen-address=:8443 | ||
| - --tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 | ||
| - --tls-min-version=VersionTLS12 | ||
| - --upstream=http://127.0.0.1:8081/ | ||
| - --tls-cert-file=/etc/tls/private/tls.crt | ||
| - --tls-private-key-file=/etc/tls/private/tls.key | ||
| ports: | ||
| - containerPort: 8443 | ||
| name: https-main | ||
| protocol: TCP | ||
| resources: | ||
| requests: | ||
| cpu: 10m | ||
| memory: 40Mi | ||
| securityContext: | ||
| allowPrivilegeEscalation: false | ||
| readOnlyRootFilesystem: true | ||
| runAsNonRoot: true | ||
| volumeMounts: | ||
| - name: metrics-tls | ||
| mountPath: /etc/tls/private | ||
| readOnly: true | ||
| - name: tmp | ||
| mountPath: /tmp | ||
| - name: kube-rbac-proxy-self | ||
| image: quay.io/openshift/kube-rbac-proxy:latest | ||
| imagePullPolicy: IfNotPresent | ||
| args: | ||
| - --secure-listen-address=:9443 | ||
| - --tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 | ||
| - --tls-min-version=VersionTLS12 | ||
| - --upstream=http://127.0.0.1:8082/ | ||
| - --tls-cert-file=/etc/tls/private/tls.crt | ||
| - --tls-private-key-file=/etc/tls/private/tls.key | ||
| ports: | ||
| - containerPort: 9443 | ||
| name: https-self | ||
| protocol: TCP | ||
| resources: | ||
| requests: | ||
| cpu: 10m | ||
| memory: 40Mi | ||
| securityContext: | ||
| allowPrivilegeEscalation: false | ||
| readOnlyRootFilesystem: true | ||
| runAsNonRoot: true | ||
| volumeMounts: | ||
| - name: metrics-tls | ||
| mountPath: /etc/tls/private | ||
| readOnly: true | ||
| - name: tmp-self | ||
| mountPath: /tmp | ||
| volumes: | ||
| - name: metrics-tls | ||
| secret: | ||
| secretName: kube-state-metrics-tls | ||
| - name: tmp | ||
| emptyDir: {} | ||
| - name: tmp-self | ||
| emptyDir: {} | ||
|
Comment on lines
+25
to
+105
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add probes and limits for all three containers. This pod defines requests only, and none of the containers have liveness/readiness probes. That leaves the rollout without health gating and the workload without hard resource ceilings. As per coding guidelines, "Resource limits (cpu, memory) on every container" and "Liveness + readiness probes defined". 🤖 Prompt for AI Agents |
||
| nodeSelector: | ||
| kubernetes.io/os: linux | ||
| node-role.kubernetes.io/master: "" | ||
| tolerations: | ||
| - key: node-role.kubernetes.io/master | ||
| operator: Exists | ||
|
Comment on lines
+106
to
+111
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't pin kube-state-metrics to master nodes. The As per coding guidelines, "do not introduce scheduling constraints that assume standard HA topology with 3+ control-plane nodes" and "Flag ... nodeSelector/affinity targeting control-plane nodes". 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: kube-state-metrics | ||
| namespace: openshift-monitoring | ||
| annotations: | ||
| service.beta.openshift.io/serving-cert-secret-name: kube-state-metrics-tls | ||
| labels: | ||
| app.kubernetes.io/name: kube-state-metrics | ||
| spec: | ||
| clusterIP: None | ||
| selector: | ||
| app.kubernetes.io/name: kube-state-metrics | ||
| ports: | ||
| - name: https-main | ||
| port: 8443 | ||
| targetPort: https-main | ||
| protocol: TCP | ||
| - name: https-self | ||
| port: 9443 | ||
| targetPort: https-self | ||
| protocol: TCP |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| images: | ||
| - name: quay.io/openshift/kube-state-metrics | ||
| newName: registry.redhat.io/openshift4/ose-kube-state-metrics-rhel9 | ||
| digest: sha256:placeholder | ||
| - name: quay.io/openshift/kube-rbac-proxy | ||
| newName: registry.redhat.io/openshift4/ose-kube-rbac-proxy-rhel9 | ||
| digest: sha256:placeholder |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| images: | ||
| - name: quay.io/openshift/kube-state-metrics | ||
| newName: quay.io/openshift-release-dev/ocp-v4.0-art-dev | ||
| digest: sha256:47dcd507a8ad265c7ebd6b128bb9bdaeb7688b5731503817b94ae1d1badd6a77 | ||
| - name: quay.io/openshift/kube-rbac-proxy | ||
| newName: quay.io/openshift-release-dev/ocp-v4.0-art-dev | ||
| digest: sha256:242b3d66438c42745f4ef318bdeaf3d793426f12962a42ea83e18d06c08aaf09 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| apiVersion: kustomize.config.k8s.io/v1beta1 | ||
| kind: Kustomization | ||
| resources: | ||
| - 01-serviceaccount.yaml | ||
| - 02-clusterrole.yaml | ||
| - 03-clusterrolebinding.yaml | ||
| - 04-deployment.yaml | ||
| - 05-service.yaml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| apiVersion: v1 | ||
| kind: Namespace | ||
| metadata: | ||
| name: openshift-monitoring | ||
| labels: | ||
| name: openshift-monitoring | ||
| pod-security.kubernetes.io/enforce: privileged | ||
| pod-security.kubernetes.io/audit: privileged | ||
| pod-security.kubernetes.io/warn: privileged | ||
|
Comment on lines
+5
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid namespace-wide privileged pod security labels. Setting As per coding guidelines, 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: metrics-server | ||
| namespace: openshift-monitoring |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: system:metrics-server | ||
| rules: | ||
| - apiGroups: [""] | ||
| resources: | ||
| - nodes/metrics | ||
| verbs: | ||
| - get | ||
| - apiGroups: [""] | ||
| resources: | ||
| - pods | ||
| - nodes | ||
| - namespaces | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: system:aggregated-metrics-reader | ||
| labels: | ||
| rbac.authorization.k8s.io/aggregate-to-admin: "true" | ||
| rbac.authorization.k8s.io/aggregate-to-edit: "true" | ||
| rbac.authorization.k8s.io/aggregate-to-view: "true" | ||
| rules: | ||
| - apiGroups: ["metrics.k8s.io"] | ||
| resources: | ||
| - pods | ||
| - nodes | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: system:metrics-server | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: system:metrics-server | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: metrics-server | ||
| namespace: openshift-monitoring | ||
| - kind: User | ||
| name: system:metrics-server | ||
| apiGroup: rbac.authorization.k8s.io | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: metrics-server:system:auth-delegator | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: system:auth-delegator | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: metrics-server | ||
| namespace: openshift-monitoring |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: RoleBinding | ||
| metadata: | ||
| name: metrics-server-auth-reader | ||
| namespace: kube-system | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: Role | ||
| name: extension-apiserver-authentication-reader | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: metrics-server | ||
| namespace: openshift-monitoring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop cluster-wide
secretsaccess unless you absolutely need secret metrics.Granting
list/watchonsecretslets this workload read Secret contents cluster-wide, which is a much larger blast radius than the rest of the collectors need. If secret metrics are not intentionally enabled, removesecretsfrom this role or split it behind an explicit opt-in.As per coding guidelines, "RBAC: least privilege; no cluster-admin for workloads".
🤖 Prompt for AI Agents