From 01daa9c47b8906309bab63068c3d28c2ac16b448 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Tue, 8 Jun 2021 15:29:41 +0200 Subject: [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 --- ansible/roles/k8s-persistent-volume/defaults/main.yml | 5 +++++ ansible/roles/k8s-persistent-volume/tasks/main.yml | 11 +++++++++++ ansible/roles/k8s-persistent-volume/templates/pv.yaml.j2 | 15 +++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 ansible/roles/k8s-persistent-volume/defaults/main.yml create mode 100644 ansible/roles/k8s-persistent-volume/tasks/main.yml create mode 100644 ansible/roles/k8s-persistent-volume/templates/pv.yaml.j2 (limited to 'ansible') 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: "" -- cgit 1.2.3-korg