Make YAML editing pleasant: VS Code extensions, safe online validators, kubectl dry-run and diff, and a troubleshooting matrix for the errors learners hit most often in labs.
Extension ID: redhat.vscode-yaml. Provides syntax highlighting, schema-based validation when configured, and hover help for many Kubernetes resources if you associate schemas or use the Kubernetes extension below.
Extension ID: ms-kubernetes-tools.vscode-kubernetes-tools. Snippets for resources, navigation between manifests, and cluster integration. Pairs well with the YAML extension for fewer “mystery indent” mistakes.
spec trees while editing one section.kubectl explain).Use these when the error says error converting YAML to JSON—that usually means the file is not valid YAML yet, before Kubernetes even checks resource fields.
kubectl apply --dry-run=client -o yaml -f your-manifest.yaml
Checks that kubectl can parse the file and build the object. Does not talk to admission webhooks.
kubectl apply --dry-run=server -f your-manifest.yaml
Requires a cluster connection. Catches more validation, including some policy and admission issues.
kubectl diff -f your-manifest.yaml
Compares your file to live objects—great after hand-editing exported YAML.
kubectl explain deployment.spec.template.spec.containers --recursive
| Error or symptom | Likely cause | Fix |
|---|---|---|
found character that cannot start any token | Tab character or stray character in column 1 | Replace tabs with spaces; show invisible characters in the editor. |
did not find expected key | List item or child key mis-indented | Align - list markers; ensure name: under a container is deeper than -. |
mapping values are not allowed here | Missing newline after : or broken flow | Put value on same line or indent block correctly on next line. |
unknown field in Pod spec | Field belongs under Deployment template | Move under spec.template.spec for workload templates. |
| Service has no Endpoints | Selector labels mismatch Pod labels | Compare spec.selector to metadata.labels on Pods. |
| Resource unchanged but behavior wrong | Edited file but applied wrong path | Confirm kubectl apply -f path; use kubectl diff. |
kubectl apply --dry-run=client -f ....kubectl describe / logs for runtime issues.You now have syntax (Part 1), object patterns and editing (Part 2), and tooling plus troubleshooting (Part 3).