美文网首页Kubernetes
Kubernetes | 配置 kubectl 命令自动补全功能

Kubernetes | 配置 kubectl 命令自动补全功能

作者: 奶茶不要奶不要茶 | 来源:发表于2022-06-08 15:42 被阅读0次
    配置 kubectl 命令自动补全功能
    # 安装 bash-completion
    yum install -y bash-completion
    source /usr/share/bash-completion/bash_completion
    
    # 系统所有用户都拥有命令自动补全功能
    kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
    
    # 仅当前用户拥有命令自动补全功能
    #echo 'source <(kubectl completion bash)' >> ~/.bashrc
    #source ~/.bashrc
    
    kubectl 命令自动补全效果
    [root@k8s-master-01 ~]# kubectl
    alpha          attach         completion     debug          edit           help           patch          rollout        top
    annotate       auth           config         delete         exec           kustomize      plugin         run            uncordon
    api-resources  autoscale      cordon         describe       explain        label          port-forward   scale          version
    api-versions   certificate    cp             diff           expose         logs           proxy          set            wait
    apply          cluster-info   create         drain          get            options        replace        taint
    [root@k8s-master-01 ~]# kubectl config
    current-context  delete-context   get-clusters     get-users        set              set-context      unset            view
    delete-cluster   delete-user      get-contexts     rename-context   set-cluster      set-credentials  use-context
    [root@k8s-master-01 ~]# kubectl config view
    anaconda-ks.cfg  .bash_logout     .bashrc          .kube/           .ssh/            .viminfo
    .bash_history    .bash_profile    .cshrc           .pki/            .tcshrc
    [root@k8s-master-01 ~]# kubectl config view
    apiVersion: v1
    clusters:
    - cluster:
        certificate-authority-data: DATA+OMITTED
        server: https://192.168.3.201:6443
      name: kubernetes
    contexts:
    - context:
        cluster: kubernetes
        user: admin
      name: kubernetes
    current-context: kubernetes
    kind: Config
    preferences: {}
    users:
    - name: admin
      user:
        client-certificate-data: REDACTED
        client-key-data: REDACTED
    [root@k8s-master-01 ~]#
    

    参考链接:

    内含的工具 | Kubernetes

    Linux 系统中的 bash 自动补全功能 | Kubernetes

    相关文章

      网友评论

        本文标题:Kubernetes | 配置 kubectl 命令自动补全功能

        本文链接:https://www.haomeiwen.com/subject/snpumrtx.html