Linux Foundation CKS Exam (page: 2)
Linux Foundation Certified Kubernetes Security Specialist
Updated on: 31-Mar-2026

Viewing Page 2 of 11

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

  1. See Explanation section for answer.

Answer(s): A

Explanation:

FROM debian:latest
MAINTAINER k@bogotobogo.com

# 1 - RUN
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq apt-utils RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq htop RUN apt-get clean

# 2 - CMD
#CMD ["htop"]
#CMD ["ls", "-l"]

# 3 - WORKDIR and ENV
WORKDIR /root
ENV DZ version1
$ docker image build -t bogodevops/demo .
Sending build context to Docker daemon 3.072kB
Step 1/7 : FROM debian:latest
---> be2868bebaba
Step 2/7 : MAINTAINER k@bogotobogo.com
---> Using cache
---> e2eef476b3fd
Step 3/7 : RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq apt-utils

---> Using cache
---> 32fd044c1356
Step 4/7 : RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq htop ---> Using cache
---> 0a5b514a209e
Step 5/7 : RUN apt-get clean
---> Using cache
---> 5d1578a47c17
Step 6/7 : WORKDIR /root
---> Using cache
---> 6b1c70e87675
Step 7/7 : ENV DZ version1
---> Using cache
---> cd195168c5c7
Successfully built cd195168c5c7
Successfully tagged bogodevops/demo:latest



Create a RuntimeClass named gvisor-rc using the prepared runtime handler named runsc. Create a Pods of image Nginx in the Namespace server to run on the gVisor runtime class

  1. See Explanation section for answer.

Answer(s): A

Explanation:

Install the Runtime Class for gVisor
{ # Step 1: Install a RuntimeClass cat <<EOF | kubectl apply -f -
apiVersion: node.k8s.io/v1beta1
kind: RuntimeClass metadata:
name: gvisor handler: runsc
EOF

}

Create a Pod with the gVisor Runtime Class
{ # Step 2: Create a pod cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod metadata:
name: nginx-gvisor spec:
runtimeClassName: gvisor containers:
- name: nginx image: nginx
EOF
}

Verify that the Pod is running
{ # Step 3: Get the pod kubectl get pod nginx-gvisor -o wide
}





Task

Create a NetworkPolicy named pod-access to restrict access to Pod users-service running in namespace dev-team.

Only allow the following Pods to connect to Pod users-service:

Pods in the namespace qa

Pods with label environment: testing, in any namespace



  1. See Explanation section for answer.

Answer(s): A

Explanation:









A container image scanner is set up on the cluster.
Given an incomplete configuration in the directory
/etc/kubernetes/confcontrol and a functional container image scanner with HTTPS endpoint https://test-server.local.8081/image_policy

1. Enable the admission plugin.
2. Validate the control configuration and change it to implicit deny.

Finally, test the configuration by deploying the pod having the image tag as latest.

  1. See Explanation section for answer.

Answer(s): A

Explanation:

ssh-add ~/.ssh/tempprivate eval "$(ssh-agent -s)"
cd contrib/terraform/aws vi terraform.tfvars terraform init terraform apply -var-file=credentials.tfvars ansible-playbook -i ./inventory/hosts ./cluster.yml -e ansible_ssh_user=core -e bootstrap_os=coreos - b --become-user=root --flush-cache -e ansible_user=core



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'

Edit the prepared manifest file to include the AppArmor profile.
apiVersion: v1

kind: Pod metadata:
name: apparmor-pod spec:
containers:
- name: apparmor-pod image: nginx

Finally, apply the manifests files and create the Pod specified on it.

Verify: Try to make a file inside the directory which is restricted.

  1. See Explanation section for answer.

Answer(s): A

Explanation:







Viewing Page 2 of 11



Share your comments for Linux Foundation CKS exam with other users:

Anonymous 7/16/2023 11:05:00 AM

upload cks exam questions
Anonymous