Skip to content

Commit

Permalink
✨(apps) add variable to customize PVC name (#780)
Browse files Browse the repository at this point in the history
The NAS migration will change the PVC name, but the PVC name are hard coded
in the resource definition. For all PVC a variable is add to allow the override
the persistent volume name or use the original name.
  • Loading branch information
claudusd authored Aug 28, 2023
1 parent 681dba5 commit 12dc914
Show file tree
Hide file tree
Showing 49 changed files with 90 additions and 52 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

### Changed

- Add variables to override persistent volume names

## [6.18.0] - 2023-07-03

### Changed
Expand Down
4 changes: 2 additions & 2 deletions apps/ashley/templates/services/app/deploy.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ spec:
{% if ashley_should_activate_media_volume %}
- name: ashley-v-media
persistentVolumeClaim:
claimName: ashley-pvc-media
claimName: "{{ ashley_pvc_media_name }}"
{% endif %}
{% if ashley_should_activate_static_volume %}
- name: ashley-v-static
persistentVolumeClaim:
claimName: ashley-pvc-static
claimName: "{{ ashley_pvc_static_name }}"
{% endif %}
securityContext:
runAsUser: {{ container_uid }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ spec:
name: ashley-app-{{ deployment_stamp }}
- name: ashley-v-static
persistentVolumeClaim:
claimName: ashley-pvc-static
claimName: "{{ ashley_pvc_static_name }}"
{% endif %}
securityContext:
runAsUser: {{ container_uid }}
Expand Down
4 changes: 2 additions & 2 deletions apps/ashley/templates/services/nginx/deploy.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ spec:
{% if ashley_should_activate_media_volume %}
- name: ashley-v-media
persistentVolumeClaim:
claimName: ashley-pvc-media
claimName: "{{ ashley_pvc_media_name }}"
{% endif %}
{% if ashley_should_activate_static_volume %}
- name: ashley-v-static
persistentVolumeClaim:
claimName: ashley-pvc-static
claimName: "{{ ashley_pvc_static_name }}"
{% endif %}
{% if activate_http_basic_auth or ashley_activate_http_basic_auth %}
- name: ashley-htpasswd
Expand Down
2 changes: 1 addition & 1 deletion apps/ashley/templates/volumes/media.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ashley-pvc-media
name: "{{ ashley_pvc_media_name }}"
namespace: "{{ namespace_name }}"
labels:
app: ashley
Expand Down
2 changes: 1 addition & 1 deletion apps/ashley/templates/volumes/static.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ashley-pvc-static
name: "{{ ashley_pvc_static_name }}"
namespace: "{{ namespace_name }}"
labels:
app: ashley
Expand Down
2 changes: 2 additions & 0 deletions apps/ashley/vars/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ ashley_media_volume_size: 2Gi
ashley_static_volume_size: 1Gi
ashley_should_activate_media_volume: true
ashley_should_activate_static_volume: true
ashley_pvc_media_name: "ashley-pvc-media"
ashley_pvc_static_name: "ashley-pvc-static"

# -- resources requests
{% set app_resources = {
Expand Down
8 changes: 4 additions & 4 deletions apps/edxapp/templates/services/cms/_deploy_base.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ spec:
secretName: "{{ edxapp_secret_name }}"
- name: edxapp-v-media
persistentVolumeClaim:
claimName: "{{ edxapp_pvc_media_name | default("edxapp-pvc-media") }}"
claimName: "{{ edxapp_pvc_media_name }}"
- name: edxapp-v-data
persistentVolumeClaim:
claimName: edxapp-pvc-data
claimName: "{{ edxapp_pvc_data_name }}"
- name: edxapp-v-export
persistentVolumeClaim:
claimName: edxapp-pvc-export
claimName: "{{ edxapp_pvc_export_name }}"
{% if edxapp_should_update_i18n %}
- name: edxapp-v-locale
persistentVolumeClaim:
claimName: edxapp-pvc-locale
claimName: "{{ edxapp_pvc_locale_name }}"
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ spec:
volumes:
- name: edxapp-v-media
persistentVolumeClaim:
claimName: "{{ edxapp_pvc_media_name | default("edxapp-pvc-media") }}"
claimName: "{{ edxapp_pvc_media_name }}"
- name: edxapp-v-data
persistentVolumeClaim:
claimName: edxapp-pvc-data
claimName: "{{ edxapp_pvc_data_name }}"
- name: edxapp-v-export
persistentVolumeClaim:
claimName: edxapp-pvc-export
claimName: "{{ edxapp_pvc_export_name }}"
{% if edxapp_should_update_i18n %}
- name: edxapp-v-locale
persistentVolumeClaim:
claimName: edxapp-pvc-locale
claimName: "{{ edxapp_pvc_locale_name }}"
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ spec:
volumes:
- name: edxapp-v-locale
persistentVolumeClaim:
claimName: edxapp-pvc-locale
claimName: "{{ edxapp_pvc_locale_name }}"
restartPolicy: Never
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ spec:
secretName: "{{ edxapp_secret_name }}"
- name: edxapp-v-media
persistentVolumeClaim:
claimName: "{{ edxapp_pvc_media_name | default("edxapp-pvc-media") }}"
claimName: "{{ edxapp_pvc_media_name }}"
restartPolicy: Never
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ spec:
secretName: "{{ edxapp_secret_name }}"
- name: edxapp-v-media
persistentVolumeClaim:
claimName: "{{ edxapp_pvc_media_name | default("edxapp-pvc-media") }}"
claimName: "{{ edxapp_pvc_media_name }}"
- name: edxapp-v-data
persistentVolumeClaim:
claimName: edxapp-pvc-data
claimName: "{{ edxapp_pvc_data_name }}"
restartPolicy: Never
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ spec:
secretName: "{{ edxapp_secret_name }}"
- name: edxapp-v-media
persistentVolumeClaim:
claimName: "{{ edxapp_pvc_media_name | default("edxapp-pvc-media") }}"
claimName: "{{ edxapp_pvc_media_name }}"
restartPolicy: Never
4 changes: 2 additions & 2 deletions apps/edxapp/templates/services/nginx/deploy.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ spec:
name: "edxapp-nginx-{{ deployment_stamp }}"
- name: edxapp-v-media
persistentVolumeClaim:
claimName: "{{ edxapp_pvc_media_name | default("edxapp-pvc-media") }}"
claimName: "{{ edxapp_pvc_media_name }}"
- name: edxapp-v-export
persistentVolumeClaim:
claimName: edxapp-pvc-export
claimName: "{{ edxapp_pvc_export_name }}"
{% if activate_http_basic_auth or edxapp_activate_http_basic_auth -%}
- name: edxapp-htpasswd
secret:
Expand Down
2 changes: 1 addition & 1 deletion apps/edxapp/templates/volumes/data.yml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: edxapp-pvc-data
name: "{{ edxapp_pvc_data_name }}"
namespace: "{{ namespace_name }}"
labels:
app: edxapp
Expand Down
2 changes: 1 addition & 1 deletion apps/edxapp/templates/volumes/export.yml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: edxapp-pvc-export
name: "{{ edxapp_pvc_export_name }}"
namespace: "{{ namespace_name }}"
labels:
app: edxapp
Expand Down
2 changes: 1 addition & 1 deletion apps/edxapp/templates/volumes/locale.yml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: edxapp-pvc-locale
name: "{{ edxapp_pvc_locale_name }}"
namespace: "{{ namespace_name }}"
labels:
app: edxapp
Expand Down
2 changes: 1 addition & 1 deletion apps/edxapp/templates/volumes/media.yml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: "{{ edxapp_pvc_media_name | default("edxapp-pvc-media") }}"
name: "{{ edxapp_pvc_media_name }}"
namespace: "{{ namespace_name }}"
labels:
app: edxapp
Expand Down
10 changes: 10 additions & 0 deletions apps/edxapp/vars/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ edxapp_i18n_languages:
- fr
edxapp_tx_secret_name: "edxapp-tx-{{ edxapp_vault_checksum | default('undefined_edxapp_vault_checksum') }}"

# -- pvc
# Persitent volume name use for media
edxapp_pvc_media_name: "edxapp-pvc-media"
edxapp_pvc_data_name: "edxapp-pvc-data"
edxapp_pvc_export_name: "edxapp-pvc-export"
edxapp_pvc_locale_name: "edxapp-pvc-locale"

# -- volumes


# -- volumes size
edxapp_data_volume_size: 2Gi
edxapp_media_volume_size: 2Gi
Expand Down
4 changes: 2 additions & 2 deletions apps/edxec/templates/services/app/deploy.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ spec:
secretName: "{{ edxec_secret_name }}"
- name: edxec-v-media
persistentVolumeClaim:
claimName: edxec-pvc-media
claimName: "{{ edxec_pvc_media_name }}"
- name: edxec-v-static
persistentVolumeClaim:
claimName: edxec-pvc-static
claimName: "{{ edxec_pvc_static_name }}"
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ spec:
secretName: "{{ edxec_secret_name }}"
- name: edxec-v-static
persistentVolumeClaim:
claimName: edxec-pvc-static
claimName: "{{ edxec_pvc_static_name }}"
restartPolicy: Never
4 changes: 2 additions & 2 deletions apps/edxec/templates/services/nginx/deploy.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ spec:
name: edxec-nginx-{{ deployment_stamp }}
- name: edxec-v-media
persistentVolumeClaim:
claimName: edxec-pvc-media
claimName: "{{ edxec_pvc_media_name }}"
- name: edxec-v-static
persistentVolumeClaim:
claimName: edxec-pvc-static
claimName: "{{ edxec_pvc_static_name }}"
{% if activate_http_basic_auth or edxec_activate_http_basic_auth %}
- name: edxec-htpasswd
secret:
Expand Down
2 changes: 1 addition & 1 deletion apps/edxec/templates/volumes/media.yml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: edxec-pvc-media
name: "{{ edxec_pvc_media_name }}"
namespace: "{{ namespace_name }}"
labels:
app: edxec
Expand Down
2 changes: 1 addition & 1 deletion apps/edxec/templates/volumes/static.yml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: edxec-pvc-static
name: "{{ edxec_pvc_static_name }}"
namespace: "{{ namespace_name }}"
labels:
app: edxec
Expand Down
4 changes: 4 additions & 0 deletions apps/edxec/vars/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ edxec_mysql_image_tag: "5.7"
edxec_mysql_port: 3306
edxec_mysql_secret_name: "edxec-mysql-{{ edxec_vault_checksum | default('undefined_edxec_vault_checksum') }}"

# -- pvc
edxec_pvc_media_name: "edxec-pvc-media"
edxec_pvc_static_name: "edxec-pvc-static"

# -- volumes size
edxec_static_volume_size: 2Gi
edxec_media_volume_size: 2Gi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ spec:
{% if elasticsearch_security_enabled %}
- name: elasticsearch-v-bootstrap
persistentVolumeClaim:
claimName: elasticsearch-pvc-bootstrap
claimName: "{{ elasticsearch_pvc_bootstrap_name }}"
{% endif %}
securityContext:
runAsUser: {{ elasticsearch_container_uid }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spec:
path: set-passwords.sh
- name: elasticsearch-v-bootstrap
persistentVolumeClaim:
claimName: elasticsearch-pvc-bootstrap
claimName: "{{ elasticsearch_pvc_bootstrap_name }}"
securityContext:
runAsUser: {{ elasticsearch_container_uid }}
runAsGroup: {{ elasticsearch_container_gid }}
Expand Down
4 changes: 2 additions & 2 deletions apps/elasticsearch/templates/services/app/sts.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ spec:
secretName: "{{ elasticsearch_ca_secret_name }}"
- name: elasticsearch-v-bootstrap
persistentVolumeClaim:
claimName: elasticsearch-pvc-bootstrap
claimName: "{{ elasticsearch_pvc_bootstrap_name }}"
- name: config-dir
emptyDir: {}
{% endif %}
Expand All @@ -182,7 +182,7 @@ spec:
{% if elasticsearch_persistent_volume_enabled %}
volumeClaimTemplates:
- metadata:
name: elasticsearch-pvc-data
name: "{{ elasticsearch_pvc_bootstrap_name }}"
labels:
app: elasticsearch
spec:
Expand Down
2 changes: 1 addition & 1 deletion apps/elasticsearch/templates/volumes/bootstrap.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: elasticsearch-pvc-bootstrap
name: "{{ elasticsearch_pvc_bootstrap_name }}"
namespace: "{{ namespace_name }}"
labels:
app: elasticsearch
Expand Down
1 change: 1 addition & 0 deletions apps/elasticsearch/vars/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ elasticsearch_credentials_secret_name: "elasticsearch-credentials-{{ elasticsear
elasticsearch_persistent_volume_enabled: false
elasticsearch_persistent_volume_size: 1Gi
elasticsearch_persistent_volume_storageclass: "{{ default_storage_class_rwo }}"
elasticsearch_pvc_bootstrap_name: "elasticsearch-pvc-bootstrap"

# -- resources requests
elasticsearch_app_resources:
Expand Down
2 changes: 1 addition & 1 deletion apps/hello/templates/services/app/job_writevolume.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
volumes:
- name: hello-volume
persistentVolumeClaim:
claimName: hello-pvc
claimName: "{{ hello_pvc_hello_volume_name }}"
restartPolicy: Never
securityContext:
runAsUser: {{ container_uid }}
Expand Down
2 changes: 1 addition & 1 deletion apps/hello/templates/volumes/hello.yml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hello-pvc
name: "{{ hello_pvc_hello_volume_name }}"
namespace: "{{ namespace_name }}"
labels:
app: hello
Expand Down
3 changes: 3 additions & 0 deletions apps/hello/vars/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ hello_app_msg: "Hello Kubernetes! by Arnold"
hello_app_resources: "{{ app_resources }}"
hello_app_job_writevolume_resources: "{{ app_resources }}"
hello_app_cronjob_resources: "{{ app_resources }}"

# -- pvc
hello_pvc_hello_volume_name: "hello-pvc"
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spec:
volumes:
- name: nextcloud-v-install
persistentVolumeClaim:
claimName: nextcloud-pvc-install
claimName: "{{ nextcloud_pvc_install_name }}"
securityContext:
runAsUser: {{ container_uid }}
runAsGroup: {{ container_gid }}
2 changes: 1 addition & 1 deletion apps/nextcloud/templates/volumes/install.yml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nextcloud-pvc-install
name: "{{ nextcloud_pvc_install_name }}"
namespace: "{{ namespace_name }}"
labels:
app: nextcloud
Expand Down
1 change: 1 addition & 0 deletions apps/nextcloud/vars/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ nextcloud_container_home_dir: "/home/openfun"

# -- volumes
nextcloud_install_volume_size: 2Mi
nextcloud_pvc_install_name: "nextcloud-pvc-install"

# -- resources requests
{% set app_resources = {
Expand Down
2 changes: 1 addition & 1 deletion apps/prosody/templates/services/app/deploy.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ spec:
{% if prosody_storage == "internal" %}
- name: prosody-v-storage
persistentVolumeClaim:
claimName: prosody-pvc-storage
claimName: "{{ prosody_pvc_storage_name }}"
{% endif %}
2 changes: 1 addition & 1 deletion apps/prosody/templates/volumes/storage.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: prosody-pvc-storage
name: "{{ prosody_pvc_storage_name }}"
namespace: "{{ namespace_name }}"
labels:
app: prosody
Expand Down
Loading

0 comments on commit 12dc914

Please sign in to comment.