Skip to content

Instantly share code, notes, and snippets.

@prasanthkothuri
Last active January 12, 2021 19:59
Show Gist options
  • Save prasanthkothuri/f98337c062e5d059fe801040cdacf11d to your computer and use it in GitHub Desktop.
Save prasanthkothuri/f98337c062e5d059fe801040cdacf11d to your computer and use it in GitHub Desktop.

SELinux provides a user, a role, a type, and a level (ls -Z). This information is used to make access control decisions. On DAC systems, access is controlled based on Linux user and group IDs. SELinux policy rules are checked after DAC rules. SELinux policy rules are not used if DAC rules deny access first.

For container to mount the host volume if SELinux is enabled on the host

  1. Kubernetes
  • Enable PodSecurityPolicy in Admission Controller link

  • Create PodSecurityPolicy with SeLinux rule link

    seLinux:
    rule: RunAsAny
    
  • Apply the newly created PodSecurityPolicy to a user link

  • Assign SELinux labels to the container in your deployment link

    securityContext:
    seLinuxOptions:
      level: "s0:c123,c456"
    
  1. Docker
  • as below 'z' at the end is important
    -v {source}:{destination}:z
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment