bootstrap-kubeconfig

[python]  ​​view plain​​​  ​​​copy​

1. apiVersion: v1
2. #集群信息
3. clusters:
4. - cluster:
5. certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUR2akNDQXFhZ0F3SUJBZ0lVYVl4d2tqcHErMTB1SkkzaDlWbG5kY0VvVlJnd0RRWUpLb1pJaHZjTkFRRUwKQlFBd1pURUxNQWtHQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFVcHBibWN4RURBT0JnTlZCQWNUQjBKbAphVXBwYm1jeEREQUtCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByCmRXSmxjbTVsZEdWek1CNFhEVEUzTURVeE1UQTFNell3TUZvWERUSXlNRFV4TURBMU16WXdNRm93WlRFTE1Ba0cKQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFVcHBibWN4RURBT0JnTlZCQWNUQjBKbGFVcHBibWN4RERBSwpCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByZFdKbGNtNWxkR1Z6Ck1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBdWhZK1V2d1lhRFMrU3ltbjFTdzAKZzREODJHV0liSU0xbHdWVVVxSG92Sit3K1VUeDYwOUxXNEc3ekdMMXRtUHo0TGpRU3dydytqOTVBc3VrbzhSdwpOYkZlbUhhRTg5ZU41VjkyZU8xeWtSbVhGNEJoaDJXSDZyNEhpUGl6NStYWWpaY0VQZCtsVDJNNGxvbzhBbTRyClZvVE1aMVdVbnpsS0d6SVJSY1lPbkpsRURwdVM4T3hzYWk2Zm9rQ1IxUjhyZEhNYUdTV3F6RHU5ZmpHRnYvQ2IKbU9yQXc4Wlc4OVFtamRSOVBtVmt3ZE1CUGhGMGhxV20yVE95SU9LNGlHK2RrT0p0U2JFdVlvMkx2RzRySmNGYgppYlkvdEgwaEh6TWVrL3dRL1FJQ3Q5ZjFHaU9zVzVvOTRJbGZJWFd1Um9SNW5aS1A1TUFwYlJDcDdqdnAyR3ROCjZRSURBUUFCbzJZd1pEQU9CZ05WSFE4QkFmOEVCQU1DQVFZd0VnWURWUjBUQVFIL0JBZ3dCZ0VCL3dJQkFqQWQKQmdOVkhRNEVGZ1FVSnhFODFtYlJDNnBSUVFlZjV4UWlrZERReUpJd0h3WURWUjBqQkJnd0ZvQVVKeEU4MW1iUgpDNnBSUVFlZjV4UWlrZERReUpJd0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFET2liVFNITldpZTA5Qmk2SzhQCmlYUzVmajRwWlJGcktycFFvMEFtSTlpckp3Z1JzalRlKzZBblBaRFBUa0RhZlhvdHNON0pKa2RtT0UrcWVRWG4KNTlCVG9WWlFjT001dzdWOHI4MnFjSEtTSnFRdGtZVEhNS0o4MnV0T2tCZmdFNE9tYytHWm1rR0s1VmUrN09DRgo2ZnVJTXRKbGIvdlZsKzh2L2RHN1dmNXJTV1B3ekp2V0Y4ZjdzQnBqNHRubFNCdnhHNE5GakI4VGJkY3EwQVNKCk5QNWdybURwVnp0RlRRS0V1b213cHFIUDFpUWFkN1gxVks5d1FNZnVDdHZrbVdKS2VCbHhqbnhGS0FlT2VocTcKSGdBRDZXS1ZvWERTRFRxaTRmSUlMbkJScEcrVmdsM2JoVkRibnZYbXQwcTF5MEVBMkJOeTlFdE5MVkJoRElmVgovM0k9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
6. 192.168.6.131:6443
7. name: kubernetes
8.
9. #设置上下文
10. contexts:
11. - context:
12. cluster: kubernetes
13. user: kubelet-bootstrap
14. name: default
15.
16. #默认上下文
17. current-context: default
18.
19. #客户端认证参数
20. kind: Config
21. preferences: {}
22. users:
23. - name: kubelet-bootstrap
24. user:
25. 5f9ecec99fd645f4665d87260f94f734

.kube/config

[python]
​​view plain​​​
​​​copy​​


