forked from easzlab/kubeasz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
- block: | ||
- name: 下载 group:read rbac 文件 | ||
copy: src=read-group-rbac.yaml dest=/tmp/read-group-rbac.yaml | ||
|
||
- name: 创建group:read rbac 绑定 | ||
shell: "{{ base_dir }}/bin/kubectl apply -f /tmp/read-group-rbac.yaml" | ||
|
||
- name: 准备kubectl使用的read证书签名请求 | ||
template: src=read-csr.json.j2 dest={{ base_dir }}/.cluster/ssl/read-csr.json | ||
|
||
- name: 创建read证书与私钥 | ||
shell: "cd {{ base_dir }}/.cluster/ssl && {{ base_dir }}/bin/cfssl gencert \ | ||
-ca=ca.pem \ | ||
-ca-key=ca-key.pem \ | ||
-config=ca-config.json \ | ||
-profile=kubernetes read-csr.json | {{ base_dir }}/bin/cfssljson -bare read" | ||
|
||
- name: 设置只读kubeconfig集群参数 | ||
shell: "{{ base_dir }}/bin/kubectl config set-cluster {{ CLUSTER_NAME }} \ | ||
--certificate-authority={{ base_dir }}/.cluster/ssl/ca.pem \ | ||
--embed-certs=true \ | ||
--server={{ KUBE_APISERVER }} \ | ||
--kubeconfig=/root/.kube/read.config" | ||
|
||
- name: 设置只读kubeconfig客户端认证参数 | ||
shell: "{{ base_dir }}/bin/kubectl config set-credentials read \ | ||
--client-certificate={{ base_dir }}/.cluster/ssl/read.pem \ | ||
--embed-certs=true \ | ||
--client-key={{ base_dir }}/.cluster/ssl/read-key.pem \ | ||
--kubeconfig=/root/.kube/read.config" | ||
|
||
- name: 设置只读kubeconfig上下文参数 | ||
shell: "{{ base_dir }}/bin/kubectl config set-context {{ CLUSTER_NAME }} \ | ||
--cluster={{ CLUSTER_NAME }} --user=read \ | ||
--kubeconfig=/root/.kube/read.config" | ||
|
||
- name: 选择只读kubeconfig默认上下文 | ||
shell: "{{ base_dir }}/bin/kubectl config use-context {{ CLUSTER_NAME }} \ | ||
--kubeconfig=/root/.kube/read.config" | ||
tags: create_ro_kctl_cfg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters