
Let's show how to do that.įirst, remember the system namespace. Let's say you have an RBAC permission error, you may want to view the K8s API server. % kubectl logs -n default -follow hello-547ffd886c-khfbp Kubectl: view logs % kubectl logs -n default hello-547ffd886c-khfbp If you check (kubectl get deployment hello -o yaml), you will see the replica count is back to 1. This applied the changes that we edited and diffed earlier.


Kubectl: apply % kubectl apply -f newDeployment.yaml Once satisfied, use apply to apply the changes. You should always use diff and see if the changes match your expectations just in case someone manually changed files and did not check those changes into git. Kubectl: diff kubectl diff -f newDeployment.yaml % kubectl get deployment hello -o yamlįull example % kubectl get deployment hello -o yaml > newDeployment.yamlĮdit file and change replica count back to 1 (vi newDeployment.yaml). (Take off the state and event data from the yaml file). You can use -o yaml to get a starter yaml file to edit. Kubectl: get the YAML of a k8s object use -o yaml This console output happens because I changed the replica count to 2 in the deployment file. See how hello pod replica (hello-547ffd886c-8bwrq) is added as not ready and then changes to ready. This goes nicely with the watch command above. This command is useful for debugging and testing. The kubectl edit command allows you to directly edit k8s objects and resource. It works with other resources as well, e.g., namespaces kubectl get namespaces -watch. Solemn-salamander-jenkins-555df964d5-8vfbd 1/1 Running 0 4d18h Lumpy-arachnid-prometheus-server-567f96c6bf-kzn2m 2/2 Running 0 4d18h Lumpy-arachnid-prometheus-pushgateway-84b5f94d76-cpkjn 1/1 Running 0 4d18h Lumpy-arachnid-prometheus-node-exporter-sf7vb 1/1 Running 0 4d18h Lumpy-arachnid-prometheus-kube-state-metrics-f46d484-k8mj6 1/1 Running 0 4d18h Lumpy-arachnid-prometheus-alertmanager-79ff6d8bcf-ql27z 2/2 Running 0 4d18h Many kubectl have a -watch option to watch for changes. This command is useful after you run a large helm install and want to see if the associated pods are ready. Kubectl: Watch for changes using kubectl get pods -watchĪfter getting the pods, watch for changes to pods. This is a pointer to distinguish between explicit The zsh extends Bourne shell but with improvements and of course features from Bash, ksh, and tcsh.Īdd autoload -Uz compinit compinit source In 2019, Apple announced that macOS Catalina would now use Zsh ( Z Shell) as the default shell, replacing bash. Shell completion is a must while you are learning Kubernetes.

This is a bit of an extension on some earlier thoughts on using Kubernetes on a Mac/OSX laptop.
