Alias


key value
k kubectl
rs replicaset
ns namepsaces
svc service
cm configmap
sa serviceaccounts
pv persistentvolumes
pvc persistentvolumeclaims
sts statefulset
ds daemonset
ep endpoints

Env. setup


# add following scripts to ~/.bashrc

alias kubectl="k3s kubectl"
source /etc/profile.d/bash_completion.sh
source <(kubectl completion bash)
alias k=kubectl
complete -F __start_kubectl k
alias crictl='k3s crictl'
eval "$(starship init bash)"
export KUBE_EDITOR="vim"
export PS1="\\h $ "
export PAGER=less

Tips


Frequently Used Commands


commands definition
k get all view deployments of app
k get pods -A view all namespaces
k get pods -o wide view pods details
k logs <pod-name> view pod logs
k config view view kubectl configs
k config use-context <context name> change context of cluster
**`ps -aux grep <process name>`**
journalctl -u <service name> -l view service logs
crictl ps -a for debugging in case kube-api server is not working
k run test --image nginx --rm -it -- sh run sub shell for debugging in pod env.
ssh <node> '<command>' &> <log path> ssh and exec commands
k get svc,ep -l <key>=<value> inspect service and endpoints using labels

Concepts


Pod

A pod is a single instance of an application. A pod is the smallest object that you can create in Kubernetes. A single Pod can have multiple containers except for the fact that they’re usually not multiple containers of the same kind.