K8s - Security Context

 
A security context allows you to set access control for Pods, as well as containers and volumes in Pods, when applicable. 

Examples of access controls that can be set with security contexts include:
  • The user ID and group IDs of the first process running in a container
  • The group ID of volumes
  • If a container's root file system is read-only
  • Security-Enhanced Linux (SELinux) options
  • The privileged status of containers, which allows the container to do almost everything root can do on the host if enabled
  • Whether or not privilege escalation, where child processes can have more privileges than their parent, is allowed
Creating a pod with no security context:


We are listing the logical device files under the container /dev folder. But it does not list the entire /dev files which are visible under host.

Let's create another pod with privileged security as TRUE.


Now you can see the /dev files which are available under the host from the container. 

This could be a major security breach and shows the importance of carefully considering if you should ever use a privileged container.

Let's create another pod which runs the process custom PID instead of root and setting root filesystem access READ ONLY.



Comments

Popular posts from this blog

SRE/DevOps Syllabus

AWS Code Commit - CI/CD Series Part 1

Docker - Preventing IP overlapping