Declarative Resource Management: CNPA practice questions
Declarative resource management means describing the state you want rather than the steps to get there, and letting software work out and apply the difference. Kubernetes is built around it. Objects carry a spec that records the desired state and a status that reports the current one, and controllers keep working to bring the two together.
By Ibrahim Yesilay · Published · Updated
Independent community practice, not affiliated with or endorsed by CNCF or The Linux Foundation.
What Declarative Resource Management covers in CNPA
Declarative resource management means describing the state you want rather than the steps to get there, and letting software work out and apply the difference. Kubernetes is built around it. Objects carry a spec that records the desired state and a status that reports the current one, and controllers keep working to bring the two together. For a platform team this is what makes self-service, review and automation possible: a desired state written in a file can be stored in Git, reviewed in a pull request, reproduced in another environment and reapplied after a failure.
The Kubernetes documentation separates three management techniques. Imperative commands such as kubectl create deployment act directly on live objects; they are quick for experiments but leave no record, no review step and no template. Imperative object configuration (kubectl create -f, replace -f, delete -f) names the operation and a file; replace overwrites the whole spec and drops anything missing from the file, which breaks fields that the cluster updates on its own. Declarative object configuration (kubectl apply -f on files or directories) lets kubectl detect per object whether to create, patch or delete. It writes only the observed differences with a patch, so changes made by other writers survive. The documentation warns that an object should be managed with only one technique, because mixing them for the same object results in undefined behavior.
The workflow it recommends is to preview with kubectl diff and then run kubectl apply, recursively with -R where needed. Client-side apply stores what was last applied in the kubectl.kubernetes.io/last-applied-configuration annotation and uses it to work out what to remove. Server-side apply moves that logic into the API server: it tracks which field manager owns each field in managedFields, and an apply that tries to change a field owned by another manager is reported as a conflict instead of silently overwriting it. Kustomize, built into kubectl since 1.14 and used with kubectl apply -k, and Helm charts are common ways to generate declarative manifests for several environments.
GitOps builds directly on this. The first OpenGitOps principle is that a system managed by GitOps must have its desired state expressed declaratively; the others require that state to be versioned and immutable, pulled automatically by software agents and continuously reconciled.
Common mistakes are treating a YAML file as declarative while still deploying it with create or replace, assuming declarative means nothing can drift (it can, until something reconciles it), and expecting kubectl apply to delete objects whose files were removed. The documentation recommends kubectl delete -f as the explicit way to delete, and warns that the alternative, apply with --prune, needs care because the selected objects can be unexpectedly deleted or retained.
At associate level, expect to choose between imperative and declarative approaches for a scenario, to recognize the benefits of declarative configuration for audit, review and repeatability, and to connect desired state in files with the reconciliation that keeps a cluster on it.
Key points
- Kubernetes supports imperative commands, imperative object configuration and declarative object configuration; use one per object.
- kubectl diff previews and kubectl apply patches only the differences, keeping changes from other writers.
- Server-side apply records field ownership in managedFields and reports conflicts between field managers.
- Declarative desired state is the first of the four OpenGitOps principles.
Three sample questions
9 CNPA questions on Declarative Resource Management, 9 with explanations. How practice works
Question 1
kubectl create/kubectl replace in one script and kubectl apply on a directory in another. What does the Kubernetes object management guide say about this setup?- A.Mixing is recommended, because imperative commands give the audit trail and apply keeps the full history.
- B.Use only one technique per object; mixing them on the same object gives undefined behavior.
- C.It is safe as long as both scripts use the same YAML files.
- D.kubectl detects the conflict and converts the object to declarative management automatically.
Correct answer: B
Sources: CNCF CNPA curriculum (CNPA_Curriculum.pdf), Kubernetes: Object management
Question 2
kubectl apply -f on that file. According to kubernetes.io, why is the other writer's field normally kept?- A.It uses the patch operation to write only observed differences, instead of replacing the whole object.
- B.kubectl apply ignores the live object and only compares two versions of the local file.
- C.kubectl apply takes a lock on the object so that no other writer can change it afterwards.
- D.kubectl apply replaces the full object, and the API server then restores fields it remembers.
Correct answer: A
kubectl replace does, and the guide warns that it drops changes missing from the file.Sources: CNCF CNPA curriculum (CNPA_Curriculum.pdf), Kubernetes: Object management, Kubernetes: Declarative management with configuration files
Question 3
- A.The API accepts only YAML, while imperative APIs accept only JSON.
- B.You send the exact sequence of commands to run, and the server executes them once, in that order.
- C.Changes are applied once at submission time and the system never revisits them.
- D.You declare the desired state, and a controller keeps the current state in sync with it.
Correct answer: D
Sources: CNCF CNPA curriculum (CNPA_Curriculum.pdf), Kubernetes: Custom resources, Kubernetes: Controllers
Practice this topic
Focus mode keeps every question on Declarative Resource Management until you leave it. 10 free guest answers, then a free account; no credit card.
Or open CNPA practice across all topics.
Sources
The explanation above was checked against these official documents.
- Kubernetes documentation: Kubernetes Object Management (checked 2026-10-28)
- Kubernetes documentation: Declarative Management of Kubernetes Objects Using Configuration Files (checked 2026-10-28)
- Kubernetes documentation: Server-Side Apply (checked 2026-10-28)
- Kubernetes documentation: Declarative Management of Kubernetes Objects Using Kustomize (checked 2026-10-28)
- OpenGitOps: GitOps Principles v1.0.0 (checked 2026-10-28)