Question 1

Analyze and edit the given Dockerfile
FROM ubuntu:latest
RUN apt-get update -y
RUN apt-install nginx -y
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
USER ROOT
Fixing two instructions present in the file being prominent security best practice issues Analyze and edit the deployment manifest file apiVersion: v1 kind: Pod metadata:
name: security-context-demo-2
spec:
securityContext:
runAsUser: 1000
containers:
- name: sec-ctx-demo-2
image: gcr.io/google-samples/node-hello:1.0
securityContext:
runAsUser: 0
privileged: True
allowPrivilegeEscalation: false
Fixing two fields present in the file being prominent security best practice issues Don't add or remove configuration settings; only modify the existing configuration settings Whenever you need an unprivileged user for any of the tasks, use user test-user with the user id 5487
  • Question 2

    SIMULATION
    Use the kubesec docker images to scan the given YAML manifest, edit and apply the advised changes, and passed with a score of 4 points.
    kubesec-test.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: kubesec-demo
    spec:
    containers:
    - name: kubesec-demo
    image: gcr.io/google-samples/node-hello:1.0
    securityContext:
    readOnlyRootFilesystem: true
    Hint: docker run -i kubesec/kubesec:512c5e0 scan /dev/stdin < kubesec-test.yaml
  • Question 3

    SIMULATION
    Given an existing Pod named nginx-pod running in the namespace test-system, fetch the service-account-name used and put the content in /candidate/KSC00124.txt Create a new Role named dev-test-role in the namespace test-system, which can perform update operations, on resources of type namespaces.
    Create a new RoleBinding named dev-test-role-binding, which binds the newly created Role to the Pod's ServiceAccount ( found in the Nginx pod running in namespace test-system).
  • Question 4

    SIMULATION
    a. Retrieve the content of the existing secret named default-token-xxxxx in the testing namespace.
    Store the value of the token in the token.txt
    b. Create a new secret named test-db-secret in the DB namespace with the following content:
    username: mysql
    password: password@123
    Create the Pod name test-db-pod of image nginx in the namespace db that can access test-db-secret via a volume at path /etc/mysql-credentials

    Question 5

    On the Cluster worker node, enforce the prepared AppArmor profile
    #include <tunables/global>
    profile nginx-deny flags=(attach_disconnected) {
    #include <abstractions/base>
    file,
    # Deny all file writes.
    deny /** w,
    }
    EOF'