World map

 

BM: Baca dalam Bahasa Melayu

World K1: The Food Court

Dry run and kubectl explain

You will learn: to rehearse a command safely, and to look up any YAML field.

Checked with Kubernetes 1.37 on 31 Oct 2026

The problem

You need a Deployment file. Twenty lines of YAML, from memory? What is the smart move?

Pick one answer.

Watch

You are here: cluster kind-dev namespace default
The dry run prints a full Deployment in YAML. Then get deployments says: No resources found. Terminal output: $ kubectl create deployment shop --image=nginx:1.29-alpine --replicas=3 --dry-run=client -o yaml apiVersion: apps/v1 kind: Deployment metadata: labels: app: shop name: shop spec: replicas: 3 selector: matchLabels: app: shop strategy: {} template: metadata: labels: app: shop spec: containers: - image: nginx:1.29-alpine name: nginx resources: {} status: {} $ kubectl get deployments No resources found in default namespace.

A dry run: A rehearsal: kubectl shows what it would do, and changes nothing. is a rehearsal. --dry-run=client -o yaml prints the order and creates nothing. get deployments proves it: no resources found.

Try it

Your turn. Add the flags that print this pod’s YAML without making it.

You are here: cluster kind-dev namespace default
Stalls: 3. Trays: 0 (0 ready). Waiting for a stall: 0.
dev-control-planeOpenManager

No trays here.

dev-workerOpen

No trays here.

dev-worker2Open

No trays here.

Time: +0s (sped up)

Predict

--dry-run=client stays on your laptop. --dry-run=server asks the cluster to check, then throws it away. Which one catches more mistakes?

Pick one answer.

Watch

You are here: cluster kind-dev namespace default
kubectl explain deployment.spec.replicas: an integer, the number of desired pods, default 1. Terminal output: $ kubectl explain deployment.spec.replicas GROUP: apps KIND: Deployment VERSION: v1 FIELD: replicas <integer> DESCRIPTION: Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.

Forgot what a field means? kubectl explain reads the cluster’s own docs. Join the field path with dots: deployment, then spec, then replicas.

Try it

Build the command that explains a Pod’s restartPolicy.

Tap the pieces in the right order.

…

Check

Dry run or explain? Which one helps here?

Drag a card into a box. Or tap the card, then tap the box.

      You did it!

      You can now rehearse with a dry run and look up any field.

      Go deeper (optional)

      Where the story breaks: a real manager can improvise. Kubernetes can’t. It only chases what the order board says. And a closed stall’s trays never walk away. New trays are cooked elsewhere, with new names.

      Real rep (optional): try these two on your kind cluster.

      You are here: cluster kind-dev namespace default
      The server dry run says deployment.apps/shop created (server dry run). explain lists Always, Never and OnFailure. Terminal output: $ kubectl apply -f shop.yaml --dry-run=server deployment.apps/shop created (server dry run) $ kubectl explain pod.spec.restartPolicy KIND: Pod VERSION: v1 FIELD: restartPolicy <string> ENUM: Always Never OnFailure DESCRIPTION: Restart policy for all containers within the pod. One of Always, OnFailure, Never. In some contexts, only a subset of those values may be permitted. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy Possible enum values: - `"Always"` - `"Never"` - `"OnFailure"`