summaryrefslogtreecommitdiffstats
path: root/roles/ands_kaas/templates/00-block-volumes.yml.j2
blob: f313699945cd3c22a72b0a78ba4df33c895b13d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
apiVersion: v1
kind: Template
metadata:
  name: {{ kaas_project }}-block-volumes
  annotations:
    descriptions: "{{ kaas_project }} glusterfs block volumes"
objects:
{% for name, vol in kaas_block_volumes.items() %}
{% set oc_name = vol.name | default(name) | regex_replace('_','-') %}
{% if oc_name | regex_search("^" + kaas_project) %}
{%   set pvname = oc_name %}
{% else %}
{%   set pvname = (kaas_project + "-" + oc_name) | regex_replace('_','-') %}
{% endif %}
  - apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: {{ pvname }}
    spec:
      persistentVolumeReclaimPolicy: Retain 
      accessModes:
        - ReadWriteOnce
      iscsi:
        fsType: xfs
        iqn: iqn.2016-12.org.gluster-block:{{ kaas_block_iqn[name] }}
        iscsiInterface: default
        lun: 0
        targetPortal: {{ kaas_block_portals[name][0] }}
{% if kaas_block_portals[name] | length > 1 %}
        portals: {{ kaas_block_portals[name][1:] | to_json }}
{% endif %}
      capacity:
        storage: {{ vol.capacity | default(kaas_default_volume_capacity) }}
      claimRef:
        name: {{ oc_name }}
        namespace: {{ kaas_project }}
  - apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: {{ oc_name }}
    spec:
      volumeName: {{ pvname }}
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: {{ vol.capacity | default(kaas_default_volume_capacity) }}
{% endfor %}