Connect YAML structure to real resources: Deployments, Services, ConfigMaps, and the kubectl commands you use in labs to create, inspect, and change manifests safely.
apiVersion/kind/metadata/spec pattern, label/selectors, full Deployment+Service examples, and practical add/edit flows aligned with repo paths like k8s/labs/basics/.
apiVersion: ... # which API kind: ... # resource type metadata: # name, namespace, labels, annotations ... spec: # desired state (varies by kind) ...
The cluster fills status for you—do not copy status from kubectl get -o yaml back into hand-written files unless you know you need it (usually you do not).
Labels are metadata used for grouping and routing. A Service selector must match Pod labels.
metadata: labels: app: nginx tier: frontend
spec: selector: app: nginx ports: - port: 80 targetPort: 8080
kubectl describe svc <name> in the lab.A Deployment nests a Pod template under spec.template. Indentation depth is easy to get wrong: containers belongs under template.spec, not under spec next to replicas.
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.25.3 ports: - containerPort: 80
apiVersion: v1 kind: ConfigMap metadata: name: app-config data: LOG_LEVEL: info app.properties: | feature.enabled=true
stringData)Use stringData when writing by hand; Kubernetes stores encoded values. Never commit real production secrets to git.
apiVersion: v1 kind: Secret metadata: name: app-secret type: Opaque stringData: api_token: replace-in-lab-only
k8s/labs/... in your editor. Change image tag, replicas, or env vars.kubectl apply --dry-run=client -f path/to/file.yamlkubectl apply -f path/to/file.yamlkubectl get, kubectl describe, kubectl logskubectl edit deployment/nginx-deployment
Opens the live object in an editor. Good for learning; for reproducible labs, prefer changing the YAML file and re-applying.
kubectl get deployment nginx-deployment -o yamlStrip status
Use exports to compare field names, then trim status and read-only fields before saving as a manifest.
k8s/labs/basics/ or k8s/labs/workloads/, set image: to another tag (e.g. nginx:1.25-alpine), apply, run kubectl describe pod and confirm the image.replicas: in a Deployment file, apply, watch kubectl get pods -w.containers:, run kubectl apply, read the error, fix spaces, re-apply.--- and a small Service below a Deployment; apply once and verify both objects.kubectl explain pod kubectl explain pod.spec kubectl explain pod.spec.containers kubectl explain deployment.spec.template.spec
kubectl explain is faster than guessing field names from blog posts.Go to Part 3 — VS Code extensions, online YAML tools, dry-run/server checks, and common error patterns.