CKAD · Domain 4 of 5 · 25% of the exam

CKAD Domain 4: Application Environment, Configuration, and Security

48 free practice questions for Application Environment, Configuration, and Security in the Certified Kubernetes Application Developer (CKAD) exam. Try each question first, then open "Show answer" for the correct option and explanation.

Application Environment, Configuration, and Security practice questions

  1. Question 1. After installing a CRD named backups.example.com, how do you list the Backup objects in the current namespace?

    1. kubectl get crd backups --items
    2. kubectl get backups
    3. kubectl describe crd --all
    4. kubectl get customresources backups
    Show answer

    Answer: B. kubectl get backups

    A CRD adds a new resource type to the API, so you use kubectl get, describe, and delete with its plural name, short name, or kind.

  2. Question 2. What does scope: Namespaced mean in a CustomResourceDefinition?

    1. The CRD can only be created in one namespace
    2. Only one namespace may use the resource type
    3. Each custom resource object lives in a namespace
    4. The controller runs a copy in every namespace
    Show answer

    Answer: C. Each custom resource object lives in a namespace

    The CRD itself is cluster-scoped. Namespaced means its objects belong to namespaces, like Pods; Cluster means they don't, like Nodes.

  3. Question 3. A custom resource is created, but no controller or operator watches its type. What happens?

    1. The API server rejects the object
    2. It's deleted after a timeout
    3. It creates Pods directly from its spec
    4. It's stored, but nothing acts on it
    Show answer

    Answer: D. It's stored, but nothing acts on it

    The API server validates and stores it in etcd. An operator's controller is what turns custom resources into real actions.

  4. Question 4. Which command lists the CustomResourceDefinitions installed in a cluster?

    1. kubectl get crd
    2. kubectl api-versions --crd
    3. kubectl get operators
    4. kubectl get apiresources --custom
    Show answer

    Answer: A. kubectl get crd

    kubectl get crd (customresourcedefinitions) lists them. kubectl api-resources shows the resource types they add.

  5. Question 5. What does a CRD's openAPIV3Schema define?

    1. The controller image that handles the resource
    2. The fields and types a custom resource can contain
    3. The RBAC rules for users of the resource
    4. The storage class used for its data
    Show answer

    Answer: B. The fields and types a custom resource can contain

    The structural schema is used for validation, pruning unknown fields, defaulting, and kubectl explain.

  6. Question 6. In what order does the API server process a request?

    1. Admission, authentication, then authorization
    2. Authorization, admission, then authentication
    3. Authentication, admission, then authorization
    4. Authentication, authorization, then admission
    Show answer

    Answer: D. Authentication, authorization, then admission

    It first identifies the caller, then checks permissions (for example RBAC), then runs admission controllers that can modify or reject the object.

  7. Question 7. Which command checks whether ServiceAccount builder in namespace ci may create Pods there?

    1. kubectl auth whoami -n ci --as=system:serviceaccount:ci:builder
    2. kubectl get serviceaccount builder -n ci --can-create=pods
    3. kubectl auth can-i create pods -n ci --as=system:serviceaccount:ci:builder
    4. kubectl auth can-i create pods -n ci [email protected]
    Show answer

    Answer: C. kubectl auth can-i create pods -n ci --as=system:serviceaccount:ci:builder

    ServiceAccounts are impersonated as system:serviceaccount:<namespace>:<name>. The answer is yes or no.

  8. Question 8. In the admission phase, in which order do mutating and validating checks run?

    1. Mutating first, then validating
    2. Validating first, then mutating
    3. Both run at the same time
    4. In the order they were registered
    Show answer

    Answer: A. Mutating first, then validating

    Mutation happens first so that validation sees the final object, including any defaults or injected sidecars.

  9. Question 9. Which namespace label makes Pod Security Admission reject Pods that break the restricted standard?

    1. pod-security.kubernetes.io/warn: restricted
    2. pod-security.kubernetes.io/enforce: restricted
    3. pod-security.kubernetes.io/audit: restricted
    4. security.kubernetes.io/policy: restricted
    Show answer

    Answer: B. pod-security.kubernetes.io/enforce: restricted

    enforce rejects violating Pods. warn only shows a warning to the user and audit only records an audit annotation.

  10. Question 10. Which Pod Security Standards level blocks known privilege escalations but allows most default Pod specs?

    1. restricted
    2. privileged
    3. baseline
    4. default
    Show answer

    Answer: C. baseline

    baseline blocks things like privileged containers and host namespaces. restricted also requires non-root, dropped capabilities, and a seccomp profile.

  11. Question 11. How should a ServiceAccount be allowed to read Secrets in its own namespace only?

    1. A ClusterRole bound by a ClusterRoleBinding
    2. A Role with get on secrets, bound by a RoleBinding
    3. A NetworkPolicy allowing access to Secrets
    4. An annotation on each Secret naming the account
    Show answer

    Answer: B. A Role with get on secrets, bound by a RoleBinding

    A Role and RoleBinding are namespaced, so the permission doesn't extend to other namespaces.

  12. Question 12. What does a ValidatingAdmissionPolicy let you write without running a webhook server?

    1. Mutations written in Rego
    2. Network rules for Pod traffic
    3. Custom scheduling filters
    4. Validation rules as CEL expressions
    Show answer

    Answer: D. Validation rules as CEL expressions

    ValidatingAdmissionPolicy evaluates CEL expressions inside the API server, with a ValidatingAdmissionPolicyBinding choosing where it applies.

  13. Question 13. A container requests cpu: 250m. How much CPU is that?

    1. 250 CPU cores
    2. A quarter of one CPU core
    3. 250 MHz of clock speed
    4. 25% of all the node's CPUs
    Show answer

    Answer: B. A quarter of one CPU core

    m means millicores: 1000m is one CPU (one core or vCPU), so 250m is 0.25.

  14. Question 14. What is the difference between 128Mi and 128M of memory?

    1. Mi is 2^20 bytes; M is 10^6 bytes
    2. They are identical units
    3. Mi is megabits; M is megabytes
    4. Mi can only be used for limits
    Show answer

    Answer: A. Mi is 2^20 bytes; M is 10^6 bytes

    Mi, Gi, and Ki are binary units; M, G, and K are decimal. 128Mi is about 134 million bytes.

  15. Question 15. A container reaches its CPU limit. What happens?

    1. It is OOMKilled and restarted
    2. The Pod is evicted from the node
    3. It is throttled, but not killed
    4. The limit is raised to match usage
    Show answer

    Answer: C. It is throttled, but not killed

    CPU is compressible, so the container gets less CPU time. Exceeding a memory limit is what gets a container killed.

  16. Question 16. Every container in a Pod sets requests equal to limits for both CPU and memory. What QoS class does the Pod get?

    1. Burstable
    2. BestEffort
    3. Critical
    4. Guaranteed
    Show answer

    Answer: D. Guaranteed

    Guaranteed Pods are the last to be evicted under node pressure. Requests below limits make the Pod Burstable.

  17. Question 17. No container in a Pod sets any requests or limits. What QoS class does it get?

    1. BestEffort, evicted first under node pressure
    2. Guaranteed, never evicted
    3. Burstable, evicted last
    4. Critical, scheduled ahead of others
    Show answer

    Answer: A. BestEffort, evicted first under node pressure

    BestEffort Pods use whatever is free, and the kubelet evicts them first when the node runs short of memory or disk.

  18. Question 18. Namespace dev has a ResourceQuota on requests.cpu. A Pod with no CPU request is created there. What happens?

    1. It's admitted with no CPU request
    2. It's rejected unless a LimitRange sets a default
    3. It's scheduled but stays Pending
    4. The quota is ignored for that Pod
    Show answer

    Answer: B. It's rejected unless a LimitRange sets a default

    With a quota on a compute resource, every new Pod must specify it. A LimitRange default request fills it in automatically.

  19. Question 19. Which LimitRange field rejects containers whose limit is above a given value?

    1. default
    2. defaultRequest
    3. max
    4. ceiling
    Show answer

    Answer: C. max

    max caps limits and min sets a floor. default and defaultRequest fill in values that containers leave out.

  20. Question 20. Which command shows how much of namespace dev's ResourceQuota is in use?

    1. kubectl top namespace dev
    2. kubectl get limitrange -n dev
    3. kubectl quota status dev
    4. kubectl describe resourcequota -n dev
    Show answer

    Answer: D. kubectl describe resourcequota -n dev

    describe shows each quota's Used and Hard values.

  21. Question 21. Which command creates a ConfigMap named app from the file app.properties?

    1. kubectl create configmap app --from-file=app.properties
    2. kubectl create configmap app --from-literal=app.properties
    3. kubectl create secret generic app --from-file=app.properties
    4. kubectl apply configmap app -f app.properties
    Show answer

    Answer: A. kubectl create configmap app --from-file=app.properties

    --from-file makes one key per file, named after the file unless you give a key=path form.

  22. Question 22. Which command creates a ConfigMap in which each KEY=value line of the file .env becomes its own key?

    1. kubectl create configmap app --from-file=.env
    2. kubectl create configmap app --from-env-file=.env
    3. kubectl create configmap app --from-literal=.env
    4. kubectl create configmap app --env=.env
    Show answer

    Answer: B. kubectl create configmap app --from-env-file=.env

    --from-env-file parses the lines. --from-file would store the whole file under a single key.

  23. Question 23. How does a container read the single key LOG_LEVEL from ConfigMap app as an environment variable?

    1. envFrom with configMapRef and a key field
    2. A volumeMount with subPath LOG_LEVEL
    3. env with valueFrom.configMapKeyRef
    4. An annotation such as configmap/LOG_LEVEL
    Show answer

    Answer: C. env with valueFrom.configMapKeyRef

    env[].valueFrom.configMapKeyRef selects one key. envFrom imports every key and can't select one.

  24. Question 24. A container gets an environment variable from a ConfigMap, and the ConfigMap is then edited. When does the container see the new value?

    1. Within about a minute
    2. Immediately, through the kubelet
    3. Never, even after a restart
    4. Only after the container is restarted
    Show answer

    Answer: D. Only after the container is restarted

    Environment variables are set when the container starts. Mounted ConfigMap volumes, without subPath, are updated in place.

  25. Question 25. A Pod references a ConfigMap that may not exist yet. How can the Pod start anyway?

    1. Set optional: true on the reference
    2. Set required: false on the Pod
    3. Name a fallback ConfigMap in the spec
    4. Set imagePullPolicy: Never
    Show answer

    Answer: A. Set optional: true on the reference

    Without optional: true, the container won't start until the ConfigMap or key exists.

  26. Question 26. What does immutable: true do on a ConfigMap?

    1. Encrypts its data at rest with the cluster key
    2. Blocks changes to its data and cuts API server watch load
    3. Stops anyone, including admins, from deleting it
    4. Copies it into every namespace automatically
    Show answer

    Answer: B. Blocks changes to its data and cuts API server watch load

    An immutable ConfigMap can't be edited, only deleted and recreated. The kubelet stops watching it, which helps large clusters.

  27. Question 27. What is the maximum size of the data in one ConfigMap?

    1. 64 KiB
    2. 16 MiB
    3. 1 MiB
    4. No limit
    Show answer

    Answer: C. 1 MiB

    ConfigMaps and Secrets are capped at 1 MiB. Larger data belongs in a volume or an external store.

  28. Question 28. A ConfigMap is mounted as a volume. Which field sets the file name a particular key is written to?

    1. mountPath on the key
    2. fileName in the ConfigMap
    3. subPathExpr on the volume
    4. items, with key and path
    Show answer

    Answer: D. items, with key and path

    items lists the keys to project and the relative path for each; keys not listed are left out.

  29. Question 29. Which command creates a TLS Secret from cert.pem and key.pem?

    1. kubectl create secret generic web-tls --tls=cert.pem,key.pem
    2. kubectl create secret tls web-tls --cert=cert.pem --key=key.pem
    3. kubectl create certificate web-tls --cert=cert.pem --key=key.pem
    4. kubectl create secret ssl web-tls --from-file=cert.pem
    Show answer

    Answer: B. kubectl create secret tls web-tls --cert=cert.pem --key=key.pem

    This creates a kubernetes.io/tls Secret with the keys tls.crt and tls.key.

  30. Question 30. How does a Pod pull its image from a private registry?

    1. Mount the registry Secret at /root/.docker
    2. Set imagePullPolicy: Private
    3. Reference a docker-registry Secret in imagePullSecrets
    4. Put the password in the image name
    Show answer

    Answer: C. Reference a docker-registry Secret in imagePullSecrets

    imagePullSecrets can be set on the Pod or attached to its ServiceAccount so every Pod using it gets them.

  31. Question 31. Which command creates a Secret holding registry credentials for image pulls?

    1. kubectl create secret registry regcred --server=...
    2. kubectl create imagepullsecret regcred --server=...
    3. kubectl create secret generic regcred --type=image
    4. kubectl create secret docker-registry regcred --docker-server=...
    Show answer

    Answer: D. kubectl create secret docker-registry regcred --docker-server=...

    docker-registry creates a kubernetes.io/dockerconfigjson Secret from --docker-server, --docker-username, and --docker-password.

  32. Question 32. In a Secret manifest, which field accepts plain-text values that are encoded for you?

    1. stringData
    2. data
    3. plainData
    4. textData
    Show answer

    Answer: A. stringData

    stringData is write-only convenience: the values are merged into data as base64 when stored.

  33. Question 33. Why is the base64 encoding in a Secret not a security control?

    1. Base64 can't store binary data
    2. Anyone who can read the Secret can decode it
    3. Kubernetes strips the encoding on read
    4. Only the kubelet can decode it
    Show answer

    Answer: B. Anyone who can read the Secret can decode it

    Base64 is an encoding, not encryption. Protect Secrets with RBAC, encryption at rest, and care about who can create Pods that mount them.

  34. Question 34. What protects Secret data in etcd from someone who gets a copy of the database files?

    1. Setting type: Opaque on the Secret
    2. Marking the Secret immutable
    3. Encryption at rest configured on the API server
    4. Using stringData instead of data
    Show answer

    Answer: C. Encryption at rest configured on the API server

    An EncryptionConfiguration (for example with a KMS provider) makes the API server encrypt Secrets before writing them to etcd.

  35. Question 35. A Secret is mounted as a volume. Which field sets the permissions of its files, such as 0400?

    1. fsGroup on the container
    2. readOnly on the volumeMount
    3. chmod in the Secret's data
    4. defaultMode on the secret volume
    Show answer

    Answer: D. defaultMode on the secret volume

    defaultMode sets the mode for every file; items[].mode overrides it for single keys.

  36. Question 36. Which securityContext setting applies the container runtime's default seccomp profile?

    1. seccompProfile type: RuntimeDefault
    2. seccompProfile type: Unconfined
    3. appArmorProfile type: Default
    4. privileged: false
    Show answer

    Answer: A. seccompProfile type: RuntimeDefault

    RuntimeDefault blocks many rarely needed syscalls. The restricted Pod Security Standard requires RuntimeDefault or Localhost.

  37. Question 37. Which ServiceAccount does a Pod use if its spec doesn't name one?

    1. admin in the Pod's namespace
    2. default in the Pod's namespace
    3. default in kube-system
    4. The account of whoever created the Pod
    Show answer

    Answer: B. default in the Pod's namespace

    Every namespace gets a ServiceAccount named default, which Pods use unless serviceAccountName is set.

  38. Question 38. Which Pod field makes the Pod run as ServiceAccount reporter?

    1. serviceAccount.user: reporter
    2. securityContext.serviceAccount: reporter
    3. serviceAccountName: reporter
    4. metadata.owner: reporter
    Show answer

    Answer: C. serviceAccountName: reporter

    spec.serviceAccountName selects the account. It must exist in the same namespace as the Pod.

  39. Question 39. Where is the ServiceAccount token mounted in a container by default?

    1. /etc/kubernetes/pki/serviceaccount/token
    2. /run/secrets/k8s.io/service-token
    3. /var/lib/kubelet/serviceaccount/token
    4. /var/run/secrets/kubernetes.io/serviceaccount
    Show answer

    Answer: D. /var/run/secrets/kubernetes.io/serviceaccount

    The directory holds token, ca.crt, and namespace. The token is short-lived and refreshed by the kubelet.

  40. Question 40. A Pod never calls the Kubernetes API. How do you stop a token being mounted into it?

    1. Set automountServiceAccountToken: false
    2. Delete the namespace's default ServiceAccount
    3. Set serviceAccountName: none
    4. Set readOnlyRootFilesystem: true
    Show answer

    Answer: A. Set automountServiceAccountToken: false

    It can be set on the ServiceAccount or the Pod; the Pod's setting wins. This removes a credential an attacker could use.

  41. Question 41. Which command issues a short-lived token for ServiceAccount ci-bot?

    1. kubectl get secret ci-bot-token
    2. kubectl create token ci-bot
    3. kubectl create sa ci-bot --token
    4. kubectl auth token ci-bot
    Show answer

    Answer: B. kubectl create token ci-bot

    kubectl create token uses the TokenRequest API. Add --duration to change the lifetime. Long-lived token Secrets are no longer created automatically.

  42. Question 42. Can you change the ServiceAccount of a running Pod?

    1. Yes, by editing the token file inside it
    2. Yes, by editing serviceAccountName in place
    3. No; change the template so new Pods replace it
    4. Only if the Pod has the BestEffort QoS class
    Show answer

    Answer: C. No; change the template so new Pods replace it

    serviceAccountName is immutable on a Pod. Change the Deployment's template (for example with kubectl set serviceaccount) so new Pods use the new account.

  43. Question 43. Which securityContext setting makes the kubelet refuse to start a container that would run as UID 0?

    1. runAsUser: 0
    2. privileged: false
    3. allowPrivilegeEscalation: false
    4. runAsNonRoot: true
    Show answer

    Answer: D. runAsNonRoot: true

    With runAsNonRoot: true, the kubelet checks the effective UID and fails the container with CreateContainerConfigError if it's root.

  44. Question 44. Which setting stops a process gaining more privileges than its parent, for example through setuid binaries?

    1. allowPrivilegeEscalation: false
    2. runAsNonRoot: true
    3. readOnlyRootFilesystem: true
    4. capabilities: {add: []}
    Show answer

    Answer: A. allowPrivilegeEscalation: false

    It sets the no_new_privs flag on the process. It's always true when the container is privileged or has CAP_SYS_ADMIN.

  45. Question 45. An app running as a non-root user must bind to port 80. Which change grants the least privilege?

    1. Set privileged: true
    2. Add only the NET_BIND_SERVICE capability
    3. Run as UID 0 with all capabilities
    4. Add the SYS_ADMIN capability
    Show answer

    Answer: B. Add only the NET_BIND_SERVICE capability

    NET_BIND_SERVICE allows binding to ports below 1024. A common pattern is to drop ALL and add back only what's needed.

  46. Question 46. runAsUser is 1000 in the Pod's securityContext and 2000 in one container's securityContext. Which UID does that container run as?

    1. 1000
    2. 0
    3. 2000
    4. The Pod fails validation
    Show answer

    Answer: C. 2000

    Container-level securityContext fields override the same fields set at Pod level.

  47. Question 47. Which Pod securityContext field sets the group owner of mounted volumes so non-root containers can write to them?

    1. runAsGroup
    2. volumeOwner
    3. supplementalGroups
    4. fsGroup
    Show answer

    Answer: D. fsGroup

    For volumes that support ownership management, the kubelet changes their group to fsGroup and adds that group to the containers' processes.

  48. Question 48. Which setting makes a container's root filesystem read-only, with writable paths supplied through volumes?

    1. readOnlyRootFilesystem: true
    2. readOnly: true on the image
    3. immutable: true
    4. rootfs: ro
    Show answer

    Answer: A. readOnlyRootFilesystem: true

    It stops an attacker modifying binaries or dropping tools. Mount an emptyDir for paths like /tmp that the app must write to.

CKAD, Certified Kubernetes Application Developer, and Kubernetes are trademarks of The Linux Foundation. These questions are original study material, not questions from the real exam.