summaryrefslogtreecommitdiffstats
path: root/ansible/roles/k8s-persistent-volume
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2021-06-29 08:25:01 +0000
committerGerrit Code Review <gerrit@onap.org>2021-06-29 08:25:01 +0000
commit76cd106951044a14b6c01db795f2681be55e7b58 (patch)
treecc2339b0029e747c75c4088ae50111cd89fc33a7 /ansible/roles/k8s-persistent-volume
parente71891de4c8caacb69efcfef622b94f52790c99c (diff)
parent078316368cfceaa77c1357ab058ad7e55164fabc (diff)
Merge changes from topic "kube-prometheus-stack"
* changes: [ANSIBLE] Increase Helm install timeout for kube-prometheus application [ANSIBLE] Create a NodePort type service for Grafana dashboard [DOC] Add documentation for kube-prometheus stack [BUILD] Add Kube Prometheus Stack docker image list to default image list [BUILD] Add 'busybox' image to kube-prometheus data list [ANSIBLE] Update custom Grafana dashboard [ANSIBLE] Configure custom Grafana dashboard [ANSIBLE] Setup persistent volume for Grafana dashboards [TOOLS] Fix helm-healer.sh usage description [ANSIBLE] Add 'nfs' playbook [ANSIBLE] Generate helm values file for kube-prometheus stack [ANSIBLE] Create host paths for PVs and set their permissions [BUILD] Add the 'python2-openshift' package [ANSIBLE] Play the 'k8s-persistent-volume' role in 'kube_prometheus' playbook [ANSIBLE] Add 'k8s-persistent-volume' role [MOLECULE] Add setup for new 'k8s-persistent-volume' role [ANSIBLE] Setup kube-prometheus-stack role [MOLECULE] Setup Molecule for kube-prometheus-stack role [MOLECULE] Add prepare-kube-prometheus-stack role [ANSIBLE] Set default kube-prometheus-stack version [ANSIBLE] Add kube_prometheus playbook [ANSIBLE] Add 'kube-prometheus-stack' role skeleton [BUILD] Symlink kube-prometheus-stack tgz file while creating offline package [BUILD] Add kube-prometheus-stack helm chart package http resource url [BUILD] Add datalist file for kube-prometheus-stack
Diffstat (limited to 'ansible/roles/k8s-persistent-volume')
-rw-r--r--ansible/roles/k8s-persistent-volume/.yamllint12
-rw-r--r--ansible/roles/k8s-persistent-volume/defaults/main.yml10
-rw-r--r--ansible/roles/k8s-persistent-volume/molecule/default/converge.yml12
-rw-r--r--ansible/roles/k8s-persistent-volume/molecule/default/molecule.yml23
-rw-r--r--ansible/roles/k8s-persistent-volume/molecule/default/vars.yml2
-rw-r--r--ansible/roles/k8s-persistent-volume/tasks/main.yml19
-rw-r--r--ansible/roles/k8s-persistent-volume/templates/pv.yaml.j215
7 files changed, 93 insertions, 0 deletions
diff --git a/ansible/roles/k8s-persistent-volume/.yamllint b/ansible/roles/k8s-persistent-volume/.yamllint
new file mode 100644
index 00000000..c5ae64be
--- /dev/null
+++ b/ansible/roles/k8s-persistent-volume/.yamllint
@@ -0,0 +1,12 @@
+---
+extends: default
+
+rules:
+ braces:
+ max-spaces-inside: 1
+ level: error
+ brackets:
+ max-spaces-inside: 1
+ level: error
+ line-length: disable
+ truthy: disable
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..de387323
--- /dev/null
+++ b/ansible/roles/k8s-persistent-volume/defaults/main.yml
@@ -0,0 +1,10 @@
+---
+k8s_volumes:
+ - name: kube-prometheus-prometheus
+ capacity: "6Gi"
+ path_prefix: "{{ nfs_mount_path }}/kube-prometheus"
+ owner: 1000 # derived from prometheus.prometheusSpec.securityContext.runAsUser
+ group: 2000 # derived from prometheus.prometheusSpec.securityContext.fsGroup
+ - name: kube-prometheus-grafana
+ capacity: "4Gi"
+ path_prefix: "{{ nfs_mount_path }}/kube-prometheus"
diff --git a/ansible/roles/k8s-persistent-volume/molecule/default/converge.yml b/ansible/roles/k8s-persistent-volume/molecule/default/converge.yml
new file mode 100644
index 00000000..4e15b3c8
--- /dev/null
+++ b/ansible/roles/k8s-persistent-volume/molecule/default/converge.yml
@@ -0,0 +1,12 @@
+---
+- name: Converge
+ hosts: all
+ pre_tasks:
+ - name: Include kubernetes group variables
+ include_vars: ../../../../group_vars/kubernetes.yml
+ - name: Include test scenario variables
+ include_vars: vars.yml
+ tasks:
+ - name: "Include k8s-persistent-volume"
+ include_role:
+ name: "k8s-persistent-volume"
diff --git a/ansible/roles/k8s-persistent-volume/molecule/default/molecule.yml b/ansible/roles/k8s-persistent-volume/molecule/default/molecule.yml
new file mode 100644
index 00000000..dbbf0d81
--- /dev/null
+++ b/ansible/roles/k8s-persistent-volume/molecule/default/molecule.yml
@@ -0,0 +1,23 @@
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint: |
+ set -e
+ yamllint .
+ ansible-lint .
+ flake8
+platforms:
+ - name: infrastructure-k8s-persistent-volume
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6}
+ pre_build_image: true
+ groups:
+ - infrastructure
+provisioner:
+ name: ansible
+ env:
+ ANSIBLE_ROLES_PATH: ../../../../test/roles
+ ANSIBLE_LIBRARY: ../../../../library
+verifier:
+ name: testinfra
diff --git a/ansible/roles/k8s-persistent-volume/molecule/default/vars.yml b/ansible/roles/k8s-persistent-volume/molecule/default/vars.yml
new file mode 100644
index 00000000..ce473376
--- /dev/null
+++ b/ansible/roles/k8s-persistent-volume/molecule/default/vars.yml
@@ -0,0 +1,2 @@
+---
+k8s_volumes: []
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..8428857f
--- /dev/null
+++ b/ansible/roles/k8s-persistent-volume/tasks/main.yml
@@ -0,0 +1,19 @@
+---
+- 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 }}"
+
+- name: Create host paths for PVs and set their permissions
+ file:
+ path: "{{ item.path_prefix }}/{{ item.name }}"
+ state: directory
+ owner: "{{ item.owner | default(0) }}"
+ group: "{{ item.group | default(0) }}"
+ 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: ""