- 创建 .kubectl_aliases 别名文件,脚本下载: wget https://githubcdn.qiushaocloud.top/gh/qiushaocloud/cdn-static/k8s/.kubectl_aliases_qiu -O ~/.kubectl_aliases
alias k='kubectl'
# 切换命名空间
alias kcd='kubectl config set-context $(kubectl config current-context) --namespace'
alias kg='kubectl get'
alias kgpo='kubectl get pods'
alias kgdep='kubectl get deployment'
alias kgcm='kubectl get configmap'
alias kgsvc='kubectl get service'
alias kgns='kubectl get namespaces'
alias kgno='kubectl get nodes'
alias kgposl='kubectl get pods --show-labels'
alias kgsvcoyaml='kubectl get service -o=yaml'
alias kgsvcwn='kubectl get service --watch --namespace'
alias kgsvcslwn='kubectl get service --show-labels --watch --namespace'
alias kd='kubectl describe'
alias kdno='kubectl describe nodes'
alias kdsvc='kubectl describe service'
alias kdns='kubectl describe namespaces'
alias krm='kubectl delete'
alias krmf='kubectl delete -f'
alias krmpo='kubectl delete pods'
alias krmsvc='kubectl delete service'
alias krmcm='kubectl delete configmap'
alias krmns='kubectl delete namespaces'
alias krmdep='kubectl delete deployment'
alias ka='kubectl apply --recursive -f'
alias kex='kubectl exec -i -t'
-
更详细的别名文件下载地址: wget https://githubcdn.qiushaocloud.top/gh/qiushaocloud/cdn-static/k8s/.kubectl_aliases -O ~/.kubectl_aliases ,文件来源:https://github.com/ahmetb/kubectl-aliases
-
使用别名文件,在您的系统的 .bashrc/.zshrc 文件中 添加 [ -f ~/.kubectl_aliases ] && source ~/.kubectl_aliases
评论区