From 954f8fa90fe096c0c3966c1e64d3ba47faa048f0 Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Sun, 1 Oct 2023 10:16:25 +0200 Subject: [PATCH] feat!(mirrorbits-parent) use global values for umbrella storage and ingress. Breaking Change. Signed-off-by: Damien Duportal --- charts/mirrorbits-parent/Chart.yaml | 2 +- .../mirrorbits-parent/templates/ingress.yaml | 14 +- .../templates/persistentvolume.yaml | 12 +- .../templates/persistentvolumeclaim.yaml | 10 +- .../templates/persistentvolumesecret.yaml | 2 +- .../tests/custom_values_ingress_test.yaml | 108 ++++++++------- .../tests/custom_values_storage_test.yaml | 78 ++++++----- .../tests/defaults_storage_test.yaml | 5 +- charts/mirrorbits-parent/values.yaml | 126 +++++++++--------- 9 files changed, 185 insertions(+), 172 deletions(-) diff --git a/charts/mirrorbits-parent/Chart.yaml b/charts/mirrorbits-parent/Chart.yaml index 132a0683d..321261761 100644 --- a/charts/mirrorbits-parent/Chart.yaml +++ b/charts/mirrorbits-parent/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: mirrorbits-parent description: A mirrorbits parent chart for Kubernetes type: application -version: 0.2.3 +version: 1.0.0 dependencies: - name: mirrorbits-lite condition: mirrorbits-lite.enabled diff --git a/charts/mirrorbits-parent/templates/ingress.yaml b/charts/mirrorbits-parent/templates/ingress.yaml index a0922dec1..359675d4c 100644 --- a/charts/mirrorbits-parent/templates/ingress.yaml +++ b/charts/mirrorbits-parent/templates/ingress.yaml @@ -1,21 +1,21 @@ -{{- if .Values.ingress.enabled -}} +{{- if .Values.global.ingress.enabled -}} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ include "mirrorbits-parent.name" . }} labels: {{ include "mirrorbits-parents.labels" . | indent 4 }} - {{- with .Values.ingress.annotations }} + {{- with .Values.global.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: -{{- if .Values.ingress.className }} - ingressClassName: {{ .Values.ingress.className }} +{{- if .Values.global.ingress.className }} + ingressClassName: {{ .Values.global.ingress.className }} {{- end }} -{{- if .Values.ingress.tls }} +{{- if .Values.global.ingress.tls }} tls: - {{- range .Values.ingress.tls }} + {{- range .Values.global.ingress.tls }} - hosts: {{- range .hosts }} - {{ . | quote }} @@ -24,7 +24,7 @@ spec: {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} + {{- range .Values.global.ingress.hosts }} - host: {{ .host | quote }} http: paths: diff --git a/charts/mirrorbits-parent/templates/persistentvolume.yaml b/charts/mirrorbits-parent/templates/persistentvolume.yaml index 10b1c2933..067f898d7 100644 --- a/charts/mirrorbits-parent/templates/persistentvolume.yaml +++ b/charts/mirrorbits-parent/templates/persistentvolume.yaml @@ -1,4 +1,4 @@ -{{- if .Values.storage.enabled }} +{{- if .Values.global.storage.enabled }} --- apiVersion: v1 kind: PersistentVolume @@ -8,11 +8,11 @@ metadata: {{- include "mirrorbits-parents.labels" . | nindent 4 }} spec: accessModes: - {{- toYaml .Values.storage.accessModes | nindent 4 }} + {{- toYaml .Values.global.storage.accessModes | nindent 4 }} capacity: - storage: {{ .Values.storage.storageSize }} - storageClassName: {{ .Values.storage.storageClassName }} - {{- with .Values.storage.persistentVolume.azureFile }} + storage: {{ .Values.global.storage.storageSize }} + storageClassName: {{ .Values.global.storage.storageClassName }} + {{- with .Values.global.storage.persistentVolume.azureFile }} csi: driver: file.csi.azure.com nodeStageSecretRef: @@ -24,7 +24,7 @@ spec: volumeHandle: {{ include "mirrorbits-parent.name" $ }} readOnly: {{ .readOnly | default false }} {{- end }} - {{- with .Values.storage.persistentVolume.additionalSpec }} + {{- with .Values.global.storage.persistentVolume.additionalSpec }} {{- toYaml . | nindent 2 }} {{- end }} {{- end }} diff --git a/charts/mirrorbits-parent/templates/persistentvolumeclaim.yaml b/charts/mirrorbits-parent/templates/persistentvolumeclaim.yaml index b9aa3037e..62fd8de29 100644 --- a/charts/mirrorbits-parent/templates/persistentvolumeclaim.yaml +++ b/charts/mirrorbits-parent/templates/persistentvolumeclaim.yaml @@ -1,4 +1,4 @@ -{{- if .Values.storage.enabled }} +{{- if .Values.global.storage.enabled }} --- apiVersion: v1 kind: PersistentVolumeClaim @@ -9,12 +9,12 @@ metadata: spec: volumeName: {{ include "mirrorbits-parent.name" . }} accessModes: - {{- toYaml .Values.storage.accessModes | nindent 4 }} + {{- toYaml .Values.global.storage.accessModes | nindent 4 }} resources: requests: - storage: {{ .Values.storage.storageSize }} - storageClassName: {{ .Values.storage.storageClassName }} - {{- with .Values.storage.persistentVolumeClaim.additionalSpec }} + storage: {{ .Values.global.storage.storageSize }} + storageClassName: {{ .Values.global.storage.storageClassName }} + {{- with .Values.global.storage.persistentVolumeClaim.additionalSpec }} {{- toYaml . | nindent 2 }} {{- end }} {{- end }} diff --git a/charts/mirrorbits-parent/templates/persistentvolumesecret.yaml b/charts/mirrorbits-parent/templates/persistentvolumesecret.yaml index 9eaee59c3..32d0666ac 100644 --- a/charts/mirrorbits-parent/templates/persistentvolumesecret.yaml +++ b/charts/mirrorbits-parent/templates/persistentvolumesecret.yaml @@ -1,4 +1,4 @@ -{{ with .Values.storage.persistentVolume.azureFile -}} +{{ with .Values.global.storage.persistentVolume.azureFile -}} --- apiVersion: v1 kind: Secret diff --git a/charts/mirrorbits-parent/tests/custom_values_ingress_test.yaml b/charts/mirrorbits-parent/tests/custom_values_ingress_test.yaml index a26c92b0d..4219e361a 100644 --- a/charts/mirrorbits-parent/tests/custom_values_ingress_test.yaml +++ b/charts/mirrorbits-parent/tests/custom_values_ingress_test.yaml @@ -10,13 +10,14 @@ set: service: port: 8080 ## End of subchart mocked values - ingress: - enabled: true - hosts: - - host: company.org - paths: - - path: / - backendService: mirrorbits + global: + ingress: + enabled: true + hosts: + - host: company.org + paths: + - path: / + backendService: mirrorbits templates: - ingress.yaml tests: @@ -56,27 +57,28 @@ tests: - it: should create ingress with multiple hosts and multiple paths with full customized values template: ingress.yaml set: - ingress: - className: my-ingress-class - annotations: - 'app.kubernetes/whatever-with-chars': 'same/here-right' - hosts: - - host: company.org - paths: - - path: /.*[.](deb|hpi|war|rpm|msi|pkg|sha256|md5sum|zip|gz|pdf|json|svg|sh|jpeg|ico|png|html)$ - backendService: httpd - - path: / - backendService: mirrorbits - pathType: ImplementationSpecific - - host: fallback.company.org - paths: - - path: / - backendService: httpd - tls: - - secretName: ingress-tls - hosts: - - company.org - - fallback.company.org + global: + ingress: + className: my-ingress-class + annotations: + 'app.kubernetes/whatever-with-chars': 'same/here-right' + hosts: + - host: company.org + paths: + - path: /.*[.](deb|hpi|war|rpm|msi|pkg|sha256|md5sum|zip|gz|pdf|json|svg|sh|jpeg|ico|png|html)$ + backendService: httpd + - path: / + backendService: mirrorbits + pathType: ImplementationSpecific + - host: fallback.company.org + paths: + - path: / + backendService: httpd + tls: + - secretName: ingress-tls + hosts: + - company.org + - fallback.company.org asserts: - hasDocuments: count: 1 @@ -135,23 +137,25 @@ tests: - it: should fail the ingress when a host's path does not have backendService template: ingress.yaml set: - ingress: - hosts: - - host: company.org - paths: - - path: / + global: + ingress: + hosts: + - host: company.org + paths: + - path: / asserts: - failedTemplate: errorMessage: "Required key: backendService for ingress.hosts[].paths[] objects must have the value 'httpd' or 'mirrorbits'." - it: should fail the ingress when a host's path has an unknown backendService template: ingress.yaml set: - ingress: - hosts: - - host: company.org - paths: - - path: / - backendService: yipikai + global: + ingress: + hosts: + - host: company.org + paths: + - path: / + backendService: yipikai asserts: - failedTemplate: errorMessage: "Required key: backendService for ingress.hosts[].paths[] objects must have the value 'httpd' or 'mirrorbits'." @@ -160,12 +164,13 @@ tests: set: httpd: enabled: false - ingress: - hosts: - - host: company.org - paths: - - path: / - backendService: httpd + global: + ingress: + hosts: + - host: company.org + paths: + - path: / + backendService: httpd asserts: - failedTemplate: errorMessage: "Cannot use httpd as backend if it is disabled." @@ -174,12 +179,13 @@ tests: set: mirrorbits-lite: enabled: false - ingress: - hosts: - - host: company.org - paths: - - path: / - backendService: mirrorbits + global: + ingress: + hosts: + - host: company.org + paths: + - path: / + backendService: mirrorbits asserts: - failedTemplate: errorMessage: "Cannot use mirrorbits(-lite) as backend if it is disabled." diff --git a/charts/mirrorbits-parent/tests/custom_values_storage_test.yaml b/charts/mirrorbits-parent/tests/custom_values_storage_test.yaml index b048dcfb3..d31aa5443 100644 --- a/charts/mirrorbits-parent/tests/custom_values_storage_test.yaml +++ b/charts/mirrorbits-parent/tests/custom_values_storage_test.yaml @@ -1,21 +1,22 @@ suite: Tests with custom values set: - storage: - enabled: true - storageClassName: super-fast-storage - storageSize: 510Gi - accessModes: - - ReadWriteMany - - ReadOnlyMany - - ReadWriteOnce - persistentVolume: - additionalSpec: - persistentVolumeReclaimPolicy: Retain - mountOptions: - - dir_mode=0755 - persistentVolumeClaim: - additionalSpec: - volumeMode: Block + global: + storage: + enabled: true + storageClassName: super-fast-storage + storageSize: 510Gi + accessModes: + - ReadWriteMany + - ReadOnlyMany + - ReadWriteOnce + persistentVolume: + additionalSpec: + persistentVolumeReclaimPolicy: Retain + mountOptions: + - dir_mode=0755 + persistentVolumeClaim: + additionalSpec: + volumeMode: Block templates: - persistentvolume.yaml - persistentvolumeclaim.yaml @@ -88,14 +89,15 @@ tests: - it: should provide an azurefile CSI PV with customized values if specified template: persistentvolume.yaml set: - storage: - persistentVolume: - azureFile: - resourceGroup: storage-rg - storageAccountName: storage-account - shareName: storage-share - storageAccountKey: StorageAccountSuperSecretKey - readOnly: true + global: + storage: + persistentVolume: + azureFile: + resourceGroup: storage-rg + storageAccountName: storage-account + shareName: storage-share + storageAccountKey: StorageAccountSuperSecretKey + readOnly: true asserts: - hasDocuments: count: 1 @@ -131,14 +133,15 @@ tests: - it: should not create any persistent volume secret template: persistentvolumesecret.yaml set: - storage: - persistentVolume: - azureFile: - resourceGroup: storage-rg - storageAccountName: storage-account - shareName: storage-share - storageAccountKey: 'StorageAccountSuperSecretKey!2023' - readOnly: true + global: + storage: + persistentVolume: + azureFile: + resourceGroup: storage-rg + storageAccountName: storage-account + shareName: storage-share + storageAccountKey: 'StorageAccountSuperSecretKey!2023' + readOnly: true asserts: - hasDocuments: count: 1 @@ -158,11 +161,12 @@ tests: release: name: rindfleischetikettierunguberwachungsaufgabenubertrags # 53 chars is the longest possible release name set: - storage: - persistentVolume: - azureFile: - storageAccountName: storage-account - storageAccountKey: 'StorageAccountSuperSecretKey!2023' + global: + storage: + persistentVolume: + azureFile: + storageAccountName: storage-account + storageAccountKey: 'StorageAccountSuperSecretKey!2023' asserts: - hasDocuments: count: 1 diff --git a/charts/mirrorbits-parent/tests/defaults_storage_test.yaml b/charts/mirrorbits-parent/tests/defaults_storage_test.yaml index 449d7004c..5b5ebf6fb 100644 --- a/charts/mirrorbits-parent/tests/defaults_storage_test.yaml +++ b/charts/mirrorbits-parent/tests/defaults_storage_test.yaml @@ -5,8 +5,9 @@ templates: - persistentvolumesecret.yaml ## Only enable storage set: - storage: - enabled: true + global: + storage: + enabled: true tests: - it: should not create any persistent volume secret template: persistentvolumesecret.yaml diff --git a/charts/mirrorbits-parent/values.yaml b/charts/mirrorbits-parent/values.yaml index d28aafabc..d5fa3159c 100644 --- a/charts/mirrorbits-parent/values.yaml +++ b/charts/mirrorbits-parent/values.yaml @@ -1,69 +1,71 @@ -## Global ingress -ingress: - enabled: false - ## Specify a custom Ingress Class (default: unspecified to rely on your cluster default) - # className: my-ingress-class +# The top-level keyword 'global' is required to share data to subcharts +global: + ## Global ingress + ingress: + enabled: false + ## Specify a custom Ingress Class (default: unspecified to rely on your cluster default) + # className: my-ingress-class - ## Define custom annotations on the Ingress object (default: undefined) - # annotations: - # foo: bar + ## Define custom annotations on the Ingress object (default: undefined) + # annotations: + # foo: bar - ## Define custom hosts for this ingress (default: undefined) - ## Note: the "path" objects allows defining which path matches which backend webservice component (possible values: mirrorbits or httpd) - # hosts: - # - host: company.org - # paths: - # # Send requests matching the pattern defined for 'path' to the http backend service - # - path: /.*[.](deb|hpi|war|rpm|msi|pkg|sha256|md5sum|zip|gz|pdf|json|svg|sh|jpeg|ico|png|html)$ - # ## Note: the "path" objects allows defining which path matches which backend webservice component (possible values: mirrorbits or httpd) - # backendService: httpd - # # Send requests matching the pattern '/' (e.g. default fallback for most ingresses) to the mirrorbits backend service - # - path: / - # ## Note: the "path" objects allows defining which path matches which backend webservice component (possible values: mirrorbits or httpd) - # backendService: mirrorbits - ## Define ingress TLS management for HTTPS - # tls: - # - secretName: ingress-tls - # hosts: - # - company.org + ## Define custom hosts for this ingress (default: undefined) + ## Note: the "path" objects allows defining which path matches which backend webservice component (possible values: mirrorbits or httpd) + # hosts: + # - host: company.org + # paths: + # # Send requests matching the pattern defined for 'path' to the http backend service + # - path: /.*[.](deb|hpi|war|rpm|msi|pkg|sha256|md5sum|zip|gz|pdf|json|svg|sh|jpeg|ico|png|html)$ + # ## Note: the "path" objects allows defining which path matches which backend webservice component (possible values: mirrorbits or httpd) + # backendService: httpd + # # Send requests matching the pattern '/' (e.g. default fallback for most ingresses) to the mirrorbits backend service + # - path: / + # ## Note: the "path" objects allows defining which path matches which backend webservice component (possible values: mirrorbits or httpd) + # backendService: mirrorbits + ## Define ingress TLS management for HTTPS + # tls: + # - secretName: ingress-tls + # hosts: + # - company.org -## Persistent Storage used across components -storage: - ## Manage (and reuse) PV + PVC for all components - enabled: false - ## Define a custom storage class - storageClassName: default - # storageClassName: azurefile-csi-premium - ## Define a custom storage size (both PV and PVC) - storageSize: 1Gi - ## Define the set of access modes available for the persistent volume and its claim - accessModes: - - ReadOnlyMany - persistentVolume: - ## This chart usually runs on Azure with an Azurefile as a persistent volume. - ## Use the following section to define the secret and CSI specification for the PV. - # azureFile: - # resourceGroup: storage-rg - # storageAccountName: storage-account - # shareName: storage-share - # storageAccountKey: StorageAccountSuperSecretKey - # readOnly: false - ## Additional custom spec added at the end of the generated PV `spec` section. - ## User is responsible to not duplicate existing (helm template is your friend). - additionalSpec: {} - # additionalSpec: - # persistentVolumeReclaimPolicy: Retain - # mountOptions: - # - dir_mode=0755 - # - ... + ## Persistent Storage used across components + storage: + ## Manage (and reuse) PV + PVC for all components + enabled: false + ## Define a custom storage class + storageClassName: default + # storageClassName: azurefile-csi-premium + ## Define a custom storage size (both PV and PVC) + storageSize: 1Gi + ## Define the set of access modes available for the persistent volume and its claim + accessModes: + - ReadOnlyMany + persistentVolume: + ## This chart usually runs on Azure with an Azurefile as a persistent volume. + ## Use the following section to define the secret and CSI specification for the PV. + # azureFile: + # resourceGroup: storage-rg + # storageAccountName: storage-account + # shareName: storage-share + # storageAccountKey: StorageAccountSuperSecretKey + # readOnly: false + ## Additional custom spec added at the end of the generated PV `spec` section. + ## User is responsible to not duplicate existing (helm template is your friend). + additionalSpec: {} + # additionalSpec: + # persistentVolumeReclaimPolicy: Retain + # mountOptions: + # - dir_mode=0755 + # - ... - persistentVolumeClaim: - ## Additional custom spec added at the end of the generated PVC `spec` section. - ## User is responsible to not duplicate existing (helm template is your friend). - additionalSpec: {} - # additionalSpec: - # volumeMode: Filesystem - # ... + persistentVolumeClaim: + ## Additional custom spec added at the end of the generated PVC `spec` section. + ## User is responsible to not duplicate existing (helm template is your friend). + additionalSpec: {} + # additionalSpec: + # volumeMode: Filesystem + # ... ## Sub charts specific values mirrorbits-lite: