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?
Akubectl skips exec plugins unless the cluster's CA is in the operating system trust store
BExec plugins run inside the target cluster, so they cannot touch the engineer's machine
CUse kubeconfig files only from trusted sources; crafted ones can run code or expose files
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.
A kubeconfig uses an exec credential plugin whose response includes an expirationTimestamp. How does the client handle the returned token?
AIt caches the token forever and never runs the plugin again after that
BIt caches it until expiry, a 401 response or the process exits
CIt runs the plugin before every single request
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.
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?
AThe command-line flag's CA, since flags are checked first
BThe one in the kubeconfig, because files always win over flags
CBoth, and the server must be signed by each of them
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.