k9s cheatsheet: https://www.hackingnote.com/en/cheatsheets/k9s/
https://discuss.kubernetes.io/t/kubectl-tips-and-tricks/192
krew as the Kubernetes CLI (kubectl) plugin manager helps to install all the tools: https://krew.sigs.k8s.io/
Install kubectl
then configure autocompletion as stated in the docs: https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/#optional-kubectl-configurations-and-plugins with adding the following to your ~/.zshrc or ~/.bashrc:
### kubectl autocompletion & alias k
source <(kubectl completion zsh)
alias k=kubectl
complete -F __start_kubectl k
https://github.com/ahmetb/kubectx: Install via brew: brew install kubectx
Now run it and switch with ease:
# list all contexts
kubectx
# switch
kubectx k3d
If you want a fancy interactive mode, you need to install https://github.com/junegunn/fzf#using-homebrew
brew install fzf
# To install useful key bindings and fuzzy completion:
$(brew --prefix)/opt/fzf/install
Now your kubectx
and kubens
are super powered as interactive mode :)
https://github.com/jonmosco/kube-ps1:
install via:
brew install kube-ps1
# now source kube-ps1.sh in your ~/.zshrc or ~/.bashrc. Therefore add the following 2 lines to them:
source "/usr/local/opt/kube-ps1/share/kube-ps1.sh"
PS1='$(kube_ps1)'$PS1
Now you should already see the current k8s context & namespace inside your prompt:
# switch on and off
kubeon
kubeoff
Now this could all look like this:
For evaluation tools ee https://learnk8s.io/validating-kubernetes-yaml
Install via homebrew (see https://www.kubeval.com/installation/):
brew tap instrumenta/instrumenta
brew install kubeval
Now use kubeval your-yaml-to-check.yaml
Install via homebrew (see https://github.com/zegl/kube-score#installation): brew install kube-score
Run with
kube-score score your-yaml-to-check.yaml
https://kubernetes.io/docs/tasks/debug-application-cluster/debug-cluster/#looking-at-logs
sudo journalctl -u kube-apiserver --follow
see https://kubernetes.io/docs/reference/kubectl/cheatsheet/
kubectl cluster-info dump
kubectl get all --namespace kube-system
kubectl get all --all-namespaces
ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 --cacert=/etc/etcd/ca.pem --cert=/etc/etcd/kube-apiserver.pem --key=/etc/etcd/kube-apiserver-key.pem get / --prefix --keys-only
kubectl get nodes --output json
kubectl logs -n kube-system kube-flannel-ds-cw7kf -c kube-flannel
kubectl get pod kube-flannel-ds-cw7kf --namespace kube-system -o yaml
kubectl describe pods -l k8s-app=kube-dns -n kube-system
kubectl get nodes --output=jsonpath='{range .items[*]}{.status.addresses[?(@.type=="InternalIP")].address} {.spec.podCIDR} {"\n"}{end}'
see https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/
kubectl logs --namespace=kube-system
kubectl describe pod/coredns-65db874f4f-lz5hl --namespace kube-system
kubectl run hostnames --image=k8s.gcr.io/serve_hostname \
--labels=app=hostnames \
--port=9376 \
--replicas=3
kubectl expose deployment hostnames --port=80 --target-port=9376
kubectl describe nodes
Cluster in cluster: https://www.vcluster.com/ & https://github.com/loft-sh/vcluster
https://github.com/ahmetb/kubectl-tree
Deployment abstraction above Helm: https://www.acorn.io/
Telepresence alternative: https://gefyra.dev/
Docker Desktop alternatives: https://podman-desktop.io/
Bare metal Kubernetes: https://www.siderolabs.com/platform/bare-metal-kubernetes-sidero/
K8s simple deployment tooling (simpler than Argo and Flux): https://werf.io/
KubeCon 2022 Recordings: https://www.youtube.com/playlist?list=PLj6h78yzYM2MCEgkd8zH0vJWF7jdQ-GRR
VMWare Tanzu on a Laptop: https://tanzu.vmware.com/developer/guides/tanzu-application-platform-local-devloper-install/ (and in GitHub Actions etc.)