Limited-Time Offer: Enjoy 50% Savings! Coupon code: 50OFF Use it at checkout
Skip to content

Free Linux Foundation Certified Kubernetes Security Specialist CKS Exam Questions

Last updated: · 11 practice questions with answers and explanations

Page: 1 / 7 Total 64 questions

Want more questions? Get Premium Access.

Question 1

New Single answer

Topic: Cluster Setup

Skill tested: Configure namespace-scoped NetworkPolicy ingress and egress restrictions for application pods.

A payment service runs in namespace `payments` and listens on TCP port 8443. It must accept connections only from pods carrying `role=frontend` in namespace `web`, and it must initiate connections only to pods labelled `role=ledger` in its own namespace on TCP 9443. The cluster's CNI enforces Kubernetes NetworkPolicy, and the payment pods have no other required network dependencies. Which policy correctly enforces both restrictions?

Correct Answer: C. A policy selecting the payment pods with `Ingress` and `Egress` policy types; ingress allows the `role=frontend` pod selector and `kubernetes.io/metadata.name=web` namespace selector on port 8443, while egress allows the `role=ledger` pod selector in namespace `payments` on port 9443.
Explanation:

A NetworkPolicy selects the pods whose traffic it governs. Selecting payment pods and declaring both `Ingress` and `Egress` makes them isolated in both directions; the specified peer selectors and ports then allow only the required flows. A namespace selector and pod selector in the same peer entry are conjunctive, so both the frontend label and `web` namespace are required. An ingress-only policy does not restrict egress, selecting frontend pods governs the wrong workloads, and broad namespace-only rules permit more peers than the scenario allows.

Question 2

New Multiple answers

Topic: Cluster Setup

Skill tested: Select TLS Ingress configuration and verification steps for secure external service access.

An organization exposes an internal reporting service through an Ingress controller. The service must be reachable only over HTTPS for `reports.example.test`, use a certificate stored in the Ingress namespace, and avoid exposing the backend Service directly outside the cluster. After deployment, operators must verify that the intended node endpoints are reachable for controller health checks. The controller is already installed and configured to listen on the node network. Which TWO actions meet these requirements? Select TWO.

Correct Answer: A. Create a TLS Secret in the Ingress namespace and reference its name under the Ingress `spec.tls` entry for `reports.example.test`.; C. Configure an Ingress rule for the hostname and backend Service, with a TLS host and same-namespace Secret reference; verify the controller's configured node endpoint using a request to that endpoint with the correct Host and TLS SNI.
Explanation:

An Ingress TLS entry associates the hostname with a TLS Secret in the same namespace as the Ingress; the rule routes matching host traffic to the backend Service without directly publishing that Service. Testing the configured node endpoint with the expected hostname exercises the controller's routing and TLS selection. A standalone NodePort bypasses the intended Ingress exposure, cross-namespace Secret references are not valid Ingress TLS references, and NetworkPolicy neither terminates TLS nor makes a ClusterIP externally reachable.

Question 3

New Single answer

Topic: Cluster Hardening

Skill tested: Create least-privilege Kubernetes RBAC roles and bindings for namespaced API access.

A release automation identity must update Deployments and read Pods in namespace `staging`. It must not create or delete Secrets, modify Services, or perform these operations in other namespaces. The identity authenticates as a dedicated ServiceAccount. Which RBAC design best satisfies the requirement?

Correct Answer: B. Create a Role in `staging` granting `get`, `list`, and `watch` on Pods and `get`, `patch`, and `update` on Deployments, then bind it to the ServiceAccount with a RoleBinding in `staging`.
Explanation:

A namespaced Role and RoleBinding limit the grant to `staging`; the resource-specific verbs avoid granting access to Secrets or Services. The listed read verbs support normal Pod inspection, while the selected Deployment verbs support updates without granting create or delete. The built-in `edit` role includes broader permissions and the ClusterRoleBinding makes its scope cluster-wide. A ClusterRoleBinding is unnecessarily broad, while wildcard permissions in a Role still grant excessive access within `staging`.

Question 4

New Multiple answers

Topic: Cluster Hardening

Skill tested: Remove unnecessary default ServiceAccount permissions and prevent automatic credential mounting.

