diff options
author | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2021-06-08 15:29:41 +0200 |
---|---|---|
committer | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2021-06-08 15:29:41 +0200 |
commit | 01daa9c47b8906309bab63068c3d28c2ac16b448 (patch) | |
tree | 547182c1975aa9324ac7789e3fdcec408657a39a | |
parent | 9519958511ef093fac6febab03bd282c267b106a (diff) |
[ANSIBLE] Add 'k8s-persistent-volume' role
This role will setup predefined k8s persistent volumes. It leverages
the community.kubernetes.k8s ansible module.
Change-Id: If71481b6b0da60872498063ff29c8da5a3830fc5
Issue-ID: INT-1926
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
-rw-r--r-- | ansible/roles/k8s-persistent-volume/defaults/main.yml | 5 | ||||
-rw-r--r-- | ansible/roles/k8s-persistent-volume/tasks/main.yml | 11 | ||||
-rw-r--r-- | ansible/roles/k8s-persistent-volume/templates/pv.yaml.j2 | 15 |
3 files changed, 31 insertions, 0 deletions
diff --git a/ansible/roles/k8s-persistent-volume/defaults/main.yml b/ansible/roles/k8s-persistent-volume/defaults/main.yml new file mode 100644 index 00000000..5260db11 --- /dev/null +++ b/ansible/roles/k8s-persistent-volume/defaults/main.yml @@ -0,0 +1,5 @@ +--- +k8s_volumes: + - name: kube-prometheus + capacity: "6Gi" + path_prefix: "{{ nfs_mount_path }}" diff --git a/ansible/roles/k8s-persistent-volume/tasks/main.yml b/ansible/roles/k8s-persistent-volume/tasks/main.yml new file mode 100644 index 00000000..94f4e0b3 --- /dev/null +++ b/ansible/roles/k8s-persistent-volume/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- name: Install OpenShift Python client library # community.kubernetes.k8s module dependency + package: + name: 'python2-openshift' + state: present + +- name: Create k8s persistent volumes + community.kubernetes.k8s: + wait: True + template: pv.yaml.j2 + loop: "{{ k8s_volumes }}" diff --git a/ansible/roles/k8s-persistent-volume/templates/pv.yaml.j2 b/ansible/roles/k8s-persistent-volume/templates/pv.yaml.j2 new file mode 100644 index 00000000..979ef2c6 --- /dev/null +++ b/ansible/roles/k8s-persistent-volume/templates/pv.yaml.j2 @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: {{ item.name }} +spec: + capacity: + storage: {{ item.capacity }} + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: {{ item.name }} + hostPath: + path: {{ item.path_prefix }}/{{ item.name }} + type: "" |