liveBook · Manning

Dry run

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

Dry-run is a command option that simulates an operation without applying its resulting resource changes.

A dry run simulates a Kubernetes operation without applying its resulting resource changes. With kubectl, --dry-run=client generates an object locally so you can inspect or edit it before creation. section 2.1.3

Generate a pod manifest

Run kubectl run pod-tolerate --image=nginx --dry-run=client -o yaml > pod-tolerate.yaml. Edit the generated YAML to add tolerations, then create the pod with kubectl create -f pod-tolerate.yaml. Verify the result with kubectl get pods -o wide. section 2.1.3

Use dry runs to prepare resource definitions efficiently:

  • Generate a resource skeleton instead of typing its manifest from scratch. section 2.1.3
  • Redirect YAML output to a file, modify the specification, and submit it separately. section 2.1.3 section 8.1.1
  • Remember that generation alone does not create the resource; use kubectl create or kubectl apply afterward. section 2.1.3 section 8.1.1
root@kind-control-plane:/# kubectl run pod-tolerate --image=nginx --dry-
run=client -o yaml > pod-tolerate.yaml
root@kind-control-plane:/# cat pod-tolerate.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: pod-tolerate
  name: pod-tolerate
spec:
  containers:
  - image: nginx
    name: pod-tolerate
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

Inspect the generated Pod YAML to see the skeleton produced by kubectl run --dry-run=client -o yaml. section 2.1.3

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

How deep it goes
Explains client-side YAML generation and the subsequent creation step, but does not detail broader dry-run behavior.
Examples
Uses kubectl run to generate Pod YAML, edits tolerations or containers, and later creates or applies the manifest.
What it assumes
Assumes familiarity with kubectl and basic Kubernetes manifests while demonstrating object generation from a command.
What you can do after
Build it from scratch by generating an editable Kubernetes manifest and applying it after the required fields are added.
How it connects
Connects kubectl, YAML manifests, Kubernetes Pods, resource creation, tolerations, and container specifications.

Also explained in

Compare how 3 books explain dry run →

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.