Fix basic auth tokens for kubeadm deployment. (#3801)
* Fix basic auth tokens for kubeadm deployment. * Tokens should be a dependancy on master, not nodes
This commit is contained in:
parent
19792cfae7
commit
432f8e9841
7 changed files with 29 additions and 32 deletions
6
roles/kubernetes/master/meta/main.yml
Normal file
6
roles/kubernetes/master/meta/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- role: kubernetes/tokens
|
||||||
|
when: kube_token_auth
|
||||||
|
tags:
|
||||||
|
- k8s-secrets
|
|
@ -5,12 +5,6 @@
|
||||||
- k8s-gen-certs
|
- k8s-gen-certs
|
||||||
- facts
|
- facts
|
||||||
|
|
||||||
- import_tasks: check-tokens.yml
|
|
||||||
tags:
|
|
||||||
- k8s-secrets
|
|
||||||
- k8s-gen-tokens
|
|
||||||
- facts
|
|
||||||
|
|
||||||
- name: Make sure the certificate directory exits
|
- name: Make sure the certificate directory exits
|
||||||
file:
|
file:
|
||||||
path: "{{ kube_cert_dir }}"
|
path: "{{ kube_cert_dir }}"
|
||||||
|
@ -18,13 +12,6 @@
|
||||||
mode: o-rwx
|
mode: o-rwx
|
||||||
group: "{{ kube_cert_group }}"
|
group: "{{ kube_cert_group }}"
|
||||||
|
|
||||||
- name: Make sure the tokens directory exits
|
|
||||||
file:
|
|
||||||
path: "{{ kube_token_dir }}"
|
|
||||||
state: directory
|
|
||||||
mode: o-rwx
|
|
||||||
group: "{{ kube_cert_group }}"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# The following directory creates make sure that the directories
|
# The following directory creates make sure that the directories
|
||||||
# exist on the first master for cases where the first master isn't
|
# exist on the first master for cases where the first master isn't
|
||||||
|
@ -37,7 +24,7 @@
|
||||||
owner: kube
|
owner: kube
|
||||||
run_once: yes
|
run_once: yes
|
||||||
delegate_to: "{{groups['kube-master'][0]}}"
|
delegate_to: "{{groups['kube-master'][0]}}"
|
||||||
when: gen_certs|default(false) or gen_tokens|default(false)
|
when: gen_certs|default(false)
|
||||||
tags:
|
tags:
|
||||||
- kubelet
|
- kubelet
|
||||||
- k8s-secrets
|
- k8s-secrets
|
||||||
|
@ -55,20 +42,10 @@
|
||||||
owner: kube
|
owner: kube
|
||||||
run_once: yes
|
run_once: yes
|
||||||
delegate_to: "{{groups['kube-master'][0]}}"
|
delegate_to: "{{groups['kube-master'][0]}}"
|
||||||
when: gen_certs|default(false) or gen_tokens|default(false)
|
when: gen_certs|default(false)
|
||||||
tags:
|
tags:
|
||||||
- k8s-secrets
|
- k8s-secrets
|
||||||
|
|
||||||
- name: "Get_tokens | Make sure the tokens directory exits (on {{groups['kube-master'][0]}})"
|
|
||||||
file:
|
|
||||||
path: "{{ kube_token_dir }}"
|
|
||||||
state: directory
|
|
||||||
mode: o-rwx
|
|
||||||
group: "{{ kube_cert_group }}"
|
|
||||||
run_once: yes
|
|
||||||
delegate_to: "{{groups['kube-master'][0]}}"
|
|
||||||
when: gen_tokens|default(false)
|
|
||||||
|
|
||||||
- include_tasks: "gen_certs_script.yml"
|
- include_tasks: "gen_certs_script.yml"
|
||||||
when:
|
when:
|
||||||
- cert_management |d('script') == 'script'
|
- cert_management |d('script') == 'script'
|
||||||
|
@ -130,8 +107,3 @@
|
||||||
- kubelet
|
- kubelet
|
||||||
- node
|
- node
|
||||||
- kube-proxy
|
- kube-proxy
|
||||||
|
|
||||||
- import_tasks: gen_tokens.yml
|
|
||||||
tags:
|
|
||||||
- k8s-secrets
|
|
||||||
- k8s-gen-tokens
|
|
||||||
|
|
0
roles/kubernetes/secrets/files/kube-gen-token.sh → roles/kubernetes/tokens/files/kube-gen-token.sh
Executable file → Normal file
0
roles/kubernetes/secrets/files/kube-gen-token.sh → roles/kubernetes/tokens/files/kube-gen-token.sh
Executable file → Normal file
|
@ -17,7 +17,6 @@
|
||||||
- "{{ groups['kube-master'] }}"
|
- "{{ groups['kube-master'] }}"
|
||||||
register: gentoken_master
|
register: gentoken_master
|
||||||
changed_when: "'Added' in gentoken_master.stdout"
|
changed_when: "'Added' in gentoken_master.stdout"
|
||||||
notify: set secret_changed
|
|
||||||
run_once: yes
|
run_once: yes
|
||||||
delegate_to: "{{groups['kube-master'][0]}}"
|
delegate_to: "{{groups['kube-master'][0]}}"
|
||||||
when: gen_tokens|default(false)
|
when: gen_tokens|default(false)
|
||||||
|
@ -31,7 +30,6 @@
|
||||||
- "{{ groups['kube-node'] }}"
|
- "{{ groups['kube-node'] }}"
|
||||||
register: gentoken_node
|
register: gentoken_node
|
||||||
changed_when: "'Added' in gentoken_node.stdout"
|
changed_when: "'Added' in gentoken_node.stdout"
|
||||||
notify: set secret_changed
|
|
||||||
run_once: yes
|
run_once: yes
|
||||||
delegate_to: "{{groups['kube-master'][0]}}"
|
delegate_to: "{{groups['kube-master'][0]}}"
|
||||||
when: gen_tokens|default(false)
|
when: gen_tokens|default(false)
|
19
roles/kubernetes/tokens/tasks/main.yml
Normal file
19
roles/kubernetes/tokens/tasks/main.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- import_tasks: check-tokens.yml
|
||||||
|
tags:
|
||||||
|
- k8s-secrets
|
||||||
|
- k8s-gen-tokens
|
||||||
|
- facts
|
||||||
|
|
||||||
|
- name: Make sure the tokens directory exits
|
||||||
|
file:
|
||||||
|
path: "{{ kube_token_dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: o-rwx
|
||||||
|
group: "{{ kube_cert_group }}"
|
||||||
|
|
||||||
|
- import_tasks: gen_tokens.yml
|
||||||
|
tags:
|
||||||
|
- k8s-secrets
|
||||||
|
- k8s-gen-tokens
|
|
@ -18,3 +18,5 @@ kube_encrypt_secret_data: true
|
||||||
ingress_nginx_enabled: true
|
ingress_nginx_enabled: true
|
||||||
cert_manager_enabled: true
|
cert_manager_enabled: true
|
||||||
metrics_server_enabled: true
|
metrics_server_enabled: true
|
||||||
|
kube_token_auth: true
|
||||||
|
kube_basic_auth: true
|
||||||
|
|
Loading…
Reference in a new issue