avionix.kube.policy¶
Contains various policy based classes
-
class
avionix.kube.policy.AllowedCSIDriver(name)¶ - Parameters
name (
str) – Name is the registered name of the CSI driver
-
class
avionix.kube.policy.AllowedFlexVolume(driver)¶ - Parameters
driver (
str) – driver is the name of the Flexvolume driver.
-
class
avionix.kube.policy.AllowedHostPath(path_prefix, read_only=None)¶ - Parameters
path_prefix (
str) – pathPrefix is the path prefix that the host volume must match. It does not support *. Trailing slashes are trimmed when validating the path prefix with a host path. Examples: /foo would allow /foo, /foo/ and /foo/bar /foo would not allow /food or /etc/fooread_only (
Optional[bool]) – when set to true, will allow host volumes matching the pathPrefix only if all volume mounts are readOnly.
-
class
avionix.kube.policy.Eviction(metadata, delete_options, api_version=None)¶ - Parameters
metadata (
ObjectMeta) – ObjectMeta describes the pod that is being evicted.delete_options (
DeleteOptions) – DeleteOptions may be providedapi_version (
Optional[str]) – APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa
-
class
avionix.kube.policy.FSGroupStrategyOptions(rule, ranges=None)¶ - Parameters
rule (
str) – rule is the strategy that will dictate what FSGroup is used in the SecurityContext.ranges (
Optional[List[IDRange]]) – ranges are the allowed ranges of fs groups. If you would like to force a single fs group then supply a single range with the same start and end. Required for MustRunAs.
-
class
avionix.kube.policy.HostPortRange(max, min)¶ - Parameters
max (
int) – max is the end of the range, inclusive.min (
int) – min is the start of the range, inclusive.
-
class
avionix.kube.policy.IDRange(min, max)¶ - Parameters
min (
int) – min is the start of the range, inclusive.max (
int) – max is the end of the range, inclusive.
-
class
avionix.kube.policy.PodDisruptionBudget(metadata, spec, api_version=None)¶ - Parameters
metadata (
ObjectMeta) – Nonespec (
PodDisruptionBudgetSpec) – Specification of the desired behavior of the PodDisruptionBudget.api_version (
Optional[str]) – APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa
-
class
avionix.kube.policy.PodDisruptionBudgetSpec(max_unavailable=None, min_available=None, selector=None)¶ - Parameters
max_unavailable (
Union[int,str,None]) – An eviction is allowed if at most “maxUnavailable” pods selected by “selector” are unavailable after the eviction, i.e. even in absence of the evicted pod. For example, one can prevent all voluntary evictions by specifying 0. This is a mutually exclusive setting with “minAvailable”.min_available (
Union[int,str,None]) – An eviction is allowed if at least “minAvailable” pods selected by “selector” will still be available after the eviction, i.e. even in the absence of the evicted pod. So for example you can prevent all voluntary evictions by specifying “100%”.selector (
Optional[LabelSelector]) – Label query over pods whose evictions are managed by the disruption budget.
-
class
avionix.kube.policy.PodSecurityPolicy(metadata, spec, api_version=None)¶ - Parameters
metadata (
ObjectMeta) – Standard object’s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata # noqaspec (
PodSecurityPolicySpec) – spec defines the policy enforced.api_version (
Optional[str]) – APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa
-
class
avionix.kube.policy.PodSecurityPolicySpec(fs_group, run_as_user, se_linux, supplemental_groups, allowed_csidrivers=None, allowed_capabilities=None, allowed_flex_volumes=None, allowed_host_paths=None, allowed_proc_mount_types=None, default_add_capabilities=None, default_allow_privilege_escalation=None, host_ipc=None, host_pid=None, host_ports=None, privileged=None, read_only_root_filesystem=None, required_drop_capabilities=None, run_as_group=None, runtime_class=None, allow_privilege_escalation=None, allowed_unsafe_sysctls=None, forbidden_sysctls=None, host_network=None, volumes=None)¶ - Parameters
fs_group (
FSGroupStrategyOptions) – fsGroup is the strategy that will dictate what fs group is used by the SecurityContext.run_as_user (
RunAsUserStrategyOptions) – runAsUser is the strategy that will dictate the allowable RunAsUser values that may be set.se_linux (
SELinuxStrategyOptions) – seLinux is the strategy that will dictate the allowable labels that may be set.allowed_csidrivers (
Optional[List[AllowedCSIDriver]]) – AllowedCSIDrivers is a whitelist of inline CSI drivers that must be explicitly set to be embedded within a pod spec. An empty value indicates that any CSI driver can be used for inline ephemeral volumes. This is an alpha field, and is only honored if the API server enables the CSIInlineVolume feature gate.allowed_capabilities (
Optional[List[str]]) – allowedCapabilities is a list of capabilities that can be requested to add to the container. Capabilities in this field may be added at the pod author’s discretion. You must not list a capability in both allowedCapabilities and requiredDropCapabilities.allowed_flex_volumes (
Optional[List[AllowedFlexVolume]]) – allowedFlexVolumes is a whitelist of allowed Flexvolumes. Empty or nil indicates that all Flexvolumes may be used. This parameter is effective only when the usage of the Flexvolumes is allowed in the “volumes” field.allowed_host_paths (
Optional[List[AllowedHostPath]]) – allowedHostPaths is a white list of allowed host paths. Empty indicates that all host paths may be used.allowed_proc_mount_types (
Optional[List[str]]) – AllowedProcMountTypes is a whitelist of allowed ProcMountTypes. Empty or nil indicates that only the DefaultProcMountType may be used. This requires the ProcMountType feature flag to be enabled.default_add_capabilities (
Optional[List[str]]) – defaultAddCapabilities is the default set of capabilities that will be added to the container unless the pod spec specifically drops the capability. You may not list a capability in both defaultAddCapabilities and requiredDropCapabilities. Capabilities added here are implicitly allowed, and need not be included in the allowedCapabilities list.default_allow_privilege_escalation (
Optional[bool]) – defaultAllowPrivilegeEscalation controls the default setting for whether a process can gain more privileges than its parent process.host_ipc (
Optional[bool]) – hostIPC determines if the policy allows the use of HostIPC in the pod spec.host_pid (
Optional[bool]) – hostPID determines if the policy allows the use of HostPID in the pod spec.host_ports (
Optional[List[HostPortRange]]) – hostPorts determines which host port ranges are allowed to be exposed.privileged (
Optional[bool]) – privileged determines if a pod can request to be run as privileged.read_only_root_filesystem (
Optional[bool]) – readOnlyRootFilesystem when set to true will force containers to run with a read only root file system. If the container specifically requests to run with a non-read only root file system the PSP should deny the pod. If set to false the container may run with a read only root file system if it wishes but it will not be forced to.required_drop_capabilities (
Optional[List[str]]) – requiredDropCapabilities are the capabilities that will be dropped from the container. These are required to be dropped and cannot be added.run_as_group (
Optional[RunAsGroupStrategyOptions]) – RunAsGroup is the strategy that will dictate the allowable RunAsGroup values that may be set. If this field is omitted, the pod’s RunAsGroup can take any value. This field requires the RunAsGroup feature gate to be enabled.runtime_class (
Optional[RuntimeClassStrategyOptions]) – runtimeClass is the strategy that will dictate the allowable RuntimeClasses for a pod. If this field is omitted, the pod’s runtimeClassName field is unrestricted. Enforcement of this field depends on the RuntimeClass feature gate being enabled.supplemental_groups (
SupplementalGroupsStrategyOptions) – supplementalGroups is the strategy that will dictate what supplemental groups are used by the SecurityContext.allow_privilege_escalation (
Optional[bool]) – allowPrivilegeEscalation determines if a pod can request to allow privilege escalation. If unspecified, defaults to true.allowed_unsafe_sysctls (
Optional[List[str]]) – allowedUnsafeSysctls is a list of explicitly allowed unsafe sysctls, defaults to none. Each entry is either a plain sysctl name or ends in “*” in which case it is considered as a prefix of allowed sysctls. Single * means all unsafe sysctls are allowed. Kubelet has to whitelist all allowed unsafe sysctls explicitly to avoid rejection. Examples: e.g. “foo/” allows “foo/bar”, “foo/baz”, etc. e.g. “foo.” allows “foo.bar”, “foo.baz”, etc.forbidden_sysctls (
Optional[List[str]]) – forbiddenSysctls is a list of explicitly forbidden sysctls, defaults to none. Each entry is either a plain sysctl name or ends in “*” in which case it is considered as a prefix of forbidden sysctls. Single * means all sysctls are forbidden. Examples: e.g. “foo/” forbids “foo/bar”, “foo/baz”, etc. e.g. “foo.” forbids “foo.bar”, “foo.baz”, etc.host_network (
Optional[bool]) – hostNetwork determines if the policy allows the use of HostNetwork in the pod spec.volumes (
Optional[List[str]]) – volumes is a white list of allowed volume plugins. Empty indicates that no volumes may be used. To allow all volumes you may use ‘*’.
-
class
avionix.kube.policy.RunAsGroupStrategyOptions(rule, ranges=None)¶ - Parameters
rule (
str) – rule is the strategy that will dictate the allowable RunAsGroup values that may be set.ranges (
Optional[List[IDRange]]) – ranges are the allowed ranges of gids that may be used. If you would like to force a single gid then supply a single range with the same start and end. Required for MustRunAs.
-
class
avionix.kube.policy.RunAsUserStrategyOptions(rule, ranges=None)¶ - Parameters
rule (
str) – rule is the strategy that will dictate the allowable RunAsUser values that may be set.ranges (
Optional[List[IDRange]]) – ranges are the allowed ranges of uids that may be used. If you would like to force a single uid then supply a single range with the same start and end. Required for MustRunAs.
-
class
avionix.kube.policy.RuntimeClassStrategyOptions(allowed_runtime_class_names, default_runtime_class_name=None)¶ - Parameters
allowed_runtime_class_names (
List[str]) – allowedRuntimeClassNames is a whitelist of RuntimeClass names that may be specified on a pod. A value of “*” means that any RuntimeClass name is allowed, and must be the only item in the list. An empty list requires the RuntimeClassName field to be unset.default_runtime_class_name (
Optional[str]) – defaultRuntimeClassName is the default RuntimeClassName to set on the pod. The default MUST be allowed by the allowedRuntimeClassNames list. A value of nil does not mutate the Pod.
-
class
avionix.kube.policy.SELinuxStrategyOptions(rule, se_linux_options=None)¶ - Parameters
rule (
str) – rule is the strategy that will dictate the allowable labels that may be set.se_linux_options (
Optional[SELinuxOptions]) – seLinuxOptions required to run as; required for MustRunAs More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
-
class
avionix.kube.policy.SupplementalGroupsStrategyOptions(rule, ranges=None)¶ - Parameters
rule (
str) – rule is the strategy that will dictate what supplemental groups is used in the SecurityContext.ranges (
Optional[List[IDRange]]) – ranges are the allowed ranges of supplemental groups. If you would like to force a single supplemental group then supply a single range with the same start and end. Required for MustRunAs.