A team discovered that application pods use the namespace's `default` ServiceAccount and receive API credentials even though they never call the Kubernetes API. A separate controller in the same namespace requires narrowly scoped API access. The security team wants both unnecessary default access removed and controller access retained. Which TWO actions are appropriate? Select TWO.

Correct Answer: B. Give the controller a dedicated ServiceAccount, bind it to a least-privilege Role with a RoleBinding in its namespace, and configure only that controller to use it.; C. Set `automountServiceAccountToken: false` on the `default` ServiceAccount, and ensure application pods do not override that setting.
Explanation:

Disabling token automount for the default ServiceAccount prevents Kubernetes from automatically mounting an API credential into workloads using it, unless a pod explicitly overrides the setting. Workloads that need the API should use a dedicated ServiceAccount and a scoped RoleBinding, separating their permissions from unrelated applications. Kubernetes maintains the default ServiceAccount, so deleting it is not a reliable control. Granting `cluster-admin` is excessive, and removing all bindings would break the controller without addressing token automount.

Question 5

New Single answer

Topic: System Hardening

Skill tested: Apply and validate a seccomp profile that limits unnecessary system calls for a container.

A node-hardening review found that a batch worker runs as a non-root user but inherits an unconfined seccomp configuration. The worker is a standard Linux application that does not need custom system calls, and the team wants a low-maintenance control applied specifically to this Deployment. Which change is most appropriate?

Correct Answer: D. Set the pod-level `securityContext.seccompProfile.type` to `RuntimeDefault`, then verify the resulting pod specification and runtime behavior.
Explanation:

The pod-level seccomp profile type `RuntimeDefault` asks the container runtime to apply its default seccomp profile to the pod's containers, which is appropriate for a conventional application that does not need a custom profile. Verifying the deployed pod confirms that the workload specification took effect. Non-root execution is useful but does not itself constrain system calls. Disabling privilege escalation is a distinct control and does not install seccomp; adding `SYS_ADMIN` increases privilege rather than reducing attack surface.

Question 6

New Single answer

Topic: Minimize Microservice Vulnerabilities

Skill tested: Set restrictive pod security contexts for non-root, read-only container execution.

A stateless API Deployment must run without root privileges and must not modify its container image filesystem. The application writes temporary data only under `/tmp`; its image supports an arbitrary non-root UID and has no need for Linux capabilities. The cluster enforces Pod Security Admission at the restricted level. Which security-context design best meets the requirements without relying on a fixed image UID?

Correct Answer: B. Set `runAsNonRoot: true`, `allowPrivilegeEscalation: false`, drop all capabilities, set `readOnlyRootFilesystem: true`, and mount an `emptyDir` at `/tmp`.
Explanation:

This design enforces non-root execution without assuming a particular numeric UID, prevents privilege escalation, removes unnecessary capabilities, and makes the image filesystem read-only. An `emptyDir` mounted at `/tmp` provides the one writable location the application needs. Running as UID 0 violates the non-root requirement, while privileged mode defeats the intended isolation. A fixed UID is unnecessary because the image supports arbitrary UIDs, and leaving the root filesystem writable contradicts the stated constraint.

Question 7

New Multiple answers

Topic: Minimize Microservice Vulnerabilities

Skill tested: Configure Kubernetes Secret volumes and environment references for application credentials.

A database password currently appears in a Deployment's environment variable value, and the team requires removal of the plaintext value from the workload manifest. The application can read either environment variables or a file. Operators want Kubernetes to inject the password from a Secret and avoid placing credential data directly in the Deployment specification. Which TWO changes meet the requirement? Select TWO.

Correct Answer: B. Create a Kubernetes Secret containing the password and reference its key through `secretKeyRef` in the container's environment definition.; D. Create a Kubernetes Secret and mount it as a volume, then configure the application to read the password from the mounted file.
Explanation:

Both `secretKeyRef` and a Secret volume let the Pod consume a Secret key without embedding the credential value in the Deployment manifest. A file-based mount is often preferable when the application supports it; the Secret volume content is projected into the container, subject to Kubernetes Secret handling and cluster configuration. Base64 is encoding, not protection, and leaves the value in the manifest. ConfigMaps are not intended for confidential credentials, and Pod annotations would expose the value rather than securely source it.

Question 8

New Single answer

Topic: Supply Chain Security

