diff --git a/charts/kong/CHANGELOG.md b/charts/kong/CHANGELOG.md index d99c8f63f..81a9d490b 100644 --- a/charts/kong/CHANGELOG.md +++ b/charts/kong/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased * Added serviceMonitor.trustCRDsExist for render based deployments +* Add support for `excludeMigrationPod` to userDefinedVolumes and userDefinedVolumeMounts ### Changes diff --git a/charts/kong/templates/_helpers.tpl b/charts/kong/templates/_helpers.tpl index d720e4d7a..b65df7792 100644 --- a/charts/kong/templates/_helpers.tpl +++ b/charts/kong/templates/_helpers.tpl @@ -584,9 +584,33 @@ The name of the Service which will be used by the controller to update the Ingre {{- end -}} +{{- define "kong.migrationPodFilter" -}} +{{ $newList := list }} +{{- range . }} +{{- if or (eq .excludeMigrationPod false) (not (hasKey . "excludeMigrationPod")) }} +{{ $newList = append $newList (omit . "excludeMigrationPod") }} +{{- end }} +{{- end }} +{{ toJson $newList }} +{{- end }} + +{{- define "kong.userDefinedMigrationVolumes" -}} +{{- if .Values.deployment.userDefinedVolumes }} +{{- include "kong.migrationPodFilter" .Values.deployment.userDefinedVolumes | fromJsonArray | toYaml }} +{{- end }} +{{- end -}} + +{{- define "kong.migrationPropertyFilter" -}} +{{ $newList := list }} +{{- range . }} +{{ $newList = append $newList (omit . "excludeMigrationPod") }} +{{- end }} +{{ toJson $newList }} +{{- end }} + {{- define "kong.userDefinedVolumes" -}} {{- if .Values.deployment.userDefinedVolumes }} -{{- toYaml .Values.deployment.userDefinedVolumes }} +{{- include "kong.migrationPropertyFilter" .Values.deployment.userDefinedVolumes | fromJsonArray | toYaml }} {{- end }} {{- end -}} @@ -746,9 +770,15 @@ The name of the Service which will be used by the controller to update the Ingre {{- end -}} {{- end -}} +{{- define "kong.userDefinedMigrationVolumeMounts" -}} +{{- if .userDefinedVolumeMounts }} +{{- include "kong.migrationPodFilter" .userDefinedVolumeMounts | fromJsonArray | toYaml }} +{{- end }} +{{- end -}} + {{- define "kong.userDefinedVolumeMounts" -}} {{- if .userDefinedVolumeMounts }} -{{- toYaml .userDefinedVolumeMounts }} +{{- include "kong.migrationPropertyFilter" .userDefinedVolumeMounts | fromJsonArray | toYaml }} {{- end }} {{- end -}} diff --git a/charts/kong/templates/migrations-post-upgrade.yaml b/charts/kong/templates/migrations-post-upgrade.yaml index 73225392c..39230745b 100644 --- a/charts/kong/templates/migrations-post-upgrade.yaml +++ b/charts/kong/templates/migrations-post-upgrade.yaml @@ -72,7 +72,7 @@ spec: args: [ "kong", "migrations", "finish" ] volumeMounts: {{- include "kong.volumeMounts" . | nindent 8 }} - {{- include "kong.userDefinedVolumeMounts" .Values.deployment | nindent 8 }} + {{- include "kong.userDefinedMigrationVolumeMounts" .Values.deployment | nindent 8 }} resources: {{- toYaml .Values.migrations.resources | nindent 10 }} securityContext: @@ -92,6 +92,6 @@ spec: restartPolicy: OnFailure volumes: {{- include "kong.volumes" . | nindent 6 -}} - {{- include "kong.userDefinedVolumes" . | nindent 6 -}} + {{- include "kong.userDefinedMigrationVolumes" . | nindent 6 -}} {{- end }} {{- end }} diff --git a/charts/kong/templates/migrations-pre-upgrade.yaml b/charts/kong/templates/migrations-pre-upgrade.yaml index 9efb8baea..7fb8fa387 100644 --- a/charts/kong/templates/migrations-pre-upgrade.yaml +++ b/charts/kong/templates/migrations-pre-upgrade.yaml @@ -74,7 +74,7 @@ spec: args: [ "kong", "migrations", "up" ] volumeMounts: {{- include "kong.volumeMounts" . | nindent 8 }} - {{- include "kong.userDefinedVolumeMounts" .Values.deployment | nindent 8 }} + {{- include "kong.userDefinedMigrationVolumeMounts" .Values.deployment | nindent 8 }} resources: {{- toYaml .Values.migrations.resources| nindent 10 }} securityContext: @@ -94,6 +94,6 @@ spec: restartPolicy: OnFailure volumes: {{- include "kong.volumes" . | nindent 6 -}} - {{- include "kong.userDefinedVolumes" . | nindent 6 -}} + {{- include "kong.userDefinedMigrationVolumes" . | nindent 6 -}} {{- end }} {{- end }} diff --git a/charts/kong/templates/migrations.yaml b/charts/kong/templates/migrations.yaml index e1a85fb90..1bab74385 100644 --- a/charts/kong/templates/migrations.yaml +++ b/charts/kong/templates/migrations.yaml @@ -82,7 +82,7 @@ spec: args: [ "kong", "migrations", "bootstrap" ] volumeMounts: {{- include "kong.volumeMounts" . | nindent 8 }} - {{- include "kong.userDefinedVolumeMounts" .Values.deployment | nindent 8 }} + {{- include "kong.userDefinedMigrationVolumeMounts" .Values.deployment | nindent 8 }} resources: {{- toYaml .Values.migrations.resources | nindent 10 }} securityContext: @@ -102,7 +102,7 @@ spec: restartPolicy: OnFailure volumes: {{- include "kong.volumes" . | nindent 6 -}} - {{- include "kong.userDefinedVolumes" . | nindent 6 -}} + {{- include "kong.userDefinedMigrationVolumes" . | nindent 6 -}} {{- end }} {{- end }} {{- end }} diff --git a/charts/kong/values.yaml b/charts/kong/values.yaml index 30b538374..ece8d75cb 100644 --- a/charts/kong/values.yaml +++ b/charts/kong/values.yaml @@ -57,6 +57,28 @@ deployment: # userDefinedVolumeMounts: # - name: "volumeName" # mountPath: "/opt/user/dir/mount" + + ## userDefinedVolumes & userDefinedVolumeMounts can be specified with excludeMigrationPod which disables adding the volumes and mounts to migration pods + # userDefinedVolumes: + # - name: "volumeNameAlways" + # emptyDir: { } + # - name: "volumeNameNever" + # excludeMigrationPod: true + # emptyDir: {} + # - name: "volumeNameYes" + # excludeMigrationPod: false + # persistentVolumeClaim: + # claimName: "my_claim" + # userDefinedVolumeMounts: + # - name: "volumeNameAlways" + # mountPath: "/opt/user/dir/mountAlways" + # - name: "volumeNameNever" + # excludeMigrationPod: true + # mountPath: "/opt/user/dir/volumeNameNever" + # - name: "volumeNameYes" + # excludeMigrationPod: false + # mountPath: "/opt/user/dir/volumeNameYes" + test: # Enable creation of test resources for use with "helm test" enabled: false