k8s☞kubectl多集群管理

阅读量: zyh 2020-08-26 09:18:22
Categories: > Tags:

前言

sunny0826/kubecm: Easier management of kubeconfig. (github.com)

下载、安装

wget -O kubecm_release.tgz https://github.com/sunny0826/kubecm/releases/download/v0.15.3/kubecm_0.15.3_Linux_x86_64.tar.gz
tar xf kubecm_release.tgz && rm -rf kubecm_release.tgz
mv kubecm /usr/local/bin/

基本使用

add (kubecm.cloud)

添加配置 zyh.yaml

apiVersion: v1
clusters:
- cluster:
    server: https://x.x.x.x:6443
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSU  
    name: kubernetes
contexts:
- context:
    cluster: kubernetes                                                                                         user: "kubernetes-admin"
  name: aaa103439
current-context: kubernetes-admin
kind: Config
preferences: {}
users:
- name: "kubernetes-admin"
  user:
    client-certificate-data: LS0tLS1CRUdJTiBDRV    
    client-key-data: LS0tLS1CRUdJTiBSU0EgUFJ

💥contexts.[].name不可与其它集群配置重复.

kubecm add -f zyh.yaml # 合并 zyh.yaml 到 ~/.kube/config
===
选择 true

切换配置

kubecm switch qa

删除配置

kubecm delete qa