2017-11-01 22:25:35 +08:00
|
|
|
---
|
|
|
|
- name: Local Volume Provisioner | Ensure base dir is created on all hosts
|
|
|
|
file:
|
2019-01-09 04:36:44 +08:00
|
|
|
path: "{{ local_volume_provisioner_storage_classes[item.1].host_dir }}"
|
2018-02-15 09:55:43 +08:00
|
|
|
state: directory
|
2017-11-01 22:25:35 +08:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0700
|
2018-10-05 20:52:25 +08:00
|
|
|
delegate_to: "{{ item[0] }}"
|
|
|
|
with_nested:
|
|
|
|
- "{{ groups['k8s-cluster'] }}"
|
2019-03-21 02:29:42 +08:00
|
|
|
- "{{ local_volume_provisioner_storage_classes.keys() | list}}"
|
2017-11-01 22:25:35 +08:00
|
|
|
|
|
|
|
- name: Local Volume Provisioner | Create addon dir
|
|
|
|
file:
|
|
|
|
path: "{{ kube_config_dir }}/addons/local_volume_provisioner"
|
2018-02-15 09:55:43 +08:00
|
|
|
state: directory
|
2017-11-01 22:25:35 +08:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
|
2018-08-23 00:16:13 +08:00
|
|
|
- name: Local Volume Provisioner | Templates list
|
|
|
|
set_fact:
|
|
|
|
local_volume_provisioner_templates:
|
|
|
|
- { name: local-volume-provisioner-ns, file: local-volume-provisioner-ns.yml, type: ns }
|
|
|
|
- { name: local-volume-provisioner-sa, file: local-volume-provisioner-sa.yml, type: sa }
|
|
|
|
- { name: local-volume-provisioner-clusterrolebinding, file: local-volume-provisioner-clusterrolebinding.yml, type: clusterrolebinding }
|
|
|
|
- { name: local-volume-provisioner-cm, file: local-volume-provisioner-cm.yml, type: cm }
|
|
|
|
- { name: local-volume-provisioner-ds, file: local-volume-provisioner-ds.yml, type: ds }
|
|
|
|
- { name: local-volume-provisioner-sc, file: local-volume-provisioner-sc.yml, type: sc }
|
|
|
|
local_volume_provisioner_templates_for_psp_not_system_ns:
|
|
|
|
- { name: local-volume-provisioner-psp, file: local-volume-provisioner-psp.yml, type: psp }
|
|
|
|
- { name: local-volume-provisioner-psp-role, file: local-volume-provisioner-psp-role.yml, type: role }
|
|
|
|
- { name: local-volume-provisioner-psp-rb, file: local-volume-provisioner-psp-rb.yml, type: rolebinding }
|
|
|
|
|
|
|
|
- name: Local Volume Provisioner | Insert extra templates to Local Volume Provisioner templates list for PodSecurityPolicy
|
|
|
|
set_fact:
|
2018-08-29 17:35:00 +08:00
|
|
|
local_volume_provisioner_templates: "{{ local_volume_provisioner_templates[:2] + local_volume_provisioner_templates_for_psp_not_system_ns + local_volume_provisioner_templates[2:] }}"
|
2018-08-23 00:16:13 +08:00
|
|
|
when:
|
|
|
|
- podsecuritypolicy_enabled
|
|
|
|
- local_volume_provisioner_namespace != "kube-system"
|
|
|
|
|
2017-11-01 22:25:35 +08:00
|
|
|
- name: Local Volume Provisioner | Create manifests
|
|
|
|
template:
|
2018-02-01 14:14:18 +08:00
|
|
|
src: "{{ item.file }}.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/addons/local_volume_provisioner/{{ item.file }}"
|
2018-08-23 00:16:13 +08:00
|
|
|
with_items: "{{ local_volume_provisioner_templates }}"
|
2018-02-15 09:55:43 +08:00
|
|
|
register: local_volume_provisioner_manifests
|
2017-11-01 22:25:35 +08:00
|
|
|
when: inventory_hostname == groups['kube-master'][0]
|
|
|
|
|
|
|
|
- name: Local Volume Provisioner | Apply manifests
|
|
|
|
kube:
|
2018-02-15 09:55:43 +08:00
|
|
|
namespace: "{{ local_volume_provisioner_namespace }}"
|
2018-02-01 14:14:18 +08:00
|
|
|
kubectl: "{{ bin_dir }}/kubectl"
|
2019-04-23 14:34:10 +08:00
|
|
|
filename: "{{ local_volume_provisioner_manifests.results | selectattr('skipped', 'undefined') | map(attribute='item') | map(attribute='file') | map('regex_replace', '^(.*)$', kube_config_dir+'/addons/local_volume_provisioner/\\1') | list }}"
|
2017-11-01 22:25:35 +08:00
|
|
|
state: "latest"
|
|
|
|
when: inventory_hostname == groups['kube-master'][0]
|