How do I configure Security Context in Pod Templates?

1 minute readKnowledge base

Issue

  • I want to configure the securityContext for the Kubernetes pod templates in my instance. However, from the templates configuration UI there is no dedicated field for this purpose.

  • I want to configure the securityContext for the Kubernetes pod templates in my instance. However, when defining them with CasC there is no dedicated field for this purpose.

Resolution

Define the pod template by passing its raw YAML. This can be done both when using CasC and when editing the template from the UI. Find an example below:

apiVersion: "v1" kind: "Pod" metadata: name: "nginx" spec: containers: name: "nginx" image: "nginx:alpine3.18" command: - "sleep" args: - "infinity" imagePullPolicy: "IfNotPresent" securityContext: privileged: false allowPrivilegeEscalation: false

If you have any problems configuring this or other Kubernetes pod properties, you can contact our Support team at CloudBees.