diff --git a/CHANGES/1492.feature b/CHANGES/1492.feature new file mode 100644 index 000000000..f445a5930 --- /dev/null +++ b/CHANGES/1492.feature @@ -0,0 +1 @@ +Added `pod_security_context` field to api, content, worker and web to override the hardcoded runAsUser/fsGroup 700. diff --git a/apis/repo-manager.pulpproject.org/v1/pulp_types.go b/apis/repo-manager.pulpproject.org/v1/pulp_types.go index f8837cc22..bd61985cf 100644 --- a/apis/repo-manager.pulpproject.org/v1/pulp_types.go +++ b/apis/repo-manager.pulpproject.org/v1/pulp_types.go @@ -421,6 +421,12 @@ type Api struct { // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"} NodeSelector map[string]string `json:"node_selector,omitempty"` + // PodSecurityContext defines the pod-level security attributes for the pulp-api pods. + // If unset, runAsUser and fsGroup default to 700. + // +kubebuilder:validation:Optional + // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"} + PodSecurityContext *corev1.PodSecurityContext `json:"pod_security_context,omitempty"` + // Node tolerations for the Pulp pods. // +kubebuilder:validation:Optional // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"} @@ -522,6 +528,12 @@ type Content struct { // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"} NodeSelector map[string]string `json:"node_selector,omitempty"` + // PodSecurityContext defines the pod-level security attributes for the pulp-content pods. + // If unset, runAsUser and fsGroup default to 700. + // +kubebuilder:validation:Optional + // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"} + PodSecurityContext *corev1.PodSecurityContext `json:"pod_security_context,omitempty"` + // Node tolerations for the Pulp pods. // +kubebuilder:validation:Optional // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"} @@ -619,6 +631,12 @@ type Worker struct { // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"} NodeSelector map[string]string `json:"node_selector,omitempty"` + // PodSecurityContext defines the pod-level security attributes for the pulp-worker pods. + // If unset, runAsUser and fsGroup default to 700. + // +kubebuilder:validation:Optional + // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"} + PodSecurityContext *corev1.PodSecurityContext `json:"pod_security_context,omitempty"` + // Node tolerations for the Pulp pods. // +kubebuilder:validation:Optional // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"} @@ -704,6 +722,12 @@ type Web struct { // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"} NodeSelector map[string]string `json:"node_selector,omitempty"` + // PodSecurityContext defines the pod-level security attributes for the pulp-web pods. + // If unset, runAsUser and fsGroup default to 700. + // +kubebuilder:validation:Optional + // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"} + PodSecurityContext *corev1.PodSecurityContext `json:"pod_security_context,omitempty"` + // PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods // +optional // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"} diff --git a/apis/repo-manager.pulpproject.org/v1/zz_generated.deepcopy.go b/apis/repo-manager.pulpproject.org/v1/zz_generated.deepcopy.go index bd87395a5..3d87891a0 100644 --- a/apis/repo-manager.pulpproject.org/v1/zz_generated.deepcopy.go +++ b/apis/repo-manager.pulpproject.org/v1/zz_generated.deepcopy.go @@ -47,6 +47,11 @@ func (in *Api) DeepCopyInto(out *Api) { (*out)[key] = val } } + if in.PodSecurityContext != nil { + in, out := &in.PodSecurityContext, &out.PodSecurityContext + *out = new(corev1.PodSecurityContext) + (*in).DeepCopyInto(*out) + } if in.Tolerations != nil { in, out := &in.Tolerations, &out.Tolerations *out = make([]corev1.Toleration, len(*in)) @@ -193,6 +198,11 @@ func (in *Content) DeepCopyInto(out *Content) { (*out)[key] = val } } + if in.PodSecurityContext != nil { + in, out := &in.PodSecurityContext, &out.PodSecurityContext + *out = new(corev1.PodSecurityContext) + (*in).DeepCopyInto(*out) + } if in.Tolerations != nil { in, out := &in.Tolerations, &out.Tolerations *out = make([]corev1.Toleration, len(*in)) @@ -804,6 +814,11 @@ func (in *Web) DeepCopyInto(out *Web) { (*out)[key] = val } } + if in.PodSecurityContext != nil { + in, out := &in.PodSecurityContext, &out.PodSecurityContext + *out = new(corev1.PodSecurityContext) + (*in).DeepCopyInto(*out) + } if in.PDB != nil { in, out := &in.PDB, &out.PDB *out = new(policyv1.PodDisruptionBudgetSpec) @@ -871,6 +886,11 @@ func (in *Worker) DeepCopyInto(out *Worker) { (*out)[key] = val } } + if in.PodSecurityContext != nil { + in, out := &in.PodSecurityContext, &out.PodSecurityContext + *out = new(corev1.PodSecurityContext) + (*in).DeepCopyInto(*out) + } if in.Tolerations != nil { in, out := &in.Tolerations, &out.Tolerations *out = make([]corev1.Toleration, len(*in)) diff --git a/bundle/manifests/pulp-operator.clusterserviceversion.yaml b/bundle/manifests/pulp-operator.clusterserviceversion.yaml index e5848ba3d..8875770db 100644 --- a/bundle/manifests/pulp-operator.clusterserviceversion.yaml +++ b/bundle/manifests/pulp-operator.clusterserviceversion.yaml @@ -65,7 +65,7 @@ metadata: capabilities: Full Lifecycle categories: Integration & Delivery containerImage: quay.io/pulp/pulp-operator:v1.0.0 - createdAt: "2026-03-17T12:18:57Z" + createdAt: "2026-11-06T20:34:38Z" description: Pulp is a platform for managing repositories of software packages and making them available to a large number of consumers. operators.operatorframework.io/builder: operator-sdk-v1.31.0 @@ -273,6 +273,12 @@ spec: path: api.pod_labels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced + - description: PodSecurityContext defines the pod-level security attributes + for the pulp-api pods. If unset, runAsUser and fsGroup default to 700. + displayName: Pod Security Context + path: api.pod_security_context + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced - description: Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. displayName: Readiness Probe @@ -489,6 +495,12 @@ spec: path: content.pod_labels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced + - description: PodSecurityContext defines the pod-level security attributes + for the pulp-content pods. If unset, runAsUser and fsGroup default to 700. + displayName: Pod Security Context + path: content.pod_security_context + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced - description: Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. displayName: Readiness Probe @@ -1010,6 +1022,12 @@ spec: path: web.pod_labels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced + - description: PodSecurityContext defines the pod-level security attributes + for the pulp-web pods. If unset, runAsUser and fsGroup default to 700. + displayName: Pod Security Context + path: web.pod_security_context + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced - description: Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. displayName: Readiness Probe @@ -1094,6 +1112,12 @@ spec: path: worker.pod_labels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced + - description: PodSecurityContext defines the pod-level security attributes + for the pulp-worker pods. If unset, runAsUser and fsGroup default to 700. + displayName: Pod Security Context + path: worker.pod_security_context + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced - description: Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. displayName: Readiness Probe diff --git a/bundle/manifests/repo-manager.pulpproject.org_pulps.yaml b/bundle/manifests/repo-manager.pulpproject.org_pulps.yaml index 842ef8249..cb66249cd 100644 --- a/bundle/manifests/repo-manager.pulpproject.org_pulps.yaml +++ b/bundle/manifests/repo-manager.pulpproject.org_pulps.yaml @@ -1919,6 +1919,240 @@ spec: type: string description: Labels to add to api pods type: object + pod_security_context: + description: |- + PodSecurityContext defines the pod-level security attributes for the pulp-api pods. + If unset, runAsUser and fsGroup default to 700. + properties: + appArmorProfile: + description: |- + appArmorProfile is the AppArmor options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile loaded on the node that should be used. + The profile must be preconfigured on the node to work. + Must match the loaded name of the profile. + Must be set if and only if type is "Localhost". + type: string + type: + description: |- + type indicates which kind of AppArmor profile will be applied. + Valid options are: + Localhost - a profile pre-loaded on the node. + RuntimeDefault - the container runtime's default profile. + Unconfined - no AppArmor enforcement. + type: string + required: + - type + type: object + fsGroup: + description: |- + A special supplemental group that applies to all containers in a pod. + Some volume types allow the Kubelet to change the ownership of that volume + to be owned by the pod: + + 1. The owning GID will be the FSGroup + 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) + 3. The permission bits are OR'd with rw-rw---- + + If unset, the Kubelet will not modify the ownership and permissions of any volume. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + fsGroupChangePolicy: + description: |- + fsGroupChangePolicy defines behavior of changing ownership and permission of the volume + before being exposed inside Pod. This field will only apply to + volume types which support fsGroup based ownership(and permissions). + It will have no effect on ephemeral volume types such as: secret, configmaps + and emptydir. + Valid values are "OnRootMismatch" and "Always". If not specified, "Always" is used. + Note that this field cannot be set when spec.os.name is windows. + type: string + runAsGroup: + description: |- + The GID to run the entrypoint of the container process. + Uses runtime default if unset. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: |- + Indicates that the container must run as a non-root user. + If true, the Kubelet will validate the image at runtime to ensure that it + does not run as UID 0 (root) and fail to start the container if it does. + If unset or false, no such validation will be performed. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: |- + The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxChangePolicy: + description: |- + seLinuxChangePolicy defines how the container's SELinux label is applied to all volumes used by the Pod. + It has no effect on nodes that do not support SELinux or to volumes does not support SELinux. + Valid values are "MountOption" and "Recursive". + + "Recursive" means relabeling of all files on all Pod volumes by the container runtime. + This may be slow for large volumes, but allows mixing privileged and unprivileged Pods sharing the same volume on the same node. + + "MountOption" mounts all eligible Pod volumes with `-o context` mount option. + This requires all Pods that share the same volume to use the same SELinux label. + It is not possible to share the same volume among privileged and unprivileged Pods. + Eligible volumes are in-tree FibreChannel and iSCSI volumes, and all CSI volumes + whose CSI driver announces SELinux support by setting spec.seLinuxMount: true in their + CSIDriver instance. Other volumes are always re-labelled recursively. + "MountOption" value is allowed only when SELinuxMount feature gate is enabled. + + If not specified and SELinuxMount feature gate is enabled, "MountOption" is used. + If not specified and SELinuxMount feature gate is disabled, "MountOption" is used for ReadWriteOncePod volumes + and "Recursive" for all other volumes. + + This field affects only Pods that have SELinux label set, either in PodSecurityContext or in SecurityContext of all containers. + + All Pods that use the same volume should use the same seLinuxChangePolicy, otherwise some pods can get stuck in ContainerCreating state. + Note that this field cannot be set when spec.os.name is windows. + type: string + seLinuxOptions: + description: |- + The SELinux context to be applied to all containers. + If unspecified, the container runtime will allocate a random SELinux context for each + container. May also be set in SecurityContext. If set in + both SecurityContext and PodSecurityContext, the value specified in SecurityContext + takes precedence for that container. + Note that this field cannot be set when spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: |- + The seccomp options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile defined in a file on the node should be used. + The profile must be preconfigured on the node to work. + Must be a descending path, relative to the kubelet's configured seccomp profile location. + Must be set if type is "Localhost". Must NOT be set for any other type. + type: string + type: + description: |- + type indicates which kind of seccomp profile will be applied. + Valid options are: + + Localhost - a profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile should be used. + Unconfined - no profile should be applied. + type: string + required: + - type + type: object + supplementalGroups: + description: |- + A list of groups applied to the first process run in each container, in + addition to the container's primary GID and fsGroup (if specified). If + the SupplementalGroupsPolicy feature is enabled, the + supplementalGroupsPolicy field determines whether these are in addition + to or instead of any group memberships defined in the container image. + If unspecified, no additional groups are added, though group memberships + defined in the container image may still be used, depending on the + supplementalGroupsPolicy field. + Note that this field cannot be set when spec.os.name is windows. + items: + format: int64 + type: integer + type: array + x-kubernetes-list-type: atomic + supplementalGroupsPolicy: + description: |- + Defines how supplemental groups of the first container processes are calculated. + Valid values are "Merge" and "Strict". If not specified, "Merge" is used. + (Alpha) Using the field requires the SupplementalGroupsPolicy feature gate to be enabled + and the container runtime must implement support for this feature. + Note that this field cannot be set when spec.os.name is windows. + type: string + sysctls: + description: |- + Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported + sysctls (by the container runtime) might fail to launch. + Note that this field cannot be set when spec.os.name is windows. + items: + description: Sysctl defines a kernel parameter to be set + properties: + name: + description: Name of a property to set + type: string + value: + description: Value of a property to set + type: string + required: + - name + - value + type: object + type: array + x-kubernetes-list-type: atomic + windowsOptions: + description: |- + The Windows specific settings applied to all containers. + If unspecified, the options within a container's SecurityContext will be used. + If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is linux. + properties: + gmsaCredentialSpec: + description: |- + GMSACredentialSpec is where the GMSA admission webhook + (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the + GMSA credential spec named by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: |- + HostProcess determines if a container should be run as a 'Host Process' container. + All of a Pod's containers must have the same effective HostProcess value + (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). + In addition, if HostProcess is true then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: |- + The UserName in Windows to run the entrypoint of the container process. + Defaults to the user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: string + type: object + type: object readinessProbe: description: |- Periodic probe of container service readiness. @@ -5476,6 +5710,240 @@ spec: type: string description: Labels to add to content pods type: object + pod_security_context: + description: |- + PodSecurityContext defines the pod-level security attributes for the pulp-content pods. + If unset, runAsUser and fsGroup default to 700. + properties: + appArmorProfile: + description: |- + appArmorProfile is the AppArmor options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile loaded on the node that should be used. + The profile must be preconfigured on the node to work. + Must match the loaded name of the profile. + Must be set if and only if type is "Localhost". + type: string + type: + description: |- + type indicates which kind of AppArmor profile will be applied. + Valid options are: + Localhost - a profile pre-loaded on the node. + RuntimeDefault - the container runtime's default profile. + Unconfined - no AppArmor enforcement. + type: string + required: + - type + type: object + fsGroup: + description: |- + A special supplemental group that applies to all containers in a pod. + Some volume types allow the Kubelet to change the ownership of that volume + to be owned by the pod: + + 1. The owning GID will be the FSGroup + 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) + 3. The permission bits are OR'd with rw-rw---- + + If unset, the Kubelet will not modify the ownership and permissions of any volume. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + fsGroupChangePolicy: + description: |- + fsGroupChangePolicy defines behavior of changing ownership and permission of the volume + before being exposed inside Pod. This field will only apply to + volume types which support fsGroup based ownership(and permissions). + It will have no effect on ephemeral volume types such as: secret, configmaps + and emptydir. + Valid values are "OnRootMismatch" and "Always". If not specified, "Always" is used. + Note that this field cannot be set when spec.os.name is windows. + type: string + runAsGroup: + description: |- + The GID to run the entrypoint of the container process. + Uses runtime default if unset. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: |- + Indicates that the container must run as a non-root user. + If true, the Kubelet will validate the image at runtime to ensure that it + does not run as UID 0 (root) and fail to start the container if it does. + If unset or false, no such validation will be performed. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: |- + The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxChangePolicy: + description: |- + seLinuxChangePolicy defines how the container's SELinux label is applied to all volumes used by the Pod. + It has no effect on nodes that do not support SELinux or to volumes does not support SELinux. + Valid values are "MountOption" and "Recursive". + + "Recursive" means relabeling of all files on all Pod volumes by the container runtime. + This may be slow for large volumes, but allows mixing privileged and unprivileged Pods sharing the same volume on the same node. + + "MountOption" mounts all eligible Pod volumes with `-o context` mount option. + This requires all Pods that share the same volume to use the same SELinux label. + It is not possible to share the same volume among privileged and unprivileged Pods. + Eligible volumes are in-tree FibreChannel and iSCSI volumes, and all CSI volumes + whose CSI driver announces SELinux support by setting spec.seLinuxMount: true in their + CSIDriver instance. Other volumes are always re-labelled recursively. + "MountOption" value is allowed only when SELinuxMount feature gate is enabled. + + If not specified and SELinuxMount feature gate is enabled, "MountOption" is used. + If not specified and SELinuxMount feature gate is disabled, "MountOption" is used for ReadWriteOncePod volumes + and "Recursive" for all other volumes. + + This field affects only Pods that have SELinux label set, either in PodSecurityContext or in SecurityContext of all containers. + + All Pods that use the same volume should use the same seLinuxChangePolicy, otherwise some pods can get stuck in ContainerCreating state. + Note that this field cannot be set when spec.os.name is windows. + type: string + seLinuxOptions: + description: |- + The SELinux context to be applied to all containers. + If unspecified, the container runtime will allocate a random SELinux context for each + container. May also be set in SecurityContext. If set in + both SecurityContext and PodSecurityContext, the value specified in SecurityContext + takes precedence for that container. + Note that this field cannot be set when spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: |- + The seccomp options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile defined in a file on the node should be used. + The profile must be preconfigured on the node to work. + Must be a descending path, relative to the kubelet's configured seccomp profile location. + Must be set if type is "Localhost". Must NOT be set for any other type. + type: string + type: + description: |- + type indicates which kind of seccomp profile will be applied. + Valid options are: + + Localhost - a profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile should be used. + Unconfined - no profile should be applied. + type: string + required: + - type + type: object + supplementalGroups: + description: |- + A list of groups applied to the first process run in each container, in + addition to the container's primary GID and fsGroup (if specified). If + the SupplementalGroupsPolicy feature is enabled, the + supplementalGroupsPolicy field determines whether these are in addition + to or instead of any group memberships defined in the container image. + If unspecified, no additional groups are added, though group memberships + defined in the container image may still be used, depending on the + supplementalGroupsPolicy field. + Note that this field cannot be set when spec.os.name is windows. + items: + format: int64 + type: integer + type: array + x-kubernetes-list-type: atomic + supplementalGroupsPolicy: + description: |- + Defines how supplemental groups of the first container processes are calculated. + Valid values are "Merge" and "Strict". If not specified, "Merge" is used. + (Alpha) Using the field requires the SupplementalGroupsPolicy feature gate to be enabled + and the container runtime must implement support for this feature. + Note that this field cannot be set when spec.os.name is windows. + type: string + sysctls: + description: |- + Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported + sysctls (by the container runtime) might fail to launch. + Note that this field cannot be set when spec.os.name is windows. + items: + description: Sysctl defines a kernel parameter to be set + properties: + name: + description: Name of a property to set + type: string + value: + description: Value of a property to set + type: string + required: + - name + - value + type: object + type: array + x-kubernetes-list-type: atomic + windowsOptions: + description: |- + The Windows specific settings applied to all containers. + If unspecified, the options within a container's SecurityContext will be used. + If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is linux. + properties: + gmsaCredentialSpec: + description: |- + GMSACredentialSpec is where the GMSA admission webhook + (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the + GMSA credential spec named by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: |- + HostProcess determines if a container should be run as a 'Host Process' container. + All of a Pod's containers must have the same effective HostProcess value + (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). + In addition, if HostProcess is true then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: |- + The UserName in Windows to run the entrypoint of the container process. + Defaults to the user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: string + type: object + type: object readinessProbe: description: |- Periodic probe of container service readiness. @@ -8645,6 +9113,240 @@ spec: type: string description: Labels to add to web pods type: object + pod_security_context: + description: |- + PodSecurityContext defines the pod-level security attributes for the pulp-web pods. + If unset, runAsUser and fsGroup default to 700. + properties: + appArmorProfile: + description: |- + appArmorProfile is the AppArmor options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile loaded on the node that should be used. + The profile must be preconfigured on the node to work. + Must match the loaded name of the profile. + Must be set if and only if type is "Localhost". + type: string + type: + description: |- + type indicates which kind of AppArmor profile will be applied. + Valid options are: + Localhost - a profile pre-loaded on the node. + RuntimeDefault - the container runtime's default profile. + Unconfined - no AppArmor enforcement. + type: string + required: + - type + type: object + fsGroup: + description: |- + A special supplemental group that applies to all containers in a pod. + Some volume types allow the Kubelet to change the ownership of that volume + to be owned by the pod: + + 1. The owning GID will be the FSGroup + 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) + 3. The permission bits are OR'd with rw-rw---- + + If unset, the Kubelet will not modify the ownership and permissions of any volume. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + fsGroupChangePolicy: + description: |- + fsGroupChangePolicy defines behavior of changing ownership and permission of the volume + before being exposed inside Pod. This field will only apply to + volume types which support fsGroup based ownership(and permissions). + It will have no effect on ephemeral volume types such as: secret, configmaps + and emptydir. + Valid values are "OnRootMismatch" and "Always". If not specified, "Always" is used. + Note that this field cannot be set when spec.os.name is windows. + type: string + runAsGroup: + description: |- + The GID to run the entrypoint of the container process. + Uses runtime default if unset. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: |- + Indicates that the container must run as a non-root user. + If true, the Kubelet will validate the image at runtime to ensure that it + does not run as UID 0 (root) and fail to start the container if it does. + If unset or false, no such validation will be performed. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: |- + The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxChangePolicy: + description: |- + seLinuxChangePolicy defines how the container's SELinux label is applied to all volumes used by the Pod. + It has no effect on nodes that do not support SELinux or to volumes does not support SELinux. + Valid values are "MountOption" and "Recursive". + + "Recursive" means relabeling of all files on all Pod volumes by the container runtime. + This may be slow for large volumes, but allows mixing privileged and unprivileged Pods sharing the same volume on the same node. + + "MountOption" mounts all eligible Pod volumes with `-o context` mount option. + This requires all Pods that share the same volume to use the same SELinux label. + It is not possible to share the same volume among privileged and unprivileged Pods. + Eligible volumes are in-tree FibreChannel and iSCSI volumes, and all CSI volumes + whose CSI driver announces SELinux support by setting spec.seLinuxMount: true in their + CSIDriver instance. Other volumes are always re-labelled recursively. + "MountOption" value is allowed only when SELinuxMount feature gate is enabled. + + If not specified and SELinuxMount feature gate is enabled, "MountOption" is used. + If not specified and SELinuxMount feature gate is disabled, "MountOption" is used for ReadWriteOncePod volumes + and "Recursive" for all other volumes. + + This field affects only Pods that have SELinux label set, either in PodSecurityContext or in SecurityContext of all containers. + + All Pods that use the same volume should use the same seLinuxChangePolicy, otherwise some pods can get stuck in ContainerCreating state. + Note that this field cannot be set when spec.os.name is windows. + type: string + seLinuxOptions: + description: |- + The SELinux context to be applied to all containers. + If unspecified, the container runtime will allocate a random SELinux context for each + container. May also be set in SecurityContext. If set in + both SecurityContext and PodSecurityContext, the value specified in SecurityContext + takes precedence for that container. + Note that this field cannot be set when spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: |- + The seccomp options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile defined in a file on the node should be used. + The profile must be preconfigured on the node to work. + Must be a descending path, relative to the kubelet's configured seccomp profile location. + Must be set if type is "Localhost". Must NOT be set for any other type. + type: string + type: + description: |- + type indicates which kind of seccomp profile will be applied. + Valid options are: + + Localhost - a profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile should be used. + Unconfined - no profile should be applied. + type: string + required: + - type + type: object + supplementalGroups: + description: |- + A list of groups applied to the first process run in each container, in + addition to the container's primary GID and fsGroup (if specified). If + the SupplementalGroupsPolicy feature is enabled, the + supplementalGroupsPolicy field determines whether these are in addition + to or instead of any group memberships defined in the container image. + If unspecified, no additional groups are added, though group memberships + defined in the container image may still be used, depending on the + supplementalGroupsPolicy field. + Note that this field cannot be set when spec.os.name is windows. + items: + format: int64 + type: integer + type: array + x-kubernetes-list-type: atomic + supplementalGroupsPolicy: + description: |- + Defines how supplemental groups of the first container processes are calculated. + Valid values are "Merge" and "Strict". If not specified, "Merge" is used. + (Alpha) Using the field requires the SupplementalGroupsPolicy feature gate to be enabled + and the container runtime must implement support for this feature. + Note that this field cannot be set when spec.os.name is windows. + type: string + sysctls: + description: |- + Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported + sysctls (by the container runtime) might fail to launch. + Note that this field cannot be set when spec.os.name is windows. + items: + description: Sysctl defines a kernel parameter to be set + properties: + name: + description: Name of a property to set + type: string + value: + description: Value of a property to set + type: string + required: + - name + - value + type: object + type: array + x-kubernetes-list-type: atomic + windowsOptions: + description: |- + The Windows specific settings applied to all containers. + If unspecified, the options within a container's SecurityContext will be used. + If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is linux. + properties: + gmsaCredentialSpec: + description: |- + GMSACredentialSpec is where the GMSA admission webhook + (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the + GMSA credential spec named by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: |- + HostProcess determines if a container should be run as a 'Host Process' container. + All of a Pod's containers must have the same effective HostProcess value + (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). + In addition, if HostProcess is true then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: |- + The UserName in Windows to run the entrypoint of the container process. + Defaults to the user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: string + type: object + type: object readinessProbe: description: |- Periodic probe of container service readiness. @@ -10552,6 +11254,240 @@ spec: type: string description: Labels to add to worker pods type: object + pod_security_context: + description: |- + PodSecurityContext defines the pod-level security attributes for the pulp-worker pods. + If unset, runAsUser and fsGroup default to 700. + properties: + appArmorProfile: + description: |- + appArmorProfile is the AppArmor options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile loaded on the node that should be used. + The profile must be preconfigured on the node to work. + Must match the loaded name of the profile. + Must be set if and only if type is "Localhost". + type: string + type: + description: |- + type indicates which kind of AppArmor profile will be applied. + Valid options are: + Localhost - a profile pre-loaded on the node. + RuntimeDefault - the container runtime's default profile. + Unconfined - no AppArmor enforcement. + type: string + required: + - type + type: object + fsGroup: + description: |- + A special supplemental group that applies to all containers in a pod. + Some volume types allow the Kubelet to change the ownership of that volume + to be owned by the pod: + + 1. The owning GID will be the FSGroup + 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) + 3. The permission bits are OR'd with rw-rw---- + + If unset, the Kubelet will not modify the ownership and permissions of any volume. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + fsGroupChangePolicy: + description: |- + fsGroupChangePolicy defines behavior of changing ownership and permission of the volume + before being exposed inside Pod. This field will only apply to + volume types which support fsGroup based ownership(and permissions). + It will have no effect on ephemeral volume types such as: secret, configmaps + and emptydir. + Valid values are "OnRootMismatch" and "Always". If not specified, "Always" is used. + Note that this field cannot be set when spec.os.name is windows. + type: string + runAsGroup: + description: |- + The GID to run the entrypoint of the container process. + Uses runtime default if unset. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: |- + Indicates that the container must run as a non-root user. + If true, the Kubelet will validate the image at runtime to ensure that it + does not run as UID 0 (root) and fail to start the container if it does. + If unset or false, no such validation will be performed. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: |- + The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxChangePolicy: + description: |- + seLinuxChangePolicy defines how the container's SELinux label is applied to all volumes used by the Pod. + It has no effect on nodes that do not support SELinux or to volumes does not support SELinux. + Valid values are "MountOption" and "Recursive". + + "Recursive" means relabeling of all files on all Pod volumes by the container runtime. + This may be slow for large volumes, but allows mixing privileged and unprivileged Pods sharing the same volume on the same node. + + "MountOption" mounts all eligible Pod volumes with `-o context` mount option. + This requires all Pods that share the same volume to use the same SELinux label. + It is not possible to share the same volume among privileged and unprivileged Pods. + Eligible volumes are in-tree FibreChannel and iSCSI volumes, and all CSI volumes + whose CSI driver announces SELinux support by setting spec.seLinuxMount: true in their + CSIDriver instance. Other volumes are always re-labelled recursively. + "MountOption" value is allowed only when SELinuxMount feature gate is enabled. + + If not specified and SELinuxMount feature gate is enabled, "MountOption" is used. + If not specified and SELinuxMount feature gate is disabled, "MountOption" is used for ReadWriteOncePod volumes + and "Recursive" for all other volumes. + + This field affects only Pods that have SELinux label set, either in PodSecurityContext or in SecurityContext of all containers. + + All Pods that use the same volume should use the same seLinuxChangePolicy, otherwise some pods can get stuck in ContainerCreating state. + Note that this field cannot be set when spec.os.name is windows. + type: string + seLinuxOptions: + description: |- + The SELinux context to be applied to all containers. + If unspecified, the container runtime will allocate a random SELinux context for each + container. May also be set in SecurityContext. If set in + both SecurityContext and PodSecurityContext, the value specified in SecurityContext + takes precedence for that container. + Note that this field cannot be set when spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: |- + The seccomp options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile defined in a file on the node should be used. + The profile must be preconfigured on the node to work. + Must be a descending path, relative to the kubelet's configured seccomp profile location. + Must be set if type is "Localhost". Must NOT be set for any other type. + type: string + type: + description: |- + type indicates which kind of seccomp profile will be applied. + Valid options are: + + Localhost - a profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile should be used. + Unconfined - no profile should be applied. + type: string + required: + - type + type: object + supplementalGroups: + description: |- + A list of groups applied to the first process run in each container, in + addition to the container's primary GID and fsGroup (if specified). If + the SupplementalGroupsPolicy feature is enabled, the + supplementalGroupsPolicy field determines whether these are in addition + to or instead of any group memberships defined in the container image. + If unspecified, no additional groups are added, though group memberships + defined in the container image may still be used, depending on the + supplementalGroupsPolicy field. + Note that this field cannot be set when spec.os.name is windows. + items: + format: int64 + type: integer + type: array + x-kubernetes-list-type: atomic + supplementalGroupsPolicy: + description: |- + Defines how supplemental groups of the first container processes are calculated. + Valid values are "Merge" and "Strict". If not specified, "Merge" is used. + (Alpha) Using the field requires the SupplementalGroupsPolicy feature gate to be enabled + and the container runtime must implement support for this feature. + Note that this field cannot be set when spec.os.name is windows. + type: string + sysctls: + description: |- + Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported + sysctls (by the container runtime) might fail to launch. + Note that this field cannot be set when spec.os.name is windows. + items: + description: Sysctl defines a kernel parameter to be set + properties: + name: + description: Name of a property to set + type: string + value: + description: Value of a property to set + type: string + required: + - name + - value + type: object + type: array + x-kubernetes-list-type: atomic + windowsOptions: + description: |- + The Windows specific settings applied to all containers. + If unspecified, the options within a container's SecurityContext will be used. + If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is linux. + properties: + gmsaCredentialSpec: + description: |- + GMSACredentialSpec is where the GMSA admission webhook + (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the + GMSA credential spec named by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: |- + HostProcess determines if a container should be run as a 'Host Process' container. + All of a Pod's containers must have the same effective HostProcess value + (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). + In addition, if HostProcess is true then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: |- + The UserName in Windows to run the entrypoint of the container process. + Defaults to the user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: string + type: object + type: object readinessProbe: description: |- Periodic probe of container service readiness. diff --git a/config/crd/bases/repo-manager.pulpproject.org_pulps.yaml b/config/crd/bases/repo-manager.pulpproject.org_pulps.yaml index 01b3adb48..ae904d35d 100644 --- a/config/crd/bases/repo-manager.pulpproject.org_pulps.yaml +++ b/config/crd/bases/repo-manager.pulpproject.org_pulps.yaml @@ -1919,6 +1919,240 @@ spec: type: string description: Labels to add to api pods type: object + pod_security_context: + description: |- + PodSecurityContext defines the pod-level security attributes for the pulp-api pods. + If unset, runAsUser and fsGroup default to 700. + properties: + appArmorProfile: + description: |- + appArmorProfile is the AppArmor options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile loaded on the node that should be used. + The profile must be preconfigured on the node to work. + Must match the loaded name of the profile. + Must be set if and only if type is "Localhost". + type: string + type: + description: |- + type indicates which kind of AppArmor profile will be applied. + Valid options are: + Localhost - a profile pre-loaded on the node. + RuntimeDefault - the container runtime's default profile. + Unconfined - no AppArmor enforcement. + type: string + required: + - type + type: object + fsGroup: + description: |- + A special supplemental group that applies to all containers in a pod. + Some volume types allow the Kubelet to change the ownership of that volume + to be owned by the pod: + + 1. The owning GID will be the FSGroup + 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) + 3. The permission bits are OR'd with rw-rw---- + + If unset, the Kubelet will not modify the ownership and permissions of any volume. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + fsGroupChangePolicy: + description: |- + fsGroupChangePolicy defines behavior of changing ownership and permission of the volume + before being exposed inside Pod. This field will only apply to + volume types which support fsGroup based ownership(and permissions). + It will have no effect on ephemeral volume types such as: secret, configmaps + and emptydir. + Valid values are "OnRootMismatch" and "Always". If not specified, "Always" is used. + Note that this field cannot be set when spec.os.name is windows. + type: string + runAsGroup: + description: |- + The GID to run the entrypoint of the container process. + Uses runtime default if unset. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: |- + Indicates that the container must run as a non-root user. + If true, the Kubelet will validate the image at runtime to ensure that it + does not run as UID 0 (root) and fail to start the container if it does. + If unset or false, no such validation will be performed. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: |- + The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxChangePolicy: + description: |- + seLinuxChangePolicy defines how the container's SELinux label is applied to all volumes used by the Pod. + It has no effect on nodes that do not support SELinux or to volumes does not support SELinux. + Valid values are "MountOption" and "Recursive". + + "Recursive" means relabeling of all files on all Pod volumes by the container runtime. + This may be slow for large volumes, but allows mixing privileged and unprivileged Pods sharing the same volume on the same node. + + "MountOption" mounts all eligible Pod volumes with `-o context` mount option. + This requires all Pods that share the same volume to use the same SELinux label. + It is not possible to share the same volume among privileged and unprivileged Pods. + Eligible volumes are in-tree FibreChannel and iSCSI volumes, and all CSI volumes + whose CSI driver announces SELinux support by setting spec.seLinuxMount: true in their + CSIDriver instance. Other volumes are always re-labelled recursively. + "MountOption" value is allowed only when SELinuxMount feature gate is enabled. + + If not specified and SELinuxMount feature gate is enabled, "MountOption" is used. + If not specified and SELinuxMount feature gate is disabled, "MountOption" is used for ReadWriteOncePod volumes + and "Recursive" for all other volumes. + + This field affects only Pods that have SELinux label set, either in PodSecurityContext or in SecurityContext of all containers. + + All Pods that use the same volume should use the same seLinuxChangePolicy, otherwise some pods can get stuck in ContainerCreating state. + Note that this field cannot be set when spec.os.name is windows. + type: string + seLinuxOptions: + description: |- + The SELinux context to be applied to all containers. + If unspecified, the container runtime will allocate a random SELinux context for each + container. May also be set in SecurityContext. If set in + both SecurityContext and PodSecurityContext, the value specified in SecurityContext + takes precedence for that container. + Note that this field cannot be set when spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: |- + The seccomp options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile defined in a file on the node should be used. + The profile must be preconfigured on the node to work. + Must be a descending path, relative to the kubelet's configured seccomp profile location. + Must be set if type is "Localhost". Must NOT be set for any other type. + type: string + type: + description: |- + type indicates which kind of seccomp profile will be applied. + Valid options are: + + Localhost - a profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile should be used. + Unconfined - no profile should be applied. + type: string + required: + - type + type: object + supplementalGroups: + description: |- + A list of groups applied to the first process run in each container, in + addition to the container's primary GID and fsGroup (if specified). If + the SupplementalGroupsPolicy feature is enabled, the + supplementalGroupsPolicy field determines whether these are in addition + to or instead of any group memberships defined in the container image. + If unspecified, no additional groups are added, though group memberships + defined in the container image may still be used, depending on the + supplementalGroupsPolicy field. + Note that this field cannot be set when spec.os.name is windows. + items: + format: int64 + type: integer + type: array + x-kubernetes-list-type: atomic + supplementalGroupsPolicy: + description: |- + Defines how supplemental groups of the first container processes are calculated. + Valid values are "Merge" and "Strict". If not specified, "Merge" is used. + (Alpha) Using the field requires the SupplementalGroupsPolicy feature gate to be enabled + and the container runtime must implement support for this feature. + Note that this field cannot be set when spec.os.name is windows. + type: string + sysctls: + description: |- + Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported + sysctls (by the container runtime) might fail to launch. + Note that this field cannot be set when spec.os.name is windows. + items: + description: Sysctl defines a kernel parameter to be set + properties: + name: + description: Name of a property to set + type: string + value: + description: Value of a property to set + type: string + required: + - name + - value + type: object + type: array + x-kubernetes-list-type: atomic + windowsOptions: + description: |- + The Windows specific settings applied to all containers. + If unspecified, the options within a container's SecurityContext will be used. + If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is linux. + properties: + gmsaCredentialSpec: + description: |- + GMSACredentialSpec is where the GMSA admission webhook + (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the + GMSA credential spec named by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: |- + HostProcess determines if a container should be run as a 'Host Process' container. + All of a Pod's containers must have the same effective HostProcess value + (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). + In addition, if HostProcess is true then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: |- + The UserName in Windows to run the entrypoint of the container process. + Defaults to the user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: string + type: object + type: object readinessProbe: description: |- Periodic probe of container service readiness. @@ -5476,6 +5710,240 @@ spec: type: string description: Labels to add to content pods type: object + pod_security_context: + description: |- + PodSecurityContext defines the pod-level security attributes for the pulp-content pods. + If unset, runAsUser and fsGroup default to 700. + properties: + appArmorProfile: + description: |- + appArmorProfile is the AppArmor options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile loaded on the node that should be used. + The profile must be preconfigured on the node to work. + Must match the loaded name of the profile. + Must be set if and only if type is "Localhost". + type: string + type: + description: |- + type indicates which kind of AppArmor profile will be applied. + Valid options are: + Localhost - a profile pre-loaded on the node. + RuntimeDefault - the container runtime's default profile. + Unconfined - no AppArmor enforcement. + type: string + required: + - type + type: object + fsGroup: + description: |- + A special supplemental group that applies to all containers in a pod. + Some volume types allow the Kubelet to change the ownership of that volume + to be owned by the pod: + + 1. The owning GID will be the FSGroup + 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) + 3. The permission bits are OR'd with rw-rw---- + + If unset, the Kubelet will not modify the ownership and permissions of any volume. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + fsGroupChangePolicy: + description: |- + fsGroupChangePolicy defines behavior of changing ownership and permission of the volume + before being exposed inside Pod. This field will only apply to + volume types which support fsGroup based ownership(and permissions). + It will have no effect on ephemeral volume types such as: secret, configmaps + and emptydir. + Valid values are "OnRootMismatch" and "Always". If not specified, "Always" is used. + Note that this field cannot be set when spec.os.name is windows. + type: string + runAsGroup: + description: |- + The GID to run the entrypoint of the container process. + Uses runtime default if unset. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: |- + Indicates that the container must run as a non-root user. + If true, the Kubelet will validate the image at runtime to ensure that it + does not run as UID 0 (root) and fail to start the container if it does. + If unset or false, no such validation will be performed. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: |- + The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxChangePolicy: + description: |- + seLinuxChangePolicy defines how the container's SELinux label is applied to all volumes used by the Pod. + It has no effect on nodes that do not support SELinux or to volumes does not support SELinux. + Valid values are "MountOption" and "Recursive". + + "Recursive" means relabeling of all files on all Pod volumes by the container runtime. + This may be slow for large volumes, but allows mixing privileged and unprivileged Pods sharing the same volume on the same node. + + "MountOption" mounts all eligible Pod volumes with `-o context` mount option. + This requires all Pods that share the same volume to use the same SELinux label. + It is not possible to share the same volume among privileged and unprivileged Pods. + Eligible volumes are in-tree FibreChannel and iSCSI volumes, and all CSI volumes + whose CSI driver announces SELinux support by setting spec.seLinuxMount: true in their + CSIDriver instance. Other volumes are always re-labelled recursively. + "MountOption" value is allowed only when SELinuxMount feature gate is enabled. + + If not specified and SELinuxMount feature gate is enabled, "MountOption" is used. + If not specified and SELinuxMount feature gate is disabled, "MountOption" is used for ReadWriteOncePod volumes + and "Recursive" for all other volumes. + + This field affects only Pods that have SELinux label set, either in PodSecurityContext or in SecurityContext of all containers. + + All Pods that use the same volume should use the same seLinuxChangePolicy, otherwise some pods can get stuck in ContainerCreating state. + Note that this field cannot be set when spec.os.name is windows. + type: string + seLinuxOptions: + description: |- + The SELinux context to be applied to all containers. + If unspecified, the container runtime will allocate a random SELinux context for each + container. May also be set in SecurityContext. If set in + both SecurityContext and PodSecurityContext, the value specified in SecurityContext + takes precedence for that container. + Note that this field cannot be set when spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: |- + The seccomp options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile defined in a file on the node should be used. + The profile must be preconfigured on the node to work. + Must be a descending path, relative to the kubelet's configured seccomp profile location. + Must be set if type is "Localhost". Must NOT be set for any other type. + type: string + type: + description: |- + type indicates which kind of seccomp profile will be applied. + Valid options are: + + Localhost - a profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile should be used. + Unconfined - no profile should be applied. + type: string + required: + - type + type: object + supplementalGroups: + description: |- + A list of groups applied to the first process run in each container, in + addition to the container's primary GID and fsGroup (if specified). If + the SupplementalGroupsPolicy feature is enabled, the + supplementalGroupsPolicy field determines whether these are in addition + to or instead of any group memberships defined in the container image. + If unspecified, no additional groups are added, though group memberships + defined in the container image may still be used, depending on the + supplementalGroupsPolicy field. + Note that this field cannot be set when spec.os.name is windows. + items: + format: int64 + type: integer + type: array + x-kubernetes-list-type: atomic + supplementalGroupsPolicy: + description: |- + Defines how supplemental groups of the first container processes are calculated. + Valid values are "Merge" and "Strict". If not specified, "Merge" is used. + (Alpha) Using the field requires the SupplementalGroupsPolicy feature gate to be enabled + and the container runtime must implement support for this feature. + Note that this field cannot be set when spec.os.name is windows. + type: string + sysctls: + description: |- + Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported + sysctls (by the container runtime) might fail to launch. + Note that this field cannot be set when spec.os.name is windows. + items: + description: Sysctl defines a kernel parameter to be set + properties: + name: + description: Name of a property to set + type: string + value: + description: Value of a property to set + type: string + required: + - name + - value + type: object + type: array + x-kubernetes-list-type: atomic + windowsOptions: + description: |- + The Windows specific settings applied to all containers. + If unspecified, the options within a container's SecurityContext will be used. + If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is linux. + properties: + gmsaCredentialSpec: + description: |- + GMSACredentialSpec is where the GMSA admission webhook + (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the + GMSA credential spec named by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: |- + HostProcess determines if a container should be run as a 'Host Process' container. + All of a Pod's containers must have the same effective HostProcess value + (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). + In addition, if HostProcess is true then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: |- + The UserName in Windows to run the entrypoint of the container process. + Defaults to the user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: string + type: object + type: object readinessProbe: description: |- Periodic probe of container service readiness. @@ -8645,6 +9113,240 @@ spec: type: string description: Labels to add to web pods type: object + pod_security_context: + description: |- + PodSecurityContext defines the pod-level security attributes for the pulp-web pods. + If unset, runAsUser and fsGroup default to 700. + properties: + appArmorProfile: + description: |- + appArmorProfile is the AppArmor options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile loaded on the node that should be used. + The profile must be preconfigured on the node to work. + Must match the loaded name of the profile. + Must be set if and only if type is "Localhost". + type: string + type: + description: |- + type indicates which kind of AppArmor profile will be applied. + Valid options are: + Localhost - a profile pre-loaded on the node. + RuntimeDefault - the container runtime's default profile. + Unconfined - no AppArmor enforcement. + type: string + required: + - type + type: object + fsGroup: + description: |- + A special supplemental group that applies to all containers in a pod. + Some volume types allow the Kubelet to change the ownership of that volume + to be owned by the pod: + + 1. The owning GID will be the FSGroup + 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) + 3. The permission bits are OR'd with rw-rw---- + + If unset, the Kubelet will not modify the ownership and permissions of any volume. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + fsGroupChangePolicy: + description: |- + fsGroupChangePolicy defines behavior of changing ownership and permission of the volume + before being exposed inside Pod. This field will only apply to + volume types which support fsGroup based ownership(and permissions). + It will have no effect on ephemeral volume types such as: secret, configmaps + and emptydir. + Valid values are "OnRootMismatch" and "Always". If not specified, "Always" is used. + Note that this field cannot be set when spec.os.name is windows. + type: string + runAsGroup: + description: |- + The GID to run the entrypoint of the container process. + Uses runtime default if unset. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: |- + Indicates that the container must run as a non-root user. + If true, the Kubelet will validate the image at runtime to ensure that it + does not run as UID 0 (root) and fail to start the container if it does. + If unset or false, no such validation will be performed. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: |- + The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxChangePolicy: + description: |- + seLinuxChangePolicy defines how the container's SELinux label is applied to all volumes used by the Pod. + It has no effect on nodes that do not support SELinux or to volumes does not support SELinux. + Valid values are "MountOption" and "Recursive". + + "Recursive" means relabeling of all files on all Pod volumes by the container runtime. + This may be slow for large volumes, but allows mixing privileged and unprivileged Pods sharing the same volume on the same node. + + "MountOption" mounts all eligible Pod volumes with `-o context` mount option. + This requires all Pods that share the same volume to use the same SELinux label. + It is not possible to share the same volume among privileged and unprivileged Pods. + Eligible volumes are in-tree FibreChannel and iSCSI volumes, and all CSI volumes + whose CSI driver announces SELinux support by setting spec.seLinuxMount: true in their + CSIDriver instance. Other volumes are always re-labelled recursively. + "MountOption" value is allowed only when SELinuxMount feature gate is enabled. + + If not specified and SELinuxMount feature gate is enabled, "MountOption" is used. + If not specified and SELinuxMount feature gate is disabled, "MountOption" is used for ReadWriteOncePod volumes + and "Recursive" for all other volumes. + + This field affects only Pods that have SELinux label set, either in PodSecurityContext or in SecurityContext of all containers. + + All Pods that use the same volume should use the same seLinuxChangePolicy, otherwise some pods can get stuck in ContainerCreating state. + Note that this field cannot be set when spec.os.name is windows. + type: string + seLinuxOptions: + description: |- + The SELinux context to be applied to all containers. + If unspecified, the container runtime will allocate a random SELinux context for each + container. May also be set in SecurityContext. If set in + both SecurityContext and PodSecurityContext, the value specified in SecurityContext + takes precedence for that container. + Note that this field cannot be set when spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: |- + The seccomp options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile defined in a file on the node should be used. + The profile must be preconfigured on the node to work. + Must be a descending path, relative to the kubelet's configured seccomp profile location. + Must be set if type is "Localhost". Must NOT be set for any other type. + type: string + type: + description: |- + type indicates which kind of seccomp profile will be applied. + Valid options are: + + Localhost - a profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile should be used. + Unconfined - no profile should be applied. + type: string + required: + - type + type: object + supplementalGroups: + description: |- + A list of groups applied to the first process run in each container, in + addition to the container's primary GID and fsGroup (if specified). If + the SupplementalGroupsPolicy feature is enabled, the + supplementalGroupsPolicy field determines whether these are in addition + to or instead of any group memberships defined in the container image. + If unspecified, no additional groups are added, though group memberships + defined in the container image may still be used, depending on the + supplementalGroupsPolicy field. + Note that this field cannot be set when spec.os.name is windows. + items: + format: int64 + type: integer + type: array + x-kubernetes-list-type: atomic + supplementalGroupsPolicy: + description: |- + Defines how supplemental groups of the first container processes are calculated. + Valid values are "Merge" and "Strict". If not specified, "Merge" is used. + (Alpha) Using the field requires the SupplementalGroupsPolicy feature gate to be enabled + and the container runtime must implement support for this feature. + Note that this field cannot be set when spec.os.name is windows. + type: string + sysctls: + description: |- + Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported + sysctls (by the container runtime) might fail to launch. + Note that this field cannot be set when spec.os.name is windows. + items: + description: Sysctl defines a kernel parameter to be set + properties: + name: + description: Name of a property to set + type: string + value: + description: Value of a property to set + type: string + required: + - name + - value + type: object + type: array + x-kubernetes-list-type: atomic + windowsOptions: + description: |- + The Windows specific settings applied to all containers. + If unspecified, the options within a container's SecurityContext will be used. + If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is linux. + properties: + gmsaCredentialSpec: + description: |- + GMSACredentialSpec is where the GMSA admission webhook + (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the + GMSA credential spec named by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: |- + HostProcess determines if a container should be run as a 'Host Process' container. + All of a Pod's containers must have the same effective HostProcess value + (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). + In addition, if HostProcess is true then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: |- + The UserName in Windows to run the entrypoint of the container process. + Defaults to the user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: string + type: object + type: object readinessProbe: description: |- Periodic probe of container service readiness. @@ -10552,6 +11254,240 @@ spec: type: string description: Labels to add to worker pods type: object + pod_security_context: + description: |- + PodSecurityContext defines the pod-level security attributes for the pulp-worker pods. + If unset, runAsUser and fsGroup default to 700. + properties: + appArmorProfile: + description: |- + appArmorProfile is the AppArmor options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile loaded on the node that should be used. + The profile must be preconfigured on the node to work. + Must match the loaded name of the profile. + Must be set if and only if type is "Localhost". + type: string + type: + description: |- + type indicates which kind of AppArmor profile will be applied. + Valid options are: + Localhost - a profile pre-loaded on the node. + RuntimeDefault - the container runtime's default profile. + Unconfined - no AppArmor enforcement. + type: string + required: + - type + type: object + fsGroup: + description: |- + A special supplemental group that applies to all containers in a pod. + Some volume types allow the Kubelet to change the ownership of that volume + to be owned by the pod: + + 1. The owning GID will be the FSGroup + 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) + 3. The permission bits are OR'd with rw-rw---- + + If unset, the Kubelet will not modify the ownership and permissions of any volume. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + fsGroupChangePolicy: + description: |- + fsGroupChangePolicy defines behavior of changing ownership and permission of the volume + before being exposed inside Pod. This field will only apply to + volume types which support fsGroup based ownership(and permissions). + It will have no effect on ephemeral volume types such as: secret, configmaps + and emptydir. + Valid values are "OnRootMismatch" and "Always". If not specified, "Always" is used. + Note that this field cannot be set when spec.os.name is windows. + type: string + runAsGroup: + description: |- + The GID to run the entrypoint of the container process. + Uses runtime default if unset. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: |- + Indicates that the container must run as a non-root user. + If true, the Kubelet will validate the image at runtime to ensure that it + does not run as UID 0 (root) and fail to start the container if it does. + If unset or false, no such validation will be performed. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: |- + The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in SecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence + for that container. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxChangePolicy: + description: |- + seLinuxChangePolicy defines how the container's SELinux label is applied to all volumes used by the Pod. + It has no effect on nodes that do not support SELinux or to volumes does not support SELinux. + Valid values are "MountOption" and "Recursive". + + "Recursive" means relabeling of all files on all Pod volumes by the container runtime. + This may be slow for large volumes, but allows mixing privileged and unprivileged Pods sharing the same volume on the same node. + + "MountOption" mounts all eligible Pod volumes with `-o context` mount option. + This requires all Pods that share the same volume to use the same SELinux label. + It is not possible to share the same volume among privileged and unprivileged Pods. + Eligible volumes are in-tree FibreChannel and iSCSI volumes, and all CSI volumes + whose CSI driver announces SELinux support by setting spec.seLinuxMount: true in their + CSIDriver instance. Other volumes are always re-labelled recursively. + "MountOption" value is allowed only when SELinuxMount feature gate is enabled. + + If not specified and SELinuxMount feature gate is enabled, "MountOption" is used. + If not specified and SELinuxMount feature gate is disabled, "MountOption" is used for ReadWriteOncePod volumes + and "Recursive" for all other volumes. + + This field affects only Pods that have SELinux label set, either in PodSecurityContext or in SecurityContext of all containers. + + All Pods that use the same volume should use the same seLinuxChangePolicy, otherwise some pods can get stuck in ContainerCreating state. + Note that this field cannot be set when spec.os.name is windows. + type: string + seLinuxOptions: + description: |- + The SELinux context to be applied to all containers. + If unspecified, the container runtime will allocate a random SELinux context for each + container. May also be set in SecurityContext. If set in + both SecurityContext and PodSecurityContext, the value specified in SecurityContext + takes precedence for that container. + Note that this field cannot be set when spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: |- + The seccomp options to use by the containers in this pod. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile defined in a file on the node should be used. + The profile must be preconfigured on the node to work. + Must be a descending path, relative to the kubelet's configured seccomp profile location. + Must be set if type is "Localhost". Must NOT be set for any other type. + type: string + type: + description: |- + type indicates which kind of seccomp profile will be applied. + Valid options are: + + Localhost - a profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile should be used. + Unconfined - no profile should be applied. + type: string + required: + - type + type: object + supplementalGroups: + description: |- + A list of groups applied to the first process run in each container, in + addition to the container's primary GID and fsGroup (if specified). If + the SupplementalGroupsPolicy feature is enabled, the + supplementalGroupsPolicy field determines whether these are in addition + to or instead of any group memberships defined in the container image. + If unspecified, no additional groups are added, though group memberships + defined in the container image may still be used, depending on the + supplementalGroupsPolicy field. + Note that this field cannot be set when spec.os.name is windows. + items: + format: int64 + type: integer + type: array + x-kubernetes-list-type: atomic + supplementalGroupsPolicy: + description: |- + Defines how supplemental groups of the first container processes are calculated. + Valid values are "Merge" and "Strict". If not specified, "Merge" is used. + (Alpha) Using the field requires the SupplementalGroupsPolicy feature gate to be enabled + and the container runtime must implement support for this feature. + Note that this field cannot be set when spec.os.name is windows. + type: string + sysctls: + description: |- + Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported + sysctls (by the container runtime) might fail to launch. + Note that this field cannot be set when spec.os.name is windows. + items: + description: Sysctl defines a kernel parameter to be set + properties: + name: + description: Name of a property to set + type: string + value: + description: Value of a property to set + type: string + required: + - name + - value + type: object + type: array + x-kubernetes-list-type: atomic + windowsOptions: + description: |- + The Windows specific settings applied to all containers. + If unspecified, the options within a container's SecurityContext will be used. + If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is linux. + properties: + gmsaCredentialSpec: + description: |- + GMSACredentialSpec is where the GMSA admission webhook + (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the + GMSA credential spec named by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: |- + HostProcess determines if a container should be run as a 'Host Process' container. + All of a Pod's containers must have the same effective HostProcess value + (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). + In addition, if HostProcess is true then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: |- + The UserName in Windows to run the entrypoint of the container process. + Defaults to the user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: string + type: object + type: object readinessProbe: description: |- Periodic probe of container service readiness. diff --git a/config/manifests/bases/pulp-operator.clusterserviceversion.yaml b/config/manifests/bases/pulp-operator.clusterserviceversion.yaml index 4cae58950..ac1cc5d1d 100644 --- a/config/manifests/bases/pulp-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/pulp-operator.clusterserviceversion.yaml @@ -282,6 +282,12 @@ spec: path: api.pod_labels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced + - description: PodSecurityContext defines the pod-level security attributes + for the pulp-api pods. If unset, runAsUser and fsGroup default to 700. + displayName: Pod Security Context + path: api.pod_security_context + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced - description: Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. displayName: Readiness Probe @@ -498,6 +504,12 @@ spec: path: content.pod_labels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced + - description: PodSecurityContext defines the pod-level security attributes + for the pulp-content pods. If unset, runAsUser and fsGroup default to 700. + displayName: Pod Security Context + path: content.pod_security_context + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced - description: Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. displayName: Readiness Probe @@ -1019,6 +1031,12 @@ spec: path: web.pod_labels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced + - description: PodSecurityContext defines the pod-level security attributes + for the pulp-web pods. If unset, runAsUser and fsGroup default to 700. + displayName: Pod Security Context + path: web.pod_security_context + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced - description: Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. displayName: Readiness Probe @@ -1103,6 +1121,12 @@ spec: path: worker.pod_labels x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced + - description: PodSecurityContext defines the pod-level security attributes + for the pulp-worker pods. If unset, runAsUser and fsGroup default to 700. + displayName: Pod Security Context + path: worker.pod_security_context + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced - description: Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. displayName: Readiness Probe diff --git a/config/samples/simple.pod-security-context.yaml b/config/samples/simple.pod-security-context.yaml new file mode 100644 index 000000000..cd6846c51 --- /dev/null +++ b/config/samples/simple.pod-security-context.yaml @@ -0,0 +1,32 @@ +--- +apiVersion: repo-manager.pulpproject.org/v1 +kind: Pulp +metadata: + name: example-pulp +spec: + # override the hardcoded runAsUser/fsGroup 700 for a custom image that + # runs its pulp user under a different UID/GID + api: + pod_security_context: + runAsUser: 101 + fsGroup: 101 + content: + pod_security_context: + runAsUser: 101 + fsGroup: 101 + worker: + pod_security_context: + runAsUser: 101 + fsGroup: 101 + web: + pod_security_context: + runAsUser: 101 + fsGroup: 101 + + database: + postgres_image: postgres:15 + postgres_storage_class: standard + + file_storage_storage_class: standard + file_storage_access_mode: "ReadWriteMany" + file_storage_size: "2Gi" diff --git a/controllers/deployment.go b/controllers/deployment.go index c887c4174..c0082bbb8 100644 --- a/controllers/deployment.go +++ b/controllers/deployment.go @@ -208,7 +208,13 @@ func (d *CommonDeployment) setStrategy(pulp pulpv1.Pulp, pulpcoreType settings.P } // setPodSecurityContext defines the pod-level security attributes -func (d *CommonDeployment) setPodSecurityContext() { +func (d *CommonDeployment) setPodSecurityContext(pulp pulpv1.Pulp, pulpcoreType settings.PulpcoreType) { + specField := reflect.ValueOf(pulp.Spec).FieldByName(string(pulpcoreType)).FieldByName("PodSecurityContext").Interface().(*corev1.PodSecurityContext) + if specField != nil { + d.podSecurityContext = specField + return + } + runAsUser := int64(700) fsGroup := int64(700) d.podSecurityContext = &corev1.PodSecurityContext{ @@ -1228,7 +1234,7 @@ func (d *CommonDeployment) build(resources any, pulpcoreType settings.PulpcoreTy d.setLabels(*pulp, pulpcoreType) d.setAnnotations(*pulp, pulpcoreType) d.setAffinity(*pulp, pulpcoreType) - d.setPodSecurityContext() + d.setPodSecurityContext(*pulp, pulpcoreType) d.setNodeSelector(*pulp, pulpcoreType) d.setTolerations(*pulp, pulpcoreType) d.setVolumes(resources, pulpcoreType) diff --git a/controllers/ocp/deployment.go b/controllers/ocp/deployment.go index c9a32c2f3..5bdf4f8b0 100644 --- a/controllers/ocp/deployment.go +++ b/controllers/ocp/deployment.go @@ -17,15 +17,25 @@ limitations under the License. package ocp import ( + "reflect" + pulpv1 "github.com/pulp/pulp-operator/apis/repo-manager.pulpproject.org/v1" "github.com/pulp/pulp-operator/controllers" + "github.com/pulp/pulp-operator/controllers/settings" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) -// defaultsForOCPDeployment sets the common Deployment configurations specific to OCP clusters -func defaultsForOCPDeployment(deployment *appsv1.Deployment, pulp *pulpv1.Pulp) { +// defaultsForOCPDeployment sets the common Deployment configurations specific to OCP clusters. +// If the CR sets an explicit pod_security_context for this component, that override is honored +// instead of being discarded, matching how web.go already behaves on OCP. +func defaultsForOCPDeployment(deployment *appsv1.Deployment, pulp *pulpv1.Pulp, pulpcoreType settings.PulpcoreType) { + specField := reflect.ValueOf(pulp.Spec).FieldByName(string(pulpcoreType)).FieldByName("PodSecurityContext").Interface().(*corev1.PodSecurityContext) + if specField != nil { + return + } + // in OCP we use SCC so there is no need to define PodSecurityContext deployment.Spec.Template.Spec.SecurityContext = &corev1.PodSecurityContext{} } @@ -40,7 +50,7 @@ func (d DeploymentAPIOCP) Deploy(resources controllers.FunctionResources) client // get the current pulpcore-api common deployment definition deployment := d.DeploymentAPICommon.Deploy(resources).(*appsv1.Deployment) - defaultsForOCPDeployment(deployment, resources.Pulp) + defaultsForOCPDeployment(deployment, resources.Pulp, settings.API) // update the hash label controllers.AddHashLabel(resources, deployment) @@ -58,7 +68,7 @@ func (d DeploymentContentOCP) Deploy(resources controllers.FunctionResources) cl // get the current pulpcore-content common deployment definition deployment := d.DeploymentContentCommon.Deploy(resources).(*appsv1.Deployment) - defaultsForOCPDeployment(deployment, resources.Pulp) + defaultsForOCPDeployment(deployment, resources.Pulp, settings.CONTENT) // update the hash label controllers.AddHashLabel(resources, deployment) @@ -76,7 +86,7 @@ func (d DeploymentWorkerOCP) Deploy(resources controllers.FunctionResources) cli // get the current pulpcore-worker common deployment definition deployment := d.DeploymentWorkerCommon.Deploy(resources).(*appsv1.Deployment) - defaultsForOCPDeployment(deployment, resources.Pulp) + defaultsForOCPDeployment(deployment, resources.Pulp, settings.WORKER) // update the hash label controllers.AddHashLabel(resources, deployment) diff --git a/controllers/ocp/pod_security_context_test.go b/controllers/ocp/pod_security_context_test.go new file mode 100644 index 000000000..3945eb92c --- /dev/null +++ b/controllers/ocp/pod_security_context_test.go @@ -0,0 +1,100 @@ +package ocp + +import ( + "context" + "reflect" + "testing" + + pulpv1 "github.com/pulp/pulp-operator/apis/repo-manager.pulpproject.org/v1" + "github.com/pulp/pulp-operator/controllers" + "github.com/pulp/pulp-operator/controllers/settings" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + "sigs.k8s.io/controller-runtime/pkg/log/zap" +) + +func deployOCPComponent(t *testing.T, pulp *pulpv1.Pulp, pulpcoreType settings.PulpcoreType) *appsv1.Deployment { + t.Helper() + scheme := runtime.NewScheme() + _ = pulpv1.AddToScheme(scheme) + _ = appsv1.AddToScheme(scheme) + _ = corev1.AddToScheme(scheme) + + resources := controllers.FunctionResources{ + Context: context.TODO(), + Client: fake.NewClientBuilder().WithScheme(scheme).WithObjects(pulp).Build(), + Pulp: pulp, + Scheme: scheme, + Logger: zap.New(), + } + + switch pulpcoreType { + case settings.API: + return DeploymentAPIOCP{}.Deploy(resources).(*appsv1.Deployment) + case settings.CONTENT: + return DeploymentContentOCP{}.Deploy(resources).(*appsv1.Deployment) + default: + return DeploymentWorkerOCP{}.Deploy(resources).(*appsv1.Deployment) + } +} + +// TestOCPPodSecurityContextDefault verifies that, as before this change, OCP +// deployments get an empty SecurityContext when the CR sets no override. +func TestOCPPodSecurityContextDefault(t *testing.T) { + pulp := &pulpv1.Pulp{ + ObjectMeta: metav1.ObjectMeta{Name: "test-pulp", Namespace: "test-namespace"}, + Spec: pulpv1.PulpSpec{ + FileStorageClass: "standard", + Api: pulpv1.Api{Replicas: 1}, + Content: pulpv1.Content{Replicas: 1}, + Worker: pulpv1.Worker{Replicas: 1}, + }, + } + + for _, pulpcoreType := range []settings.PulpcoreType{settings.API, settings.CONTENT, settings.WORKER} { + t.Run(string(pulpcoreType), func(t *testing.T) { + dep := deployOCPComponent(t, pulp, pulpcoreType) + sc := dep.Spec.Template.Spec.SecurityContext + if sc == nil || !reflect.DeepEqual(*sc, corev1.PodSecurityContext{}) { + t.Errorf("SecurityContext = %v, want empty PodSecurityContext{}", sc) + } + }) + } +} + +// TestOCPPodSecurityContextOverride verifies that an explicit CR override is +// honored on OCP instead of being silently discarded by the empty-context +// default (this was a real bug caught by review before this test existed). +func TestOCPPodSecurityContextOverride(t *testing.T) { + runAsUser := int64(101) + fsGroup := int64(101) + override := &corev1.PodSecurityContext{RunAsUser: &runAsUser, FSGroup: &fsGroup} + + pulp := &pulpv1.Pulp{ + ObjectMeta: metav1.ObjectMeta{Name: "test-pulp", Namespace: "test-namespace"}, + Spec: pulpv1.PulpSpec{ + FileStorageClass: "standard", + Api: pulpv1.Api{Replicas: 1, PodSecurityContext: override}, + Content: pulpv1.Content{Replicas: 1}, // no override: must still get the empty OCP default + Worker: pulpv1.Worker{Replicas: 1}, + }, + } + + apiDep := deployOCPComponent(t, pulp, settings.API) + apiSC := apiDep.Spec.Template.Spec.SecurityContext + if apiSC == nil || apiSC.RunAsUser == nil || *apiSC.RunAsUser != 101 { + t.Errorf("api RunAsUser = %v, want 101 (override must survive the OCP defaulting pass)", apiSC) + } + if apiSC == nil || apiSC.FSGroup == nil || *apiSC.FSGroup != 101 { + t.Errorf("api FSGroup = %v, want 101", apiSC) + } + + contentDep := deployOCPComponent(t, pulp, settings.CONTENT) + contentSC := contentDep.Spec.Template.Spec.SecurityContext + if contentSC == nil || !reflect.DeepEqual(*contentSC, corev1.PodSecurityContext{}) { + t.Errorf("content SecurityContext = %v, want empty PodSecurityContext{} (no override set)", contentSC) + } +} diff --git a/controllers/pod_security_context_test.go b/controllers/pod_security_context_test.go new file mode 100644 index 000000000..f1d0e2ec3 --- /dev/null +++ b/controllers/pod_security_context_test.go @@ -0,0 +1,115 @@ +package controllers + +import ( + "context" + "testing" + + pulpv1 "github.com/pulp/pulp-operator/apis/repo-manager.pulpproject.org/v1" + "github.com/pulp/pulp-operator/controllers/settings" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + "sigs.k8s.io/controller-runtime/pkg/log/zap" +) + +// deploySecurityContextComponent runs the real Deployment generator of a pulpcore component +func deploySecurityContextComponent(t *testing.T, pulp *pulpv1.Pulp, pulpcoreType settings.PulpcoreType) *appsv1.Deployment { + t.Helper() + scheme := runtime.NewScheme() + _ = pulpv1.AddToScheme(scheme) + _ = appsv1.AddToScheme(scheme) + _ = corev1.AddToScheme(scheme) + + resources := FunctionResources{ + Context: context.TODO(), + Client: fake.NewClientBuilder().WithScheme(scheme).WithObjects(pulp).Build(), + Pulp: pulp, + Scheme: scheme, + Logger: zap.New(), + } + + switch pulpcoreType { + case settings.API: + return DeploymentAPICommon{}.Deploy(resources).(*appsv1.Deployment) + case settings.CONTENT: + return DeploymentContentCommon{}.Deploy(resources).(*appsv1.Deployment) + default: + return DeploymentWorkerCommon{}.Deploy(resources).(*appsv1.Deployment) + } +} + +// TestPodSecurityContextDefault verifies that with no override set, every +// component keeps the historical hardcoded runAsUser/fsGroup 700. +func TestPodSecurityContextDefault(t *testing.T) { + pulp := &pulpv1.Pulp{ + ObjectMeta: metav1.ObjectMeta{Name: "test-pulp", Namespace: "test-namespace"}, + Spec: pulpv1.PulpSpec{ + FileStorageClass: "standard", + Api: pulpv1.Api{Replicas: 1}, + Content: pulpv1.Content{Replicas: 1}, + Worker: pulpv1.Worker{Replicas: 1}, + }, + } + + for _, pulpcoreType := range []settings.PulpcoreType{settings.API, settings.CONTENT, settings.WORKER} { + t.Run(string(pulpcoreType), func(t *testing.T) { + dep := deploySecurityContextComponent(t, pulp, pulpcoreType) + sc := dep.Spec.Template.Spec.SecurityContext + if sc == nil || sc.RunAsUser == nil || *sc.RunAsUser != 700 { + t.Errorf("RunAsUser = %v, want 700", sc) + } + if sc == nil || sc.FSGroup == nil || *sc.FSGroup != 700 { + t.Errorf("FSGroup = %v, want 700", sc) + } + }) + } +} + +// TestPodSecurityContextOverride verifies that setting pod_security_context per +// component overrides the default and does not leak to other components. +func TestPodSecurityContextOverride(t *testing.T) { + apiUser := int64(101) + apiGroup := int64(101) + workerGroup := int64(2000) + apiOverride := &corev1.PodSecurityContext{RunAsUser: &apiUser, FSGroup: &apiGroup} + workerOverride := &corev1.PodSecurityContext{FSGroup: &workerGroup} + + pulp := &pulpv1.Pulp{ + ObjectMeta: metav1.ObjectMeta{Name: "test-pulp", Namespace: "test-namespace"}, + Spec: pulpv1.PulpSpec{ + FileStorageClass: "standard", + Api: pulpv1.Api{Replicas: 1, PodSecurityContext: apiOverride}, + Content: pulpv1.Content{Replicas: 1}, // no override: must keep default + Worker: pulpv1.Worker{Replicas: 1, PodSecurityContext: workerOverride}, + }, + } + + apiDep := deploySecurityContextComponent(t, pulp, settings.API) + apiSC := apiDep.Spec.Template.Spec.SecurityContext + if apiSC == nil || apiSC.RunAsUser == nil || *apiSC.RunAsUser != 101 { + t.Errorf("api RunAsUser = %v, want 101", apiSC) + } + if apiSC == nil || apiSC.FSGroup == nil || *apiSC.FSGroup != 101 { + t.Errorf("api FSGroup = %v, want 101", apiSC) + } + + contentDep := deploySecurityContextComponent(t, pulp, settings.CONTENT) + contentSC := contentDep.Spec.Template.Spec.SecurityContext + if contentSC == nil || contentSC.RunAsUser == nil || *contentSC.RunAsUser != 700 { + t.Errorf("content RunAsUser leaked override or lost default: %v", contentSC) + } + if contentSC == nil || contentSC.FSGroup == nil || *contentSC.FSGroup != 700 { + t.Errorf("content FSGroup leaked override or lost default: %v", contentSC) + } + + workerDep := deploySecurityContextComponent(t, pulp, settings.WORKER) + workerSC := workerDep.Spec.Template.Spec.SecurityContext + if workerSC == nil || workerSC.RunAsUser != nil { + t.Errorf("worker RunAsUser = %v, want nil (override only set FSGroup)", workerSC) + } + if workerSC == nil || workerSC.FSGroup == nil || *workerSC.FSGroup != 2000 { + t.Errorf("worker FSGroup = %v, want 2000", workerSC) + } +} diff --git a/controllers/repo_manager/README.md b/controllers/repo_manager/README.md index 04ad93ace..1670f0c91 100644 --- a/controllers/repo_manager/README.md +++ b/controllers/repo_manager/README.md @@ -30,6 +30,7 @@ Api defines desired state of pulpcore-api resources | hpa | HPA defines the Horizontal Pod Autoscaler configuration for the pulp-api deployment | *[HPA](#hpa) | false | | affinity | Affinity is a group of affinity scheduling rules. | *corev1.Affinity | false | | node_selector | NodeSelector for the Pulp pods. | map[string]string | false | +| pod_security_context | PodSecurityContext defines the pod-level security attributes for the pulp-api pods. If unset, runAsUser and fsGroup default to 700. | *corev1.PodSecurityContext | false | | tolerations | Node tolerations for the Pulp pods. | []corev1.Toleration | false | | topology_spread_constraints | Topology rule(s) for the pods. | []corev1.TopologySpreadConstraint | false | | gunicorn_timeout | The timeout for the gunicorn process. Default: 90 | int | false | @@ -82,6 +83,7 @@ Content defines desired state of pulpcore-content resources | resource_requirements | Resource requirements for the pulp-content container | corev1.ResourceRequirements | false | | affinity | Affinity is a group of affinity scheduling rules. | *corev1.Affinity | false | | node_selector | NodeSelector for the Pulp pods. | map[string]string | false | +| pod_security_context | PodSecurityContext defines the pod-level security attributes for the pulp-content pods. If unset, runAsUser and fsGroup default to 700. | *corev1.PodSecurityContext | false | | tolerations | Node tolerations for the Pulp pods. | []corev1.Toleration | false | | topology_spread_constraints | Topology rule(s) for the pods. | []corev1.TopologySpreadConstraint | false | | gunicorn_timeout | The timeout for the gunicorn process. Default: 90 | int | false | @@ -324,6 +326,7 @@ Web defines desired state of pulpcore-web (reverse-proxy) resources | readinessProbe | Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. | *corev1.Probe | false | | livenessProbe | Periodic probe of container liveness. Container will be restarted if the probe fails. | *corev1.Probe | false | | node_selector | NodeSelector for the Web pods. | map[string]string | false | +| pod_security_context | PodSecurityContext defines the pod-level security attributes for the pulp-web pods. If unset, runAsUser and fsGroup default to 700. | *corev1.PodSecurityContext | false | | pdb | PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods | *policy.PodDisruptionBudgetSpec | false | | strategy | The deployment strategy to use to replace existing pods with new ones. | appsv1.DeploymentStrategy | false | | service_annotations | Annotations for the service | map[string]string | false | @@ -345,6 +348,7 @@ Worker defines desired state of pulpcore-worker resources | resource_requirements | Resource requirements for the pulp-api container | corev1.ResourceRequirements | false | | affinity | Affinity is a group of affinity scheduling rules. | *corev1.Affinity | false | | node_selector | NodeSelector for the Pulp pods. | map[string]string | false | +| pod_security_context | PodSecurityContext defines the pod-level security attributes for the pulp-worker pods. If unset, runAsUser and fsGroup default to 700. | *corev1.PodSecurityContext | false | | tolerations | Node tolerations for the Pulp pods. | []corev1.Toleration | false | | topology_spread_constraints | Topology rule(s) for the pods. | []corev1.TopologySpreadConstraint | false | | readinessProbe | Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. | *corev1.Probe | false | diff --git a/controllers/repo_manager/pod_security_context_crd_test.go b/controllers/repo_manager/pod_security_context_crd_test.go new file mode 100644 index 000000000..2d494bcf2 --- /dev/null +++ b/controllers/repo_manager/pod_security_context_crd_test.go @@ -0,0 +1,80 @@ +package repo_manager_test + +import ( + "context" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + pulpv1 "github.com/pulp/pulp-operator/apis/repo-manager.pulpproject.org/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/types" +) + +// CRD schema validation of pod_security_context +var _ = Describe("Pulp CRD validation of pod_security_context", func() { + ctx := context.Background() + components := []string{"api", "content", "worker", "web"} + + newPulp := func(name string, spec map[string]any) *unstructured.Unstructured { + return &unstructured.Unstructured{Object: map[string]any{ + "apiVersion": pulpv1.GroupVersion.String(), + "kind": "Pulp", + "metadata": map[string]any{"name": name, "namespace": "default"}, + "spec": spec, + }} + } + + create := func(name string, spec map[string]any) error { + u := newPulp(name, spec) + err := k8sClient.Create(ctx, u) + if err == nil { + DeferCleanup(func() { _ = k8sClient.Delete(ctx, u) }) + } + return err + } + + for _, component := range components { + component := component + + It("accepts and preserves pod_security_context in "+component, func() { + name := "psc-valid-" + component + Expect(create(name, map[string]any{ + component: map[string]any{ + "pod_security_context": map[string]any{ + "runAsUser": int64(101), + "fsGroup": int64(101), + "runAsGroup": int64(101), + }, + }, + })).To(Succeed()) + + // the field must not be pruned by the API server + got := &unstructured.Unstructured{} + got.SetGroupVersionKind(pulpv1.GroupVersion.WithKind("Pulp")) + Expect(k8sClient.Get(ctx, types.NamespacedName{Name: name, Namespace: "default"}, got)).To(Succeed()) + + runAsUser, _, _ := unstructured.NestedInt64(got.Object, "spec", component, "pod_security_context", "runAsUser") + Expect(runAsUser).To(Equal(int64(101))) + + fsGroup, _, _ := unstructured.NestedInt64(got.Object, "spec", component, "pod_security_context", "fsGroup") + Expect(fsGroup).To(Equal(int64(101))) + + runAsGroup, _, _ := unstructured.NestedInt64(got.Object, "spec", component, "pod_security_context", "runAsGroup") + Expect(runAsGroup).To(Equal(int64(101))) + }) + } + + It("accepts a CR with no pod_security_context override (default behavior unchanged)", func() { + name := "psc-unset" + Expect(create(name, map[string]any{ + "api": map[string]any{"replicas": int64(1)}, + })).To(Succeed()) + + got := &unstructured.Unstructured{} + got.SetGroupVersionKind(pulpv1.GroupVersion.WithKind("Pulp")) + Expect(k8sClient.Get(ctx, types.NamespacedName{Name: name, Namespace: "default"}, got)).To(Succeed()) + + _, found, _ := unstructured.NestedMap(got.Object, "spec", "api", "pod_security_context") + Expect(found).To(BeFalse()) + }) +}) diff --git a/controllers/repo_manager/pod_security_context_test.go b/controllers/repo_manager/pod_security_context_test.go new file mode 100644 index 000000000..d3055980b --- /dev/null +++ b/controllers/repo_manager/pod_security_context_test.go @@ -0,0 +1,77 @@ +package repo_manager + +import ( + "context" + "testing" + + pulpv1 "github.com/pulp/pulp-operator/apis/repo-manager.pulpproject.org/v1" + "github.com/pulp/pulp-operator/controllers" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + "sigs.k8s.io/controller-runtime/pkg/log/zap" +) + +func deployWeb(t *testing.T, pulp *pulpv1.Pulp) *corev1.PodSecurityContext { + t.Helper() + scheme := runtime.NewScheme() + _ = pulpv1.AddToScheme(scheme) + _ = corev1.AddToScheme(scheme) + + r := &RepoManagerReconciler{ + Client: fake.NewClientBuilder().WithScheme(scheme).WithObjects(pulp).Build(), + Scheme: scheme, + } + funcResources := controllers.FunctionResources{ + Context: context.TODO(), + Client: r.Client, + Pulp: pulp, + Scheme: scheme, + Logger: zap.New(), + } + + dep := r.deploymentForPulpWeb(pulp, funcResources) + return dep.Spec.Template.Spec.SecurityContext +} + +// TestPodSecurityContextWebDefault verifies pulp-web keeps the historical +// hardcoded runAsUser/fsGroup 700 when no override is set. +func TestPodSecurityContextWebDefault(t *testing.T) { + pulp := &pulpv1.Pulp{ + ObjectMeta: metav1.ObjectMeta{Name: "test-pulp", Namespace: "test-namespace"}, + Spec: pulpv1.PulpSpec{Web: pulpv1.Web{Replicas: 1}}, + } + + sc := deployWeb(t, pulp) + if sc == nil || sc.RunAsUser == nil || *sc.RunAsUser != 700 { + t.Errorf("RunAsUser = %v, want 700", sc) + } + if sc == nil || sc.FSGroup == nil || *sc.FSGroup != 700 { + t.Errorf("FSGroup = %v, want 700", sc) + } +} + +// TestPodSecurityContextWebOverride verifies pod_security_context overrides +// the hardcoded default for pulp-web. +func TestPodSecurityContextWebOverride(t *testing.T) { + runAsUser := int64(101) + fsGroup := int64(101) + pulp := &pulpv1.Pulp{ + ObjectMeta: metav1.ObjectMeta{Name: "test-pulp", Namespace: "test-namespace"}, + Spec: pulpv1.PulpSpec{ + Web: pulpv1.Web{ + Replicas: 1, + PodSecurityContext: &corev1.PodSecurityContext{RunAsUser: &runAsUser, FSGroup: &fsGroup}, + }, + }, + } + + sc := deployWeb(t, pulp) + if sc == nil || sc.RunAsUser == nil || *sc.RunAsUser != 101 { + t.Errorf("RunAsUser = %v, want 101", sc) + } + if sc == nil || sc.FSGroup == nil || *sc.FSGroup != 101 { + t.Errorf("FSGroup = %v, want 101", sc) + } +} diff --git a/controllers/repo_manager/web.go b/controllers/repo_manager/web.go index 1c866ef87..3d6a1c99c 100644 --- a/controllers/repo_manager/web.go +++ b/controllers/repo_manager/web.go @@ -199,7 +199,9 @@ func (r *RepoManagerReconciler) deploymentForPulpWeb(m *pulpv1.Pulp, funcResourc runAsUser := int64(700) fsGroup := int64(700) podSecurityContext := &corev1.PodSecurityContext{RunAsUser: &runAsUser, FSGroup: &fsGroup} - if isOpenShift, _ := controllers.IsOpenShift(); isOpenShift { + if m.Spec.Web.PodSecurityContext != nil { + podSecurityContext = m.Spec.Web.PodSecurityContext + } else if isOpenShift, _ := controllers.IsOpenShift(); isOpenShift { podSecurityContext = &corev1.PodSecurityContext{} } diff --git a/docs/admin/guides/configurations/pod_security_context.md b/docs/admin/guides/configurations/pod_security_context.md new file mode 100644 index 000000000..6e55030b3 --- /dev/null +++ b/docs/admin/guides/configurations/pod_security_context.md @@ -0,0 +1,68 @@ +# Overriding the pod security context + +By default, Pulp Operator runs the `api`, `content`, `worker`, and `web` pods with +a hardcoded `runAsUser: 700` and `fsGroup: 700` [pod security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/). + +This works for the images Pulp Operator ships by default, but a custom Pulp image +that does not use UID/GID 700 for its `pulp` user needs a different value. The +`pod_security_context` field lets you override the pod-level security attributes +per component instead of patching the operator. + +!!! INFO + + `pod_security_context` only applies to the `api`, `content`, `worker` and `web` + pods. It has no effect on: + + * the `database` and `cache` (Redis) pods; + * the `AdminPasswordJob`, `MigrationJob` and `SigningJob` jobs; + * `PulpBackup` and `PulpRestore` pods. + + These keep their own hardcoded values. + +!!! INFO + + Setting `pod_security_context` **replaces** the whole default, it does not merge + field by field. `pod_security_context: {fsGroup: 2000}` drops `runAsUser: 700` + entirely rather than keeping it alongside the new `fsGroup`. Set every attribute + you need explicitly. + +To override the pod security context configure the following fields: + +* `api.pod_security_context` [**optional**] overrides the pod-level `securityContext` for api pods. If not defined, `runAsUser` and `fsGroup` default to `700`. +* `content.pod_security_context` [**optional**] overrides the pod-level `securityContext` for content pods. If not defined, `runAsUser` and `fsGroup` default to `700`. +* `worker.pod_security_context` [**optional**] overrides the pod-level `securityContext` for worker pods. If not defined, `runAsUser` and `fsGroup` default to `700`. +* `web.pod_security_context` [**optional**] overrides the pod-level `securityContext` for web pods. If not defined, `runAsUser` and `fsGroup` default to `700` (or left unset on OpenShift, where the platform assigns a UID/GID automatically). + +On OpenShift, api, content and worker pods also get an empty `securityContext` by +default (the platform's SCC assigns a UID/GID automatically) unless +`pod_security_context` is set, in which case your override is used instead. + +Example of CR configuration to run a custom image under UID/GID 101: +```yaml +spec: + api: + pod_security_context: + runAsUser: 101 + fsGroup: 101 + content: + pod_security_context: + runAsUser: 101 + fsGroup: 101 + worker: + pod_security_context: + runAsUser: 101 + fsGroup: 101 + web: + pod_security_context: + runAsUser: 101 + fsGroup: 101 +``` + +The field accepts any Kubernetes [`PodSecurityContext`](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#podsecuritycontext-v1-core) +attribute (for example `runAsGroup` or `fsGroupChangePolicy`), not just `runAsUser` and `fsGroup`. + +!!! INFO + + Some container runtimes reject `runAsGroup` when `runAsUser` is not also + set, with an error like `user group "N" is specified without user`. + Set both together if you need to override the group. diff --git a/mkdocs.yml b/mkdocs.yml index 010cfeddf..32692452a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -60,6 +60,7 @@ nav: - LDAP Authentication: configuring/ldap.md - Metadata Signing: configuring/metadata_signing.md - Custom Environment Variables: configuring/custom_env_vars.md + - Pod Security Context: configuring/pod_security_context.md - Backup and Restore: - Overview: backup_and_restore/overview.md - Configuring and Running: backup_and_restore/config_running.md