KCNA · Domain 1: Kubernetes Fundamentals · 44% of the exam
Task 1.2: Administration
Working with a cluster through kubectl and kubeconfig contexts, declarative and imperative object management, resource quotas and limit ranges, node maintenance, upgrades and the version skew policy, and backing up etcd.
Study it
Working with a cluster: kubectl, kubeconfig contexts, apply versus create
Lesson coming
Quotas, limit ranges, node maintenance, upgrades and etcd backups
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 team keeps its manifests in Git. Its pipeline must create the objects on the first run and update them on every later run, without failing because the objects already exist. Which command fits?
Akubectl create -f manifests/
Bkubectl apply -f manifests/
Ckubectl replace -f manifests/
Dkubectl run app --image=app:1.0
Show the answer and why
Akubectl create -f manifests/
Incorrect
create is imperative object configuration for new objects; it reports an error when an object already exists.
Bkubectl apply -f manifests/
Correct
Declarative configuration lets kubectl detect per object whether to create or patch it, and it works on whole directories.
Ckubectl replace -f manifests/
Incorrect
replace overwrites live objects that must already exist and drops changes not in the file, so the first run fails.
Dkubectl run app --image=app:1.0
Incorrect
run starts a single Pod imperatively and does not read the manifests at all.
Declarative object configuration with kubectl apply is the fit for files kept in version control: the same command creates, updates and works on directories.
An engineer's kubeconfig file defines two contexts, staging and production. kubectl commands currently go to staging. Which command makes the following commands go to production?
Akubectl config use-context production
Bkubectl config set-context production
Ckubectl config view --minify
Dkubectl cluster-info
Show the answer and why
Akubectl config use-context production
Correct
use-context sets the current context in the kubeconfig file, and kubectl uses it for every later command.
Bkubectl config set-context production
Incorrect
set-context does not switch which context is current, so later commands would still go to staging.
Ckubectl config view --minify
Incorrect
view prints the configuration; with --minify it shows only what the current context uses. It changes nothing.
Dkubectl cluster-info
Incorrect
cluster-info prints the addresses of the control plane and services for the current context.
A kubeconfig file can hold many clusters, users and contexts; kubectl config use-context picks the one that later commands use.
A worker node needs a kernel update and a reboot. The administrator wants the node's Pods moved elsewhere gracefully, honoring PodDisruptionBudgets, and no new Pods placed on it meanwhile. Which command does this?
A NoSchedule taint keeps new Pods off but leaves the running Pods where they are.
Ckubectl drain <node> --ignore-daemonsets
Correct
drain marks the node unschedulable and evicts its Pods through the Eviction API, which respects PodDisruptionBudgets. DaemonSet Pods are skipped with the flag.
Dkubectl rollout restart deployment --all
Incorrect
Restarting every Deployment recreates Pods across the cluster, possibly on the same node, and ignores Pods not owned by Deployments.
kubectl drain is the maintenance command: it cordons the node and evicts Pods with respect for disruption budgets, so workloads move before the reboot.
A shared cluster gives each team its own namespace. The administrator wants all of team-a's Pods together to request no more than 20 CPUs and 64Gi of memory. Which object enforces that?
ALimitRange in team-a
BPriorityClass for team-a's Pods
CResourceQuota in team-a
DPodDisruptionBudget for team-a's Deployments
Show the answer and why
ALimitRange in team-a
Incorrect
A LimitRange constrains individual Pods or containers, not the total for the namespace.
BPriorityClass for team-a's Pods
Incorrect
Priority orders Pods for scheduling and preemption. It sets no ceiling on what a team consumes.
CResourceQuota in team-a
Correct
A ResourceQuota limits the aggregate resource consumption of a namespace and rejects requests that would exceed it.
DPodDisruptionBudget for team-a's Deployments
Incorrect
A disruption budget limits how many Pods voluntary disruptions may take down at once. It says nothing about resources.
Namespace-wide totals are the job of ResourceQuota; once a quota covers CPU or memory, Pods in that namespace must state requests or limits for them.
A developer wants to read, from the terminal, the documented fields under a Deployment's spec.strategy for the API version that the cluster serves. Which command shows them?
Akubectl describe deployment web
Bkubectl api-resources
Ckubectl get deployment web -o yaml --show-managed-fields
Dkubectl explain deployment.spec.strategy
Show the answer and why
Akubectl describe deployment web
Incorrect
describe shows the live state and recent events of one object, not field documentation.
Bkubectl api-resources
Incorrect
api-resources lists the kinds the server supports, with short names and scope, but no field documentation.
Ckubectl get deployment web -o yaml --show-managed-fields
Incorrect
This prints one object's current values. Fields that are unset do not appear and nothing is explained.
Dkubectl explain deployment.spec.strategy
Correct
explain describes the fields and structure of a resource, addressed with a simple JSONPath-style identifier, using the cluster's API schema.
kubectl explain reads the API schema the server publishes, so it is the quickest way to look up what a field means and which sub-fields it has.
An administrator will upgrade a kubeadm cluster from Kubernetes v1.35 to v1.37. Which two steps follow the supported upgrade path? (Choose TWO.)
AUpgrade the worker nodes' kubelets first so they are ready for the new API
BUpgrade to v1.36 first and then from v1.36 to v1.37
CRun kubeadm upgrade apply v1.37.x directly on the v1.35 control plane
DUpgrade the control plane nodes before the worker nodes
EUpgrade the nodes together in one step and skip the drain
Show the answer and why
AUpgrade the worker nodes' kubelets first so they are ready for the new API
Incorrect
A kubelet newer than kube-apiserver is outside the version skew policy.
BUpgrade to v1.36 first and then from v1.36 to v1.37
Correct
kubeadm supports upgrades of one minor version at a time; skipping a minor version is unsupported.
CRun kubeadm upgrade apply v1.37.x directly on the v1.35 control plane
Incorrect
That skips a minor version, which kubeadm does not support.
DUpgrade the control plane nodes before the worker nodes
Correct
The workflow upgrades the primary control plane node, then the other control plane nodes, then the workers, because a kubelet must not be newer than the API server.
EUpgrade the nodes together in one step and skip the drain
Incorrect
The documented procedure drains each node before upgrading its kubelet so workloads move off first.
Go one minor version at a time, control plane first and nodes after, draining each node before its kubelet is upgraded.
In a shared namespace, developers often forget to set CPU and memory requests and limits. The administrator wants such containers to receive sensible defaults automatically. What should be created?
Akubectl set resources run on each Deployment
BA PriorityClass marked globalDefault
CA VerticalPodAutoscaler for each Deployment
DA LimitRange with default requests and limits
Show the answer and why
Akubectl set resources run on each Deployment
Incorrect
That sets values once per workload by hand; new containers still get none.
BA PriorityClass marked globalDefault
Incorrect
That sets a default priority, not resource values.
CA VerticalPodAutoscaler for each Deployment
Incorrect
VPA recommends or adjusts requests from usage; it is not a namespace-wide default for new containers.
DA LimitRange with default requests and limits
Correct
A LimitRange can set default requests and limits that the admission controller applies to containers that do not set them.
LimitRange sets per-container defaults and bounds inside a namespace, so containers that state nothing still get sensible values.
A field was removed from a manifest, and the next client-side kubectl apply also removed it from the live object. Where does kubectl find out which fields the previous apply had set?
AIn the status field of the live object
BIn its last-applied-configuration annotation
CIn a local cache file next to the manifest
DIn the Deployment's revision history
Show the answer and why
AIn the status field of the live object
Incorrect
status reports current state written by controllers.
BIn its last-applied-configuration annotation
Correct
Client-side apply stores the applied configuration in this annotation and compares it with the new file.
CIn a local cache file next to the manifest
Incorrect
kubectl keeps no per-object cache on disk for this.
DIn the Deployment's revision history
Incorrect
Revision history tracks Pod template changes, not every applied field.
The last-applied-configuration annotation lets apply compute what to add, change and delete.