Security constraints
Pod security policies can be used to define under what conditions workloads can run. With Portainer we achieve this by leveraging Open Policy Agent via OPA Gatekeeper.
Policies are configured on a per-environment basis. To enable and configure security policies, from the menu select a Kubernetes environment, then expand Cluster and click Security constraints.
This is advanced functionality and should be applied with caution. If a deployment attempts to create a pod that does not meet defined security constraints it may not be immediately obvious that the constraint is the reason for provision failure.
![](https://docs.portainer.io/~gitbook/image?url=https%3A%2F%2F3124200557-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FSnGaCQxx2ODexfYYKEez%252Fuploads%252FuAPam1ylDgJ3rMqkTT2E%252F2.20-kubernetes-cluster-security.gif%3Falt%3Dmedia%26token%3Dc8a7697c-7478-480b-989a-6df1c4599403&width=768&dpr=4&quality=100&sign=ed870629&sv=1)
Toggle on Enable pod security constraints to enable the functionality, then toggle on the features you require and configure them as needed.
Policies are based on the Kubernetes security policy reference - for more detail on each option check the Kubernetes documentation.
Field/Option | Overview |
---|---|
Restrict running privileged containers | Set whether any container in a pod can enable privileged mode. |
Restrict host namespace | Controls whether the pod containers can share the process ID namespace and host IPC namespace. |
Restrict host networking ports | Define a range of ports that can be used by pods, on a per-network basis. |
Restrict volume types | Define the types of volumes that may be used. Examples of volume types are |
Restrict host filesystem paths | Define the host paths that are allowed when using hostPath volumes. |
Restrict drivers | Define the FlexVolume drivers that can be used. |
Require read-only root filesystem | Specify that containers must run with a read-only root filesystem. |
Restrict User and group ids | Controls which user ID or group ID the containers are run with or which group IDs get added. For users, specify |
Restrict escalation to root privileges | Controls the user privileges and prevents files from enabling extra capabilities. |
Restrict Linux capabilities | Define the capabilities available to the pod. Set allowed capabilities to specify those capabilities that a container can use, and set Required drop capabilities to specify which privileges must be dropped from containers. |
Restrict SELinux security context | Controls the SELinux context of the container. You can specify the level, role, type and user. |
Restrict Proc Mount types | Defines the type of |
Restrict AppArmor profiles | Controls the AppArmor profile used by containers. Refer to the AppArmor documentation for more details. |
Restrict seccomp profiles | Controls the seccomp profile used by containers or pods. |
Restrict sysctl profiles | Controls the sysctl profile used by containers. Specify the sysctls to forbid from use by pods. |
Once you have completed your configuration, click Save settings to apply your changes.
Last updated