Skip to main content

kubectl

How apply works: https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/#merging-changes-to-primitive-fields If object does not exist, it is created If object exists, YAML is compared to live. If there is a difference live is updated, then last applied configuration database is updated (in JSON format) Last applied configuration is stored as JSON as an annotation to the live object. If a field is removed from YAML, then it is checked against Last applied config to see if the field needs to be removed from live. If a field is in live, but not in local OR last applied, it will be left as-is.

Generate YAML for a resource:

alias dk=“kubectl --dry-run=client -o=yaml

dk create service …

Get Current Context kubectl config current-context

Switch Namespace Default kubectl config set-context $(kubectl config current-context) —namespace=dev

kubectl replace —force -f /tmp/…

kubectl proxy - Proxy to the Kubernetes HTTP endpoint with credentials in place so you can curl http://localhost:8001 /versions