pub struct SecurityContext {
pub capabilities: Option<Capabilities>,
pub privileged: Option<bool>,
pub se_linux_options: Option<SeLinuxOptions>,
pub windows_options: Option<WindowsSecurityContextOptions>,
pub run_as_user: Option<i64>,
pub run_as_group: Option<i64>,
pub run_as_non_root: Option<bool>,
pub read_only_root_filesystem: Option<bool>,
pub allow_privilege_escalation: Option<bool>,
pub proc_mount: Option<String>,
pub seccomp_profile: Option<SeccompProfile>,
pub app_armor_profile: Option<AppArmorProfile>,
}
Expand description
SecurityContext holds security configuration that will be applied to a container. Some fields are present in both SecurityContext and PodSecurityContext. When both are set, the values in SecurityContext take precedence.
Fields§
§capabilities: Option<Capabilities>
The capabilities to add/drop when running containers. Defaults to the default set of capabilities granted by the container runtime. Note that this field cannot be set when spec.os.name is windows. +optional
privileged: Option<bool>
Run container in privileged mode. Processes in privileged containers are essentially equivalent to root on the host. Defaults to false. Note that this field cannot be set when spec.os.name is windows. +optional
se_linux_options: Option<SeLinuxOptions>
The SELinux context to be applied to the container. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in PodSecurityContext. 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 windows. +optional
windows_options: Option<WindowsSecurityContextOptions>
The Windows specific settings applied to all containers. If unspecified, the options from the PodSecurityContext 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. +optional
run_as_user: Option<i64>
The UID to run the entrypoint of the container process. Defaults to 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. Note that this field cannot be set when spec.os.name is windows. +optional
run_as_group: Option<i64>
The GID to run the entrypoint of the container process. Uses runtime default if unset. May also be set in PodSecurityContext. 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 windows. +optional
run_as_non_root: Option<bool>
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 PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. +optional
read_only_root_filesystem: Option<bool>
Whether this container has a read-only root filesystem. Default is false. Note that this field cannot be set when spec.os.name is windows. +optional
allow_privilege_escalation: Option<bool>
AllowPrivilegeEscalation controls whether a process can gain more privileges than its parent process. This bool directly controls if the no_new_privs flag will be set on the container process. AllowPrivilegeEscalation is true always when the container is:
- run as Privileged
- has CAP_SYS_ADMIN Note that this field cannot be set when spec.os.name is windows. +optional
proc_mount: Option<String>
procMount denotes the type of proc mount to use for the containers. The default value is Default which uses the container runtime defaults for readonly paths and masked paths. This requires the ProcMountType feature flag to be enabled. Note that this field cannot be set when spec.os.name is windows. +optional
seccomp_profile: Option<SeccompProfile>
The seccomp options to use by this container. If seccomp options are provided at both the pod & container level, the container options override the pod options. Note that this field cannot be set when spec.os.name is windows. +optional
app_armor_profile: Option<AppArmorProfile>
appArmorProfile is the AppArmor options to use by this container. If set, this profile overrides the pod’s appArmorProfile. Note that this field cannot be set when spec.os.name is windows. +optional
Implementations§
Source§impl SecurityContext
impl SecurityContext
Sourcepub fn privileged(&self) -> bool
pub fn privileged(&self) -> bool
Returns the value of privileged
, or the default value if privileged
is unset.
Sourcepub fn run_as_user(&self) -> i64
pub fn run_as_user(&self) -> i64
Returns the value of run_as_user
, or the default value if run_as_user
is unset.
Sourcepub fn run_as_non_root(&self) -> bool
pub fn run_as_non_root(&self) -> bool
Returns the value of run_as_non_root
, or the default value if run_as_non_root
is unset.
Sourcepub fn read_only_root_filesystem(&self) -> bool
pub fn read_only_root_filesystem(&self) -> bool
Returns the value of read_only_root_filesystem
, or the default value if read_only_root_filesystem
is unset.
Sourcepub fn allow_privilege_escalation(&self) -> bool
pub fn allow_privilege_escalation(&self) -> bool
Returns the value of allow_privilege_escalation
, or the default value if allow_privilege_escalation
is unset.
Sourcepub fn run_as_group(&self) -> i64
pub fn run_as_group(&self) -> i64
Returns the value of run_as_group
, or the default value if run_as_group
is unset.
Sourcepub fn proc_mount(&self) -> &str
pub fn proc_mount(&self) -> &str
Returns the value of proc_mount
, or the default value if proc_mount
is unset.
Trait Implementations§
Source§impl Clone for SecurityContext
impl Clone for SecurityContext
Source§fn clone(&self) -> SecurityContext
fn clone(&self) -> SecurityContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SecurityContext
impl Debug for SecurityContext
Source§impl Default for SecurityContext
impl Default for SecurityContext
Source§impl Hash for SecurityContext
impl Hash for SecurityContext
Source§impl Message for SecurityContext
impl Message for SecurityContext
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
.