Voici une liste d’aliases Bash que j’utilise plus ou moins fréquement pour administrer un cluster Kubernetes.
# generic
alias k="kubectl"
alias kg="kubectl get"
alias kd="kubectl describe"
# config
alias kcfg="kubectl config view"
# namespaces
alias kgn="kubectl get namespaces"
alias kdn="kubectl describe namespaces"
alias kcn="kubectl create namespace"
alias kdeln="kubectl delete namespaces"
# pods
alias kgp="kubectl get pods --all-namespaces --output=wide"
alias kdp="kubectl describe pod"
alias kdelp="kubectl delete pod"
# ingress
alias kgi="kubectl get ingress --all-namespaces --output=wide"
alias kdi="kubectl describe ingress"
alias kdeli="kubectl delete ingress"
# nodes
alias kgnodes="kubectl get nodes --output wide"
alias kdnodes="kubectl describe nodes"
# deployments
alias ked="kubectl expose deployment"
alias kgd="kubectl get deployment --all-namespaces"
alias kdd="kubectl describe deployment"
alias kdeld="kubectl delete deployments"
function klogd(){
local deployment="$1"
[[ -z "$deployment" ]] \
&& echo "usage: klogd <deployment-name>" \
&& return 255
kubectl logs "deployments/$deployment"
}
# services
alias kgs="kubectl get services --all-namespaces"
alias kds="kubectl describe service"
alias kdels="kubectl delete service"
# storage
alias kgpv="kubectl get pv --all-namespaces"
alias kgpvc="kubectl get pvc --all-namespaces"
alias kdelpv="kubectl delete pv"
alias kdelpvc="kubectl delete pvc"
# apply from file
alias kap="kubectl apply -f"
alias kac="kubectl create -f"
# get shell to container
function kpshell(){
local namespace="$1"
local pod="$2"
[[ -z "$pod" ]] \
&& echo "usage: kpshell <namespace> <pod-name>" \
&& return 255
kubectl -n "$namespace" exec --stdin --tty "$pod" -- /bin/bash
}
export KUBECONFIG=$(pwd)/kubeconfig.yml