Skill tested: Enforce trusted container image sources with Kubernetes admission policy.

A platform team must prevent newly created workloads from using images outside `registry.corp.example`. Workloads are deployed in several namespaces by different teams, and the policy must be enforced at admission rather than by convention. The cluster does not currently have a third-party policy engine. Which approach is the most appropriate using Kubernetes-native controls?

Correct Answer: A. Configure a built-in ValidatingAdmissionPolicy with a validation that inspects Pod container and init-container image fields and rejects references outside the approved registry, then bind it at the required scope.
Explanation:

A ValidatingAdmissionPolicy can inspect submitted Pod specifications and reject disallowed image references when its policy and binding are configured for the relevant scope. The validation must cover all applicable container fields, including init containers, and should define the approved registry matching rules carefully. NetworkPolicy controls network traffic, not whether a manifest is admitted. `imagePullPolicy` controls pull behavior, not registry authorization, and runtime mirror configuration does not inherently reject every unapproved image reference.

Question 9

New Single answer

Topic: Supply Chain Security

Skill tested: Run Dockerfile static analysis and remediate insecure build instructions.

Before promoting a service image, a release engineer must perform static analysis of its Dockerfile. The team has already selected a scanner that reports insecure instructions and misconfigurations, and policy requires that build promotion stop when the scan reports a blocking finding. The image does not need to be running for this check. Which workflow best meets the requirement?

Correct Answer: A. Run the selected static Dockerfile scanner against the source Dockerfile in CI, configure the pipeline to fail on policy-defined blocking findings, and remediate or formally review findings before promotion.
Explanation:

Dockerfile static analysis operates on the build instructions and can detect risky configuration before an image is built or run. Integrating the scanner into CI and failing promotion on blocking findings makes the control effective in the release process. Executing analysis inside the workload is unnecessary and inspects the wrong context; runtime process inspection does not establish the safety of the Dockerfile. Signing establishes an integrity and provenance-related assertion about an artifact, not that its build instructions are secure.

Question 10

New Multiple answers

Topic: Monitoring, Logging and Runtime Security

Skill tested: Correlate Kubernetes audit events and runtime evidence during pod compromise investigation.

An on-call engineer sees a compromised application container making unexpected outbound connections and modifying files in a mounted directory. The cluster has Kubernetes API audit logging and node-level runtime monitoring. The team must establish which identity created or changed the Pod, determine what the container did on the node, and contain the incident without destroying evidence. Which THREE actions are most appropriate? Select THREE.

Correct Answer: A. Use runtime alerts and node-level process, file, and network telemetry to correlate the container activity with the affected Pod and host.; B. Preserve relevant logs and runtime evidence, then isolate the affected workload or node using the incident-response controls available to the cluster before proceeding with forensic collection.; C. Query audit events for the Pod's namespace and name, correlate timestamps and user or ServiceAccount identity, and review create, update, or exec-related API events.
Explanation:

Audit records help identify API actors and changes to the Pod, while runtime monitoring provides evidence of process execution, file activity, and network behavior that API auditing does not capture. Correlating timestamps, workload identity, and host telemetry supports a more complete investigation. Evidence should be preserved while the affected workload or node is contained according to the response plan. Deleting resources immediately may destroy useful state, and Kubernetes audit logs do not record container system calls or filesystem operations.

Question 11

New Single answer

Topic: Monitoring, Logging and Runtime Security

Skill tested: Use Kubernetes audit policy levels to capture security-relevant request details.

A security operations team is tuning API audit logging after an incident. It needs request bodies for changes to Secrets and RBAC objects, but wants to avoid recording response bodies and routine read-only traffic for those resources. For other resource types, existing audit requirements remain unchanged. Which policy rule design best balances investigation value and data minimization?

Correct Answer: C. Add higher-priority matching rules for Secrets and RBAC resources at `Request`, followed by the existing rules for other resources; ensure the specific rules precede broader matches.
Explanation:

The `Request` audit level records request metadata and the request body but not the response body, matching the requirement to capture submitted changes without collecting response payloads. Specific rules should precede broader rules because audit policy evaluation uses the first matching rule; existing rules can then continue to govern other resource types. `RequestResponse` collects more data than requested, `Metadata` omits request bodies, and a broad global rule may override the intended resource-specific handling or discard existing coverage.