Skip to content

KCSA · Domain 2: Kubernetes Cluster Component Security · 22% of the exam

Task 2.10: Client Security

kubeconfig files and the credentials they hold, client certificates, exec credential plugins and short-lived tokens.

Study it

  • kubeconfig and client credentials

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the CNCF documentation page that proves it.

Question 1 · choose 1

A contractor emails a kubeconfig file so that an engineer can run kubectl against the contractor's cluster. The file's user entry calls an exec credential plugin. What does the Kubernetes documentation on kubeconfig files warn about?

  1. Akubectl skips exec plugins unless the cluster's CA is in the operating system trust store
  2. BExec plugins run inside the target cluster, so they cannot touch the engineer's machine
  3. CUse kubeconfig files only from trusted sources; crafted ones can run code or expose files
  4. DThe file is safe once its context is made current with kubectl config use-context
Show the answer and why
  • Akubectl skips exec plugins unless the cluster's CA is in the operating system trust store

    Incorrect

    kubectl runs the exec plugin that the file configures; no trust store setting makes it skip the plugin.

  • BExec plugins run inside the target cluster, so they cannot touch the engineer's machine

    Incorrect

    A credential plugin is a command that kubectl runs locally on the engineer's machine to obtain credentials.

  • CUse kubeconfig files only from trusted sources; crafted ones can run code or expose files

    Correct

    The kubeconfig page warns that a specially crafted kubeconfig file could result in malicious code execution or file exposure.

  • DThe file is safe once its context is made current with kubectl config use-context

    Incorrect

    Selecting a context does not vet the file; using it is what runs whatever the user entry configures.

A kubeconfig file can tell kubectl to run commands, such as an exec credential plugin, on the local machine. The kubeconfig documentation therefore warns to use only files from trusted sources, since a crafted file can lead to code execution or file exposure.

Question 2 · choose 1

A kubeconfig uses an exec credential plugin whose response includes an expirationTimestamp. How does the client handle the returned token?

  1. AIt caches the token forever and never runs the plugin again after that
  2. BIt caches it until expiry, a 401 response or the process exits
  3. CIt runs the plugin before every single request
  4. DIt writes the token into the kubeconfig file for later use
Show the answer and why
  • AIt caches the token forever and never runs the plugin again after that

    Incorrect

    With an expiry included, the token is dropped when it expires and the plugin is run again.

  • BIt caches it until expiry, a 401 response or the process exits

    Correct

    The authentication page says that with an expiry the credentials are cached until it is reached, the server returns 401, or the process exits.

  • CIt runs the plugin before every single request

    Incorrect

    The client caches the credentials rather than calling the plugin for each request.

  • DIt writes the token into the kubeconfig file for later use

    Incorrect

    The plugin's credentials are cached in the client process, not written back to the file.

Exec credential plugins let kubectl and client-go fetch credentials from an external source. When the plugin returns an expiry, the client reuses the token until then (or until a 401 or process exit), which suits short-lived tokens.

Question 3 · choose 1

An engineer runs kubectl with --certificate-authority pointing to one CA file, while the current context's cluster entry in the kubeconfig names a different CA. Which CA does kubectl use to verify the API server?

  1. AThe command-line flag's CA, since flags are checked first
  2. BThe one in the kubeconfig, because files always win over flags
  3. CBoth, and the server must be signed by each of them
  4. DNeither, and kubectl skips verification because they conflict
Show the answer and why
  • AThe command-line flag's CA, since flags are checked first

    Correct

    The kubeconfig documentation says cluster information is built from a chain where the first hit wins, starting with command-line flags such as --server and --certificate-authority.

  • BThe one in the kubeconfig, because files always win over flags

    Incorrect

    Flags come first in the chain; kubeconfig values are used only when no flag sets them.

  • CBoth, and the server must be signed by each of them

    Incorrect

    kubectl uses the first value found, not a combination of trust anchors.

  • DNeither, and kubectl skips verification because they conflict

    Incorrect

    A conflict is resolved by order; verification still happens with the chosen CA.

kubectl assembles cluster and user information in a fixed order: command-line flags first, then the merged kubeconfig files. A --certificate-authority flag therefore overrides the CA in the kubeconfig for that command.

Practice domain 2 →Practice all domains →