2020-01-29 10:40:27 +08:00
|
|
|
- name: 准备kube-controller-manager 证书签名请求
|
2020-12-25 11:53:00 +08:00
|
|
|
template: src=kube-controller-manager-csr.json.j2 dest={{ cluster_dir }}/ssl/kube-controller-manager-csr.json
|
2020-01-29 10:40:27 +08:00
|
|
|
|
|
|
|
- name: 创建 kube-controller-manager证书与私钥
|
2020-12-25 11:53:00 +08:00
|
|
|
shell: "cd {{ cluster_dir }}/ssl && {{ base_dir }}/bin/cfssl gencert \
|
2020-01-29 10:40:27 +08:00
|
|
|
-ca=ca.pem \
|
|
|
|
-ca-key=ca-key.pem \
|
|
|
|
-config=ca-config.json \
|
|
|
|
-profile=kubernetes kube-controller-manager-csr.json | {{ base_dir }}/bin/cfssljson -bare kube-controller-manager"
|
|
|
|
|
|
|
|
- name: 设置集群参数
|
|
|
|
shell: "{{ base_dir }}/bin/kubectl config set-cluster kubernetes \
|
2020-12-25 11:53:00 +08:00
|
|
|
--certificate-authority={{ cluster_dir }}/ssl/ca.pem \
|
2020-01-29 10:40:27 +08:00
|
|
|
--embed-certs=true \
|
|
|
|
--server={{ KUBE_APISERVER }} \
|
2020-12-25 11:53:00 +08:00
|
|
|
--kubeconfig={{ cluster_dir }}/kube-controller-manager.kubeconfig"
|
2020-01-29 10:40:27 +08:00
|
|
|
|
|
|
|
- name: 设置认证参数
|
2020-01-29 18:05:58 +08:00
|
|
|
shell: "{{ base_dir }}/bin/kubectl config set-credentials system:kube-controller-manager \
|
2020-12-25 11:53:00 +08:00
|
|
|
--client-certificate={{ cluster_dir }}/ssl/kube-controller-manager.pem \
|
|
|
|
--client-key={{ cluster_dir }}/ssl/kube-controller-manager-key.pem \
|
2020-01-29 10:40:27 +08:00
|
|
|
--embed-certs=true \
|
2020-12-25 11:53:00 +08:00
|
|
|
--kubeconfig={{ cluster_dir }}/kube-controller-manager.kubeconfig"
|
2020-01-29 10:40:27 +08:00
|
|
|
|
|
|
|
- name: 设置上下文参数
|
|
|
|
shell: "{{ base_dir }}/bin/kubectl config set-context default \
|
|
|
|
--cluster=kubernetes \
|
2020-01-29 18:05:58 +08:00
|
|
|
--user=system:kube-controller-manager \
|
2020-12-25 11:53:00 +08:00
|
|
|
--kubeconfig={{ cluster_dir }}/kube-controller-manager.kubeconfig"
|
2020-01-29 10:40:27 +08:00
|
|
|
|
|
|
|
- name: 选择默认上下文
|
|
|
|
shell: "{{ base_dir }}/bin/kubectl config use-context default \
|
2020-12-25 11:53:00 +08:00
|
|
|
--kubeconfig={{ cluster_dir }}/kube-controller-manager.kubeconfig"
|