-
Notifications
You must be signed in to change notification settings - Fork 270
DO-NOT-MERGE: static pod deployer #2345
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: master
Are you sure you want to change the base?
Changes from all commits
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,92 @@ | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: kms-preflight-installer | ||
| namespace: {{.Namespace}} | ||
| labels: | ||
| app: openshift-kms-preflight-installer | ||
| spec: | ||
| automountServiceAccountToken: false | ||
| nodeSelector: | ||
| node-role.kubernetes.io/master: "" | ||
| tolerations: | ||
| - key: "node-role.kubernetes.io/master" | ||
| operator: "Exists" | ||
| effect: "NoSchedule" | ||
| - key: "node-role.kubernetes.io/master" | ||
| operator: "Exists" | ||
| effect: "NoExecute" | ||
| initContainers: | ||
| - name: cleanup | ||
| image: {{.InstallerImage}} | ||
| imagePullPolicy: IfNotPresent | ||
| terminationMessagePolicy: FallbackToLogsOnError | ||
| command: | ||
| - /bin/sh | ||
| - -c | ||
| - | | ||
| #!/bin/sh | ||
| set -euo pipefail | ||
|
|
||
| rm -f /etc/kubernetes/manifests/kms-preflight-pod.yaml | ||
| rm -rf /etc/kubernetes/manifests/secrets/kms-preflight-encryption-config | ||
| securityContext: | ||
| privileged: true | ||
| runAsUser: 0 | ||
| resources: | ||
| requests: | ||
| memory: 10Mi | ||
| cpu: 10m | ||
|
Comment on lines
+37
to
+39
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. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Missing resource limits on both containers. Only As per path instructions, "Resource limits (cpu, memory) on every container." 🔧 Proposed fix resources:
requests:
memory: 10Mi
cpu: 10m
+ limits:
+ memory: 10Mi
+ cpu: 10mAlso applies to: 69-71 🤖 Prompt for AI AgentsSource: Path instructions |
||
| volumeMounts: | ||
| - mountPath: /etc/kubernetes/manifests | ||
| name: manifests-dir | ||
| containers: | ||
| - name: installer | ||
| image: {{.InstallerImage}} | ||
| imagePullPolicy: IfNotPresent | ||
| terminationMessagePolicy: FallbackToLogsOnError | ||
| command: | ||
| - /bin/sh | ||
| - -c | ||
| - | | ||
| #!/bin/sh | ||
| set -euo pipefail | ||
|
|
||
| target_secret_dir="/etc/kubernetes/manifests/secrets/kms-preflight-encryption-config" | ||
| mkdir -p "${target_secret_dir}" | ||
| cp -f /install/secret/* "${target_secret_dir}/" | ||
| cp -f /install/pod/lb-int.kubeconfig "${target_secret_dir}/lb-int.kubeconfig" | ||
|
|
||
| manifest_path="/etc/kubernetes/manifests/kms-preflight-pod.yaml" | ||
| mkdir -p /etc/kubernetes/manifests | ||
| cp -f /install/pod/pod.yaml "${manifest_path}" | ||
| chmod 0600 "${manifest_path}" | ||
| securityContext: | ||
| privileged: true | ||
| runAsUser: 0 | ||
| resources: | ||
| requests: | ||
| memory: 10Mi | ||
| cpu: 10m | ||
| volumeMounts: | ||
| - mountPath: /etc/kubernetes/manifests | ||
| name: manifests-dir | ||
| - mountPath: /install/pod | ||
| name: pod-manifest | ||
| - mountPath: /install/secret | ||
| name: encryption-config | ||
| readOnly: true | ||
| restartPolicy: Never | ||
| priorityClassName: system-node-critical | ||
| securityContext: | ||
| runAsUser: 0 | ||
| volumes: | ||
| - hostPath: | ||
| path: /etc/kubernetes/manifests | ||
| name: manifests-dir | ||
| - name: pod-manifest | ||
| configMap: | ||
| name: kms-preflight-pod | ||
| - name: encryption-config | ||
| secret: | ||
| secretName: kms-preflight-encryption-config | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,9 @@ spec: | |
| # This is a one-shot preflight check, not a long-running pod. | ||
| # The operator creates it, waits for completion, and inspects the result. | ||
| restartPolicy: Never | ||
| {{- if not .StaticPod}} | ||
|
Contributor
Author
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. not possible to use a service account anymore due to: |
||
| serviceAccountName: kms-preflight | ||
| {{- end}} | ||
| priorityClassName: system-cluster-critical | ||
| nodeSelector: | ||
| node-role.kubernetes.io/master: "" | ||
|
|
@@ -24,6 +26,13 @@ spec: | |
| - key: "node-role.kubernetes.io/master" | ||
| operator: "Exists" | ||
| effect: "NoExecute" | ||
| {{- if .StaticPod}} | ||
| hostNetwork: true | ||
| volumes: | ||
| - name: resource-dir | ||
| hostPath: | ||
| path: /etc/kubernetes/manifests | ||
| {{- end}} | ||
|
tjungblu marked this conversation as resolved.
|
||
| containers: | ||
| - name: kms-preflight-check | ||
| image: {{.OperatorImage}} | ||
|
|
@@ -32,8 +41,10 @@ spec: | |
| - --kms-call-timeout={{.KMSCallTimeout}} | ||
| - --config-hash=$(CONFIG_HASH) | ||
| - --pod-name=$(POD_NAME) | ||
| - --pod-namespace=$(POD_NAMESPACE){{if .Kubeconfig}} | ||
| - --kubeconfig={{.Kubeconfig}}{{end}} | ||
| - --pod-namespace=$(POD_NAMESPACE) | ||
| {{- if .StaticPod}} | ||
| - --kubeconfig=/etc/kubernetes/static-pod-resources/secrets/kms-preflight-encryption-config/lb-int.kubeconfig | ||
| {{- end}} | ||
| env: | ||
| - name: POD_NAME | ||
| valueFrom: { fieldRef: { fieldPath: metadata.name } } | ||
|
|
@@ -46,3 +57,11 @@ spec: | |
| requests: | ||
| memory: 50Mi | ||
| cpu: 5m | ||
| {{- if .StaticPod}} | ||
| securityContext: | ||
| runAsUser: 0 | ||
| volumeMounts: | ||
| - name: resource-dir | ||
| mountPath: /etc/kubernetes/static-pod-resources | ||
| readOnly: true | ||
| {{- end}} | ||
|
tjungblu marked this conversation as resolved.
|
||
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.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: openshift/library-go
Length of output: 5957
🏁 Script executed:
Repository: openshift/library-go
Length of output: 27824
Installer pod still runs as root with full privilege
These host-write containers likely need elevated access, but the manifest still leaves them as
privileged: trueandrunAsUser: 0without any clear justification or extra hardening. If that access is required, document why it cannot be reduced; otherwise scope it down and add the missing securityContext settings where compatible.🤖 Prompt for AI Agents
Sources: Coding guidelines, Path instructions