nerdexam
Linux_Foundation

CKS · Question #50

Your organization's security policy includes: ServiceAccounts must not automount API credentials ServiceAccount names must end in "-sa" The Pod specified in the manifest file…

This question tests the ability to create a Kubernetes ServiceAccount with security hardening (no automounted credentials), correctly reference it in a Pod manifest, and perform namespace hygiene by removing unused ServiceAccounts.

Submitted by rania.sa· May 4, 2026Minimize Microservice Vulnerabilities

Question

Your organization's security policy includes:
  • ServiceAccounts must not automount API credentials
  • ServiceAccount names must end in "-sa"
The Pod specified in the manifest file /home/candidate/KSCH00301/pod-manifest.yaml fails to schedule because of an incorrectly specified ServiceAccount. Complete the following tasks:
  1. Create a new ServiceAccount named frontend-sa in the existing namespace qa. Ensure the ServiceAccount does not automount API credentials.
  2. Using the manifest file at /home/candidate/KSCH00301/pod-manifest.yaml, create the Pod.
  3. Finally, clean up any unused ServiceAccounts in namespace qa.

Explanation

This question tests the ability to create a Kubernetes ServiceAccount with security hardening (no automounted credentials), correctly reference it in a Pod manifest, and perform namespace hygiene by removing unused ServiceAccounts.

Approach. First, create the ServiceAccount with automountServiceAccountToken: false - either via kubectl create serviceaccount frontend-sa -n qa then patching, or declaratively with a YAML manifest that sets automountServiceAccountToken: false at the ServiceAccount level. Next, inspect /home/candidate/KSCH00301/pod-manifest.yaml to confirm the spec.serviceAccountName field references frontend-sa (and that spec.automountServiceAccountToken is not overriding to true), then apply it with kubectl apply -f. Finally, run kubectl get serviceaccounts -n qa to list all SAs, cross-reference them against running pods with kubectl get pods -n qa -o jsonpath='{.items[*].spec.serviceAccountName}', and kubectl delete serviceaccount <name> -n qa for any SA not referenced by a pod - skipping the default SA and the newly created frontend-sa.

Concept tested. Kubernetes ServiceAccount security hardening (automountServiceAccountToken), namespace-scoped resource management, Pod manifest authoring with correct ServiceAccount binding, and ServiceAccount lifecycle cleanup

Reference. https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#opt-out-of-api-credential-automounting

Topics

#ServiceAccounts#Security Policy#API Access Control#Least Privilege

Community Discussion

No community discussion yet for this question.

Full CKS Practice