管理 KubeConfig 設定

kube-config 設定參考

警告
這個做法會有安全性問題,理想上還是另外使用管理工具 (如 rancher) 來處理使用者資訊以及一般使用者使用的 kubeconfig
1
cat /etc/kubernetes/admin.conf
1
cat /etc/rancher/rke2/rke2.yaml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: <first-cluster-cert-data>
    server: https://<first-cluster domain>:6443
  name: first-cluster
- cluster:
    certificate-authority-data: <second-cluster-cert-data>
    server: https://<second-cluster domain>:6443
  name: second-cluster
contexts:
- context:
    cluster: first-cluster
    user: first-cluster-admin
  name: first-cluster-admin@first-cluster
- context:
    cluster: second-cluster
    user: second-cluster-admin
  name: second-cluster-admin@second-cluster
current-context: first-cluster-admin@first-cluster
kind: Config
preferences: {}
users:
- name: first-cluster-admin
  user:
    client-certificate-data: <first-cluster-admin-cert-data>
    client-key-data: <first-cluster-admin-cert-key>
- name: second-cluster-admin
  user:
    client-certificate-data: <second-cluster-admin-cert-data>
    client-key-data: <second-cluster-admin-cert-key>