liveBook · Manning

Kubectl apply

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

kubectl apply is a kubectl command that creates a Kubernetes resource or updates an existing resource from configuration.

kubectl apply submits a YAML manifest to the Kubernetes API, creating a resource or updating an existing resource so the control plane reconciles the cluster toward the declared desired state. section 1.9

Choose apply when the manifest is the source of truth and resource lifecycle behavior matters:

  • Use kubectl create -f when the resource must not already exist; an existing resource causes an error. section 1.9
  • Use kubectl apply -f to create a missing resource or update an existing one. section 1.9
  • Use kubectl replace -f when replacement semantics are intended; Deployments receive a new rollout. section 1.9

Apply a node-selected pod

Add nodeSelector: disktype: ssd to ssd-pod.yaml, then run kubectl apply -f ssd-pod.yaml. Verify placement with kubectl get po -o wide; the pod should show the selected node, such as kind-worker. section 4.1

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Explains create, update, replacement, reconciliation, and verification, but defers Deployment and rollout details.
Examples
Uses Pod manifests, node-selector scheduling, multi-container Pod creation, and kubectl get or logs commands for verification.
What it assumes
Assumes basic YAML and Kubernetes resource knowledge while teaching declarative submission and create-versus-update behavior.
What you can do after
Apply it via kubectl, update resources from manifests, and verify resulting scheduling or Pod state with kubectl commands.
How it connects
Connects manifests, desired state, the Kubernetes API, reconciliation, node selectors, pod scheduling, and Deployments.

Also explained in

Compare how 6 books explain kubectl apply →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.