Skip to content

Instantly share code, notes, and snippets.

@nhthai2005
Created April 10, 2022 03:36
Show Gist options
  • Save nhthai2005/877775b9e931784d8164faebad616390 to your computer and use it in GitHub Desktop.
Save nhthai2005/877775b9e931784d8164faebad616390 to your computer and use it in GitHub Desktop.
Kubernetes completion script
# Kubectl Autocomplete
source <(kubectl completion bash)
alias k=kubectl
complete -F __start_kubectl k
alias kns='kubectl config set-context --current --namespace'
alias kurrent='kubectl config view --minify -o "jsonpath={..namespace}" | xargs -I %s echo "Current Namespace: %s"'
alias kcurrent=kurrent
alias nodetop='k get nodes | grep Ready | cut -d" " -f1 | xargs kubectl describe node | grep -E "Name: |cpu |memory "'
alias ktop=nodetop
export KUBECONFIG=$HOME/.kube/config
# Helm completion bash
source <(helm completion bash)
# Kubernetes completion script
source <(kubectl completion zsh)
alias k=kubectl
complete -F __start_kubectl k
alias kns='kubectl config set-context --current --namespace'
alias kurrent='kubectl config view --minify -o "jsonpath={..namespace}" | xargs -I %s echo "Current Namespace: %s"'
alias kcurrent=kurrent
alias nodetop='k get nodes | grep Ready | cut -d" " -f1 | xargs kubectl describe node | grep -E "Name: |cpu |memory "'
alias ktop=nodetop
export KUBECONFIG=$HOME/.kube/config
# Helm completion zsh
source <(helm completion zsh)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment