summaryrefslogtreecommitdiffstats
path: root/ansible/roles
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/roles')
-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: ""