kcd

    alias kcd=’kubectl config set-context $(kubectl config current-context) —namespace’
    kcd 命名空间

    1. # Get current context
    2. alias krc='kubectl config current-context'
    3. # List all contexts
    4. alias klc='kubectl config get-contexts -o name | sed "s/^/ /;\|^ $(krc)$|s/ /*/"'
    5. # Change current context
    6. alias kcc='kubectl config use-context "$(klc | fzf -e | sed "s/^..//")"'
    7. # Get current namespace
    8. alias krn='kubectl config get-contexts --no-headers "$(krc)" | awk "{print \$5}" | sed "s/^$/default/"'
    9. # List all namespaces
    10. alias kln='kubectl get -o name ns | sed "s|^.*/| |;\|^ $(krn)$|s/ /*/"'
    11. # Change current namespace
    12. alias kcn='kubectl config set-context --current --namespace "$(kln | fzf -e | sed "s/^..//")"'
    13. 作者:tonybai
    14. 链接:https://www.imooc.com/article/291842
    15. 来源:慕课网
    16. 本文首次发布于慕课网 ,转载请注明出处,谢谢合作