summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2021-06-08 15:29:41 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2021-06-08 15:29:41 +0200
commit01daa9c47b8906309bab63068c3d28c2ac16b448 (patch)
tree547182c1975aa9324ac7789e3fdcec408657a39a
parent9519958511ef093fac6febab03bd282c267b106a (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.yml5
-rw-r--r--ansible/roles/k8s-persistent-volume/tasks/main.yml11
-rw-r--r--ansible/roles/k8s-persistent-volume/templates/pv.yaml.j215
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: ""