Challenge, Easy,  on  Kubernetes

Secure a Deployment with Security Context and Capabilities

Scenario

The security team has identified that the joker-deployment in namespace joker needs hardening. The deployment is currently running with default security settings, which pose potential security risks.

The manifest file for the existing Deployment can be found at /home/laborant/joker-deployment.yaml.


🎯 Task

Modify the existing Deployment named joker-deployment running in namespace joker so that its containers:

  1. Run with user ID 3000
  2. Privilege escalation is forbidden
  3. Add the following Linux capabilities:
    • NET_BIND_SERVICE
    • NET_RAW
    • NET_ADMIN
  4. Check the logs of the deployment that show user ID 3000.

Modified the YAML file at /home/laborant/joker-deployment.yaml


Hint

All security settings should be applied at the container level under spec.template.spec.containers[].securityContext:

  • runAsUser: 3000
  • allowPrivilegeEscalation: false
  • capabilities with add list

💡 Test Cases