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 to verify it shows user ID 3000.

Modify the YAML file at /home/laborant/joker-deployment.yaml and apply the changes.


Hint
  • All security settings must be configured at the container level under spec.template.spec.containers[0].securityContext
  • Use runAsUser to set the user ID
  • Use allowPrivilegeEscalation to control privilege escalation
  • Use capabilities.add to add Linux capabilities as a list
  • After editing the YAML file, apply it with kubectl apply -f
  • Check Kubernetes documentation for securityContext examples if needed

Test Cases