zoukankan      html  css  js  c++  java
  • kubectl 安装命令自动补全

    kubectl 安装和命令自动补全

    kubectl 安装

    centos

    cat <<EOF > /etc/yum.repos.d/kubernetes.repo
    [kubernetes]
    name=Kubernetes
    baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
    enabled=1
    gpgcheck=1
    repo_gpgcheck=1
    gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
    EOF
    yum install -y kubectl
    

    ubuntu

    sudo apt-get update && sudo apt-get install -y apt-transport-https
    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
    echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
    sudo apt-get update
    sudo apt-get install -y kubectl
    

    命令补全

    在linux上

    # yum install -y bash-completion
    # source /usr/share/bash-completion/bash_completion
    # source <(kubectl completion bash)
    

    测试下,没问题后,我们对 /root/.bashrc 加2行代码 ,方便以后每次登录自动生效:

    source /usr/share/bash-completion/bash_completion
    source <(kubectl completion bash)
    

    在mac上

    $ brew install bash-completion
    $ source $(brew --prefix)/etc/bash_completion
    $ source <(kubectl completion bash)
    
  • 相关阅读:
    [译]git reflog
    [译]git rebase -i
    [译]git rebase
    [译]git commit --amend
    [译]git clean
    [译]git reset
    [译]git revert
    [译]git checkout
    [译]git log
    [译]git status
  • 原文地址:https://www.cnblogs.com/h-gallop/p/11713022.html
Copyright © 2011-2022 走看看