1. apiV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5ZjFHaU9zVzVvOTRJbGZJWFd1Um9SNW5aS1A1TUFwYlJDcDdqdnAyR3ROCjZRSURBUUFCbzJZd1pEQU9CZ05WSFE4QkFmOEVCQU1DQVFZd0VnWURWUjBUQVFIL0JBZ3dCZ0VCL3dJQkFqQWQKQmdOVkhRNEVGZ1FVSnhFODFtYlJDNnBSUVFlZjV4UWlrZERReUpJd0h3WURWUjBqQkJnd0ZvQVVKeEU4MW1iUgpDNnBSUVFlZjV4UWlrZERReUpJd0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFET2liVFNITldpZTA5Qmk2SzhQCmlYUzVmajRwWlJGcktycFFvMEFtSTlpckp3Z1JzalRlKzZBblBaRFBUa0RhZlhvdHNON0pKa2RtT0UrcWVRWG4KNTlCVG9WWlFjT001dzdWOHI4MnFjSEtTSnFRdGtZVEhNS0o4MnV0T2tCZmdFNE9tYytHWm1rR0s1VmUrN09DRgo2ZnVJTXRKbGIvdlZsKzh2L2RHN1dmNXJTV1B3ekp2V0Y4ZjdzQnBqNHRubFNCdnhHNE5GakI4VGJkY3EwQVNKCk5QNWdybURwVnp0RlRRS0V1b213cHFIUDFpUWFkN1gxVks5d1FNZnVDdHZrbVdKS2VCbHhqbnhGS0FlT2VocTcKSGdBRDZXS1ZvWERTRFRxaTRmSUlMbkJScEcrVmdsM2JoVkRibnZYbXQwcTF5MEVBMkJOeTlFdE5MVkJoRElmVgovM0k9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
6. 192.168.6.131:6443
7. name: kubernetes
8.
9. #设置上下文
10. contexts:
11. - context:
12. cluster: kubernetes
13. user: admin
14. name: kubernetes
15.
16. #设置默认上下文
17. current-context: kubernetes
18.
19. #设置客户端认证参数
20. kind: Config
21. preferences: {}
22. users:
23. - name: admin
24. user:
25. client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQzVENDQXNXZ0F3SUJBZ0lVWGlteHlvSFBjN0djWW90ZW4zdk9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YUdZM2k4VmVjMTdkK3FaNUFZamFDTkdhMkhxVXpsCmVVaU55SVlVQ2ZaZzFzcHJSYldnbktTL3IyeW9NV01GNTV3clpOTUNnWUEyUmVleHNNbWZzVWJQaWZWWVRKOXAKR0F2WVJEbWU4NEc4bUlwVGJCVlBBaWxiTENDbTkrdmNrS0pla0xFS3EvK25pTmloSkNhQmVLMHB4VW1GdWJJSQpqQThRUEVjd0tsKzcxdFE0OEN6andxcUh3SnI3RmljWjN3OEdJZDB2TjE3OFhtRnBEcXNnQXB1U0hJR2hyUDZZClQ5RXVwdTJnVUFwNmhqREtsWE5nb1FLQmdHL2w0d043djBJVi9JTmo4d2JhTi8rSml1Yk5IU0dqN21KbFZwcGUKVGxsOFY1a1JZVDEwcGVnT2paWmtZY0l3ZmtzNXlGUUhpamw4eCttYmNrS2RtWWxBdnFYL3JqUHFGODg1ZUFEVgoxWmlnTXh4QWdvd0x3cGEyNUxnQi9JU2xPMkpZQ2lRbWhrV0tpSGpPWk85Q21kSlZmVzlYaG1zcXlESWo5VXJRCkpFd3JBb0dCQUtjNnI2SHVFVnJQVEdDU3hSQWMrRytoZkhQT3ZKTnJWQmpxZFBYeVl3M1huVVNaNjAvUEVnNWIKTS9LQVVONEc4U3FHYS9SRTlUc3FTdkRNTCtSVEo5Z2t3MVpLZDU0VlljOGZtOEZlWDlJMXhXMjRVWDBpcmcwUAo3dWZrejRxdUlPVWpMYXhLU2YyakdjVXpybVoxRExzZjI5cjZWTCt1NmFKayt2OHdCOCtZCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==



创建 kubectl kubeconfig 文件



$ # 设置集群参数

$ kubectl config set-cluster kubernetes \

--certificate-authority=/etc/kubernetes/ssl/ca.pem \

--embed-certs=true \

--server=${KUBE_APISERVER}

$ # 设置客户端认证参数

$ kubectl config set-credentials admin \

--client-certificate=/etc/kubernetes/ssl/admin.pem \

--embed-certs=true \

--client-key=/etc/kubernetes/ssl/admin-key.pem

$ # 设置上下文参数

$ kubectl config set-context kubernetes \

--cluster=kubernetes \

--user=admin

$ # 设置默认上下文

$ kubectl config use-context kubernetes









创建 kubelet bootstrapping kubeconfig 文件



$ # 设置集群参数

$ kubectl config set-cluster kubernetes \

--certificate-authority=/etc/kubernetes/ssl/ca.pem \

--embed-certs=true \

--server=${KUBE_APISERVER} \

--kubeconfig=bootstrap.kubeconfig

$ # 设置客户端认证参数

$ kubectl config set-credentials kubelet-bootstrap \

--token=${BOOTSTRAP_TOKEN} \

--kubeconfig=bootstrap.kubeconfig

$ # 设置上下文参数

$ kubectl config set-context default \

--cluster=kubernetes \

--user=kubelet-bootstrap \

--kubeconfig=bootstrap.kubeconfig

$ # 设置默认上下文

$ kubectl config use-context default --kubeconfig=bootstrap.kubeconfig

$ mv bootstrap.kubeconfig /etc/kubernetes/