Hands-on Lab·Certified Kubernetes Administrator
Declarative Versus Imperative Object Management
Create the same Deployment twice, once with a command and once with a file, then look at what each left behind on the object. One remembers what you asked for; the other does not. That difference is why apply can diff and create cannot.
Foundations Guide 5 of 103 Beginner
- Kubernetes1.36.4
- Cluster4 nodes
- Runtimecontainerd 2.2.6
- CNICalico v3.32.1
- TimeAbout 25 min
- Reviewed21 August 2026
Written against the versions above. Temporary paths and timestamps in the diff output are from this run and will differ on yours.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| CKA1001 | 192.168.0.175 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE01 | 192.168.0.176 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE02 | 192.168.0.177 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE03 | 192.168.0.178 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
Before you start
- A working cluster and
kubectl. - The kubectl session guide, mainly for
kubectl explain, which is how you find field names without looking them up. - The Pods guide, so the Deployment spec below is recognisable.
-
The imperative shortcut, and how to make it write YAML for you
-
Run it for real, then ask what it remembered
-
The declarative form, and the annotation it leaves behind
-
Why that annotation matters: kubectl diff
-
Which to use, and the trap in mixing them