Dry-run and structured output
Three different kinds of evidence
A manifest can be valid YAML but fail the Kubernetes API schema. A request accepted by the API can still create an unschedulable Pod or an application that never becomes ready. A client dry-run previews the client operation without submitting the requested write; discovery or validation can still require API access. A server dry-run submits the request for authorization, validation and applicable admission without persisting it. Neither proves successful scheduling, reconciliation, startup or application behavior. Webhooks must support dry-run for affected requests.
Preview and review the proposed change
The following example assumes a complete approved lab manifest and an explicit kubeconfig. The desired.yaml fixture intentionally points to fictional images. Compare a preview with live state using diff. Its exit status is 0 for no changes, 1 for differences, and greater than 1 for an error. A diff containing a Secret or other sensitive values must not be copied to public logs. Review the intended manager and namespace before any actual apply; none is authorized here.
kubectl --kubeconfig ./approved-lab.kubeconfig --context bytemind-lab -n api-lab apply --dry-run=client -f desired.yaml -o yamlkubectl --kubeconfig ./approved-lab.kubeconfig --context bytemind-lab -n api-lab apply --server-side --field-manager=release-bot --dry-run=server -f desired.yaml -o yamlkubectl --kubeconfig ./approved-lab.kubeconfig --context bytemind-lab -n api-lab diff --server-side --field-manager=release-bot -f desired.yamlRead structured output instead of scraping tables
JSON is suitable for a real parser; YAML helps humans review nested fields. JSONPath selects fields, custom-columns produces a compact table and Go templates format data with template logic. The examples below use a POSIX-style shell; quoting can differ elsewhere. A missing status.readyReplicas is not proof of readiness. In the synthetic deployment-live.json fixture, name is catalog, desired replicas are 3 and ready replicas are 2.
kubectl --kubeconfig ./approved-lab.kubeconfig --context bytemind-lab -n api-lab get deployment catalog -o jsonpath='{.metadata.name}{"\n"}'kubectl --kubeconfig ./approved-lab.kubeconfig --context bytemind-lab -n api-lab get deployment catalog -o 'custom-columns=NAME:.metadata.name,DESIRED:.spec.replicas,READY:.status.readyReplicas'kubectl --kubeconfig ./approved-lab.kubeconfig --context bytemind-lab -n api-lab get deployment catalog -o go-template='{{.metadata.name}}{{"\n"}}'Observe the outcome after a separately approved write
A watch delivers changes over time rather than repeatedly parsing a single table. Use bounded wait and rollout status commands when verifying a lab Deployment. Available can remain true during a partially failed rollout, so check the intended rollout and perform a functional smoke test. Inspect observedGeneration when reasoning about stale status. A timeout is a diagnostic signal, not proof that the object is absent. A server dry-run success followed by ImagePullBackOff in this fictional timeline is consistent: image availability is not demonstrated by admission.
kubectl --kubeconfig ./approved-lab.kubeconfig --context bytemind-lab -n api-lab get deployment catalog --watchkubectl --kubeconfig ./approved-lab.kubeconfig --context bytemind-lab -n api-lab wait --for=condition=Available deployment/catalog --timeout=60skubectl --kubeconfig ./approved-lab.kubeconfig --context bytemind-lab -n api-lab rollout status deployment/catalog --timeout=60sDeletion is also asynchronous
When deletion is requested, finalizers may keep the object visible with deletionTimestamp until cleanup completes. Foreground cascading deletion waits for qualifying blocking dependents; background deletion removes the owner and lets garbage collection handle dependents asynchronously; orphan propagation leaves dependents. Inspect the owning controller and cleanup obligations instead of stripping finalizers. A bounded wait for deletion can time out while the object still exists. Do not treat force deletion as a generic repair.
Practice: build an evidence chain
Review lab-fixtures/advanced-kubectl/evidence-cases.json. Classify each outcome as client preview, server acceptance, runtime status or application evidence. Explain why a diff exit status of 1 is not an execution error and why two ready replicas do not establish three-replica rollout success. Write a review checklist covering scope, intended change, admission, observed rollout and smoke test. The next chapter builds on this chain for continuous delivery.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Dry-run and structured output — knowledge check
Reason about the offline API change fixtures.
Which operation submits a write request without persisting it?
What does kubectl diff exit status 1 indicate?
What does a successful dry-run prove about an image pull?
Which is the best evidence that the new app serves expected requests?
Deletion timestamp exists and a finalizer remains. What next?