Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(conf): Add support for excludeMigrationPod to userDefinedVolumes and userDefinedVolumeMounts #1176

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/kong/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
* Added serviceMonitor.trustCRDsExist for render based deployments
* Add support for `excludeMigrationPod` to userDefinedVolumes and userDefinedVolumeMounts

### Changes

Expand Down
34 changes: 32 additions & 2 deletions charts/kong/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}

Expand Down Expand Up @@ -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 -}}

Expand Down
4 changes: 2 additions & 2 deletions charts/kong/templates/migrations-post-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
4 changes: 2 additions & 2 deletions charts/kong/templates/migrations-pre-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
4 changes: 2 additions & 2 deletions charts/kong/templates/migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
22 changes: 22 additions & 0 deletions charts/kong/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down