function kns() { local cache="$XDG_CACHE_HOME/${FUNCNAME[0]}" if [ -n "$1" ]; then if ! kubectl get namespace -o name | grep -q "^namespace/$1\$"; then echo "error: no namespace exists with the name: \"$1\"" >&2 return 1 fi kubectl config set-context --current --namespace "$1" > /dev/null else if [ "${KUBECONFIG:-"$HOME/.kube/config"}" -nt "$cache" ]; then set -- "$(kubectl config view --minify -o jsonpath='{..namespace}')" else cat "$cache" return fi fi tee "$cache" <<< "$1" } function kctx() { local cache="$XDG_CACHE_HOME/${FUNCNAME[0]}" if [ -n "$1" ]; then kubectl config use-context "$1" > /dev/null || return else if [ "${KUBECONFIG:-"$HOME/.kube/config"}" -nt "$cache" ]; then set -- "$(kubectl config current-context)" else cat "$cache" return fi fi tee "$cache" <<< "$1" } alias kga='kubectl get "$(kubectl api-resources --verbs=list --namespaced -oname | grep -v event | paste -sd,)"' . /usr/share/bash-completion/completions/kubectl compalias k=kubectl \ ka='kubectl apply --recursive -f' \ kd='kubectl describe' \ kdcj='kubectl describe cronjob' \ kdcm='kubectl describe configmap' \ kddep='kubectl describe deployment' \ kding='kubectl describe ingress' \ kdj='kubectl describe job' \ kdno='kubectl describe node' \ kdns='kubectl describe namespace' \ kdpo='kubectl describe pod' \ kdpvc='kubectl describe persistentvolumeclaim' \ kdsec='kubectl describe secret' \ kdsts='kubectl describe statefulset' \ kdsvc='kubectl describe service' \ kex='kubectl exec -i -t' \ kg='kubectl get' \ kgall='kubectl get --all-namespaces' \ kgalloname='kubectl get --all-namespaces -o name' \ kgallowide='kubectl get --all-namespaces -o wide' \ kgalloyaml='kubectl get --all-namespaces -o yaml' \ kgcj='kubectl get cronjob' \ kgcjall='kubectl get cronjob --all-namespaces' \ kgcjalloname='kubectl get cronjob --all-namespaces -o name' \ kgcjallowide='kubectl get cronjob --all-namespaces -o wide' \ kgcjalloyaml='kubectl get cronjob --all-namespaces -o yaml' \ kgcjoname='kubectl get cronjob -o name' \ kgcjowide='kubectl get cronjob -o wide' \ kgcjoyaml='kubectl get cronjob -o yaml' \ kgcm='kubectl get configmap' \ kgcmall='kubectl get configmap --all-namespaces' \ kgcmalloname='kubectl get configmap --all-namespaces -o name' \ kgcmallowide='kubectl get configmap --all-namespaces -o wide' \ kgcmalloyaml='kubectl get configmap --all-namespaces -o yaml' \ kgcmoname='kubectl get configmap -o name' \ kgcmowide='kubectl get configmap -o wide' \ kgcmoyaml='kubectl get configmap -o yaml' \ kgdep='kubectl get deployment' \ kgdepall='kubectl get deployment --all-namespaces' \ kgdepalloname='kubectl get deployment --all-namespaces -o name' \ kgdepallowide='kubectl get deployment --all-namespaces -o wide' \ kgdepalloyaml='kubectl get deployment --all-namespaces -o yaml' \ kgdeponame='kubectl get deployment -o name' \ kgdepowide='kubectl get deployment -o wide' \ kgdepoyaml='kubectl get deployment -o yaml' \ kging='kubectl get ingress' \ kgingall='kubectl get ingress --all-namespaces' \ kgingalloname='kubectl get ingress --all-namespaces -o name' \ kgingallowide='kubectl get ingress --all-namespaces -o wide' \ kgingalloyaml='kubectl get ingress --all-namespaces -o yaml' \ kgingoname='kubectl get ingress -o name' \ kgingowide='kubectl get ingress -o wide' \ kgingoyaml='kubectl get ingress -o yaml' \ kgj='kubectl get job' \ kgjall='kubectl get job --all-namespaces' \ kgjalloname='kubectl get job --all-namespaces -o name' \ kgjallowide='kubectl get job --all-namespaces -o wide' \ kgjalloyaml='kubectl get job --all-namespaces -o yaml' \ kgjoname='kubectl get job -o name' \ kgjowide='kubectl get job -o wide' \ kgjoyaml='kubectl get job -o yaml' \ kgno='kubectl get node' \ kgns='kubectl get namespace' \ kgnsoname='kubectl get namespace -o name' \ kgnsowide='kubectl get namespace -o wide' \ kgnsoyaml='kubectl get namespace -o yaml' \ kgoname='kubectl get -o name' \ kgowide='kubectl get -o wide' \ kgoyaml='kubectl get -o yaml' \ kgpo='kubectl get pod' \ kgpoall='kubectl get pod --all-namespaces' \ kgpoalloname='kubectl get pod --all-namespaces -o name' \ kgpoallowide='kubectl get pod --all-namespaces -o wide' \ kgpoalloyaml='kubectl get pod --all-namespaces -o yaml' \ kgpooname='kubectl get pod -o name' \ kgpoowide='kubectl get pod -o wide' \ kgpooyaml='kubectl get pod -o yaml' \ kgpvc='kubectl get persistentvolumeclaim' \ kgpvcall='kubectl get persistentvolumeclaim --all-namespaces' \ kgpvcalloname='kubectl get persistentvolumeclaim --all-namespaces -o name' \ kgpvcallowide='kubectl get persistentvolumeclaim --all-namespaces -o wide' \ kgpvcalloyaml='kubectl get persistentvolumeclaim --all-namespaces -o yaml' \ kgpvconame='kubectl get persistentvolumeclaim -o name' \ kgpvcowide='kubectl get persistentvolumeclaim -o wide' \ kgpvcoyaml='kubectl get persistentvolumeclaim -o yaml' \ kgsec='kubectl get secret' \ kgsecall='kubectl get secret --all-namespaces' \ kgsecalloname='kubectl get secret --all-namespaces -o name' \ kgsecallowide='kubectl get secret --all-namespaces -o wide' \ kgsecalloyaml='kubectl get secret --all-namespaces -o yaml' \ kgseconame='kubectl get secret -o name' \ kgsecowide='kubectl get secret -o wide' \ kgsecoyaml='kubectl get secret -o yaml' \ kgsts='kubectl get statefulset' \ kgstsall='kubectl get statefulset --all-namespaces' \ kgstsalloname='kubectl get statefulset --all-namespaces -o name' \ kgstsallowide='kubectl get statefulset --all-namespaces -o wide' \ kgstsalloyaml='kubectl get statefulset --all-namespaces -o yaml' \ kgstsoname='kubectl get statefulset -o name' \ kgstsowide='kubectl get statefulset -o wide' \ kgstsoyaml='kubectl get statefulset -o yaml' \ kgsvc='kubectl get service' \ kgsvcall='kubectl get service --all-namespaces' \ kgsvcalloname='kubectl get service --all-namespaces -o name' \ kgsvcallowide='kubectl get service --all-namespaces -o wide' \ kgsvcalloyaml='kubectl get service --all-namespaces -o yaml' \ kgsvconame='kubectl get service -o name' \ kgsvcowide='kubectl get service -o wide' \ kgsvcoyaml='kubectl get service -o yaml' \ klo='kubectl logs -f' \ kpf='kubectl port-forward' \ krm='kubectl delete' \ krmcj='kubectl delete cronjob' \ krmcm='kubectl delete configmap' \ krmdep='kubectl delete deployment' \ krming='kubectl delete ingress' \ krmj='kubectl delete job' \ krmns='kubectl delete namespace' \ krmpo='kubectl delete pod' \ krmpvc='kubectl delete persistentvolumeclaim' \ krmsec='kubectl delete secret' \ krmsts='kubectl delete statefulset' \ krmsvc='kubectl delete service'