Class PodSecurityContext
- java.lang.Object
-
- io.fabric8.kubernetes.api.model.PodSecurityContext
-
- All Implemented Interfaces:
io.fabric8.kubernetes.api.builder.Editable<PodSecurityContextBuilder>
,KubernetesResource
,Serializable
@Generated("io.fabric8.kubernetes.schema.generator.model.ModelGenerator") public class PodSecurityContext extends Object implements io.fabric8.kubernetes.api.builder.Editable<PodSecurityContextBuilder>, KubernetesResource
PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PodSecurityContext()
No args constructor for use in serializationPodSecurityContext(AppArmorProfile appArmorProfile, Long fsGroup, String fsGroupChangePolicy, Long runAsGroup, Boolean runAsNonRoot, Long runAsUser, String seLinuxChangePolicy, SELinuxOptions seLinuxOptions, SeccompProfile seccompProfile, List<Long> supplementalGroups, String supplementalGroupsPolicy, List<Sysctl> sysctls, WindowsSecurityContextOptions windowsOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PodSecurityContextBuilder
edit()
Map<String,Object>
getAdditionalProperties()
AppArmorProfile
getAppArmorProfile()
PodSecurityContext holds pod-level security attributes and common container settings.Long
getFsGroup()
A special supplemental group that applies to all containers in a pod.String
getFsGroupChangePolicy()
fsGroupChangePolicy defines behavior of changing ownership and permission of the volume before being exposed inside Pod.Long
getRunAsGroup()
The GID to run the entrypoint of the container process.Boolean
getRunAsNonRoot()
Indicates that the container must run as a non-root user.Long
getRunAsUser()
The UID to run the entrypoint of the container process.SeccompProfile
getSeccompProfile()
PodSecurityContext holds pod-level security attributes and common container settings.String
getSeLinuxChangePolicy()
seLinuxChangePolicy defines how the container's SELinux label is applied to all volumes used by the Pod.SELinuxOptions
getSeLinuxOptions()
PodSecurityContext holds pod-level security attributes and common container settings.List<Long>
getSupplementalGroups()
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).String
getSupplementalGroupsPolicy()
Defines how supplemental groups of the first container processes are calculated.List<Sysctl>
getSysctls()
Sysctls hold a list of namespaced sysctls used for the pod.WindowsSecurityContextOptions
getWindowsOptions()
PodSecurityContext holds pod-level security attributes and common container settings.void
setAdditionalProperties(Map<String,Object> additionalProperties)
void
setAdditionalProperty(String name, Object value)
void
setAppArmorProfile(AppArmorProfile appArmorProfile)
PodSecurityContext holds pod-level security attributes and common container settings.void
setFsGroup(Long fsGroup)
A special supplemental group that applies to all containers in a pod.void
setFsGroupChangePolicy(String fsGroupChangePolicy)
fsGroupChangePolicy defines behavior of changing ownership and permission of the volume before being exposed inside Pod.void
setRunAsGroup(Long runAsGroup)
The GID to run the entrypoint of the container process.void
setRunAsNonRoot(Boolean runAsNonRoot)
Indicates that the container must run as a non-root user.void
setRunAsUser(Long runAsUser)
The UID to run the entrypoint of the container process.void
setSeccompProfile(SeccompProfile seccompProfile)
PodSecurityContext holds pod-level security attributes and common container settings.void
setSeLinuxChangePolicy(String seLinuxChangePolicy)
seLinuxChangePolicy defines how the container's SELinux label is applied to all volumes used by the Pod.void
setSeLinuxOptions(SELinuxOptions seLinuxOptions)
PodSecurityContext holds pod-level security attributes and common container settings.void
setSupplementalGroups(List<Long> supplementalGroups)
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).void
setSupplementalGroupsPolicy(String supplementalGroupsPolicy)
Defines how supplemental groups of the first container processes are calculated.void
setSysctls(List<Sysctl> sysctls)
Sysctls hold a list of namespaced sysctls used for the pod.void
setWindowsOptions(WindowsSecurityContextOptions windowsOptions)
PodSecurityContext holds pod-level security attributes and common container settings.PodSecurityContextBuilder
toBuilder()
-
-
-
Constructor Detail
-
PodSecurityContext
public PodSecurityContext()
No args constructor for use in serialization
-
PodSecurityContext
public PodSecurityContext(AppArmorProfile appArmorProfile, Long fsGroup, String fsGroupChangePolicy, Long runAsGroup, Boolean runAsNonRoot, Long runAsUser, String seLinuxChangePolicy, SELinuxOptions seLinuxOptions, SeccompProfile seccompProfile, List<Long> supplementalGroups, String supplementalGroupsPolicy, List<Sysctl> sysctls, WindowsSecurityContextOptions windowsOptions)
-
-
Method Detail
-
getAppArmorProfile
public AppArmorProfile getAppArmorProfile()
PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.
-
setAppArmorProfile
public void setAppArmorProfile(AppArmorProfile appArmorProfile)
PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.
-
getFsGroup
public Long getFsGroup()
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.
-
setFsGroup
public void setFsGroup(Long fsGroup)
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.
-
getFsGroupChangePolicy
public String getFsGroupChangePolicy()
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.
-
setFsGroupChangePolicy
public void setFsGroupChangePolicy(String fsGroupChangePolicy)
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.
-
getRunAsGroup
public Long getRunAsGroup()
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.
-
setRunAsGroup
public void setRunAsGroup(Long runAsGroup)
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.
-
getRunAsNonRoot
public Boolean getRunAsNonRoot()
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.
-
setRunAsNonRoot
public void setRunAsNonRoot(Boolean runAsNonRoot)
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.
-
getRunAsUser
public Long getRunAsUser()
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.
-
setRunAsUser
public void setRunAsUser(Long runAsUser)
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.
-
getSeLinuxChangePolicy
public String getSeLinuxChangePolicy()
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.
-
setSeLinuxChangePolicy
public void setSeLinuxChangePolicy(String seLinuxChangePolicy)
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.
-
getSeLinuxOptions
public SELinuxOptions getSeLinuxOptions()
PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.
-
setSeLinuxOptions
public void setSeLinuxOptions(SELinuxOptions seLinuxOptions)
PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.
-
getSeccompProfile
public SeccompProfile getSeccompProfile()
PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.
-
setSeccompProfile
public void setSeccompProfile(SeccompProfile seccompProfile)
PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.
-
getSupplementalGroups
public List<Long> getSupplementalGroups()
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.
-
setSupplementalGroups
public void setSupplementalGroups(List<Long> supplementalGroups)
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.
-
getSupplementalGroupsPolicy
public String getSupplementalGroupsPolicy()
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.
-
setSupplementalGroupsPolicy
public void setSupplementalGroupsPolicy(String supplementalGroupsPolicy)
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.
-
getSysctls
public List<Sysctl> getSysctls()
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.
-
setSysctls
public void setSysctls(List<Sysctl> sysctls)
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.
-
getWindowsOptions
public WindowsSecurityContextOptions getWindowsOptions()
PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.
-
setWindowsOptions
public void setWindowsOptions(WindowsSecurityContextOptions windowsOptions)
PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.
-
edit
public PodSecurityContextBuilder edit()
- Specified by:
edit
in interfaceio.fabric8.kubernetes.api.builder.Editable<PodSecurityContextBuilder>
-
toBuilder
public PodSecurityContextBuilder toBuilder()
-
-