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


