From 712eda6c64a28c4e471d1a7a082de12fcf29fd41 Mon Sep 17 00:00:00 2001 From: LDL-GH <81672459+LDL-GH@users.noreply.github.com> Date: Mon, 11 Jul 2022 11:29:39 +0200 Subject: [PATCH] feat: Provide configuration backup with Persistent Volume (#128) --- .../azure-api-management-gateway/README.md | 7 +++++++ .../templates/deployment.yaml | 15 +++++++++++++++ .../templates/persistent-volume-claim.yaml | 17 +++++++++++++++++ .../azure-api-management-gateway/values.yaml | 8 ++++++++ 4 files changed, 47 insertions(+) create mode 100644 helm-charts/azure-api-management-gateway/templates/persistent-volume-claim.yaml diff --git a/helm-charts/azure-api-management-gateway/README.md b/helm-charts/azure-api-management-gateway/README.md index 8a88903..c0e4990 100644 --- a/helm-charts/azure-api-management-gateway/README.md +++ b/helm-charts/azure-api-management-gateway/README.md @@ -76,6 +76,12 @@ their default values. | `image.tag` | Tag of image to use | N/A, defaults to app version of Helm chart | | `image.pullPolicy` | Policy to pull image | `IfNotPresent` | | `gateway.configuration.uri` | Endpoint in Azure API Management to which every self-hosted agent has to connect | | +| `gateway.configuration.backup.enabled` | If enabled will store a backup copy of the latests downloaded configuration on a storage volume | `false` | +| `gateway.configuration.backup.persistentVolumeClaim.existingName` | Use an existing Persistent Volume Claim (PVC) instead of creating one. *.persistentVolumeClaim.create needs to be false | `""` | +| `gateway.configuration.backup.persistentVolumeClaim.create` | Create a Persistent Volume Claim (PVC) with values specified in *.backup.persistentVolumeClaim.\* | `true` | +| `gateway.configuration.backup.persistentVolumeClaim.storageClassName` | storageClassName to be set on the Persistent Volume Claim (PVC). `null` means no storageClassName specified and will use the platform default, `""` means no storageClassName specified and none will be used. | `null` | +| `gateway.configuration.backup.persistentVolumeClaim.accessMode` | Access mode for the Persistent Volume Claim (PVC) pod | `ReadWriteMany` | +| `gateway.configuration.backup.persistentVolumeClaim.size` | Size of the Persistent Volume Claim (PVC) to be created | `50Mi` | | `gateway.auth.key` | Authentication key to authenticate with to Azure API Management service. Typically starts with `GatewayKey` | | | `secret.createSecret` | Indication whether or not a Kubernetes secret should be created to store the authentication token. | `true` | | `secret.existingSecretName` | Name of the existing secret to be used by the gateway. Requires `secret.createSecret` to be false. | | @@ -122,6 +128,7 @@ their default values. | `securityContext` | Privilege and access control settings for the container | `{}` | | `podSecurityContext` | Privilege and access control settings for the pod | `{}` | + Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. diff --git a/helm-charts/azure-api-management-gateway/templates/deployment.yaml b/helm-charts/azure-api-management-gateway/templates/deployment.yaml index dbd5937..ce4c722 100644 --- a/helm-charts/azure-api-management-gateway/templates/deployment.yaml +++ b/helm-charts/azure-api-management-gateway/templates/deployment.yaml @@ -67,6 +67,11 @@ spec: securityContext: {{- toYaml . | nindent 12 }} {{- end }} + {{- if .Values.gateway.configuration.backup.enabled }} + volumeMounts: + - mountPath: /apim/config + name: {{ include "azure-api-management-gateway.fullname" . }} + {{- end }} {{- with .Values.podSecurityContext }} securityContext: {{- toYaml . | nindent 8 }} @@ -111,3 +116,13 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- if .Values.gateway.configuration.backup.enabled }} + volumes: + - name: {{ include "azure-api-management-gateway.fullname" . }} + persistentVolumeClaim: + {{ if .Values.gateway.configuration.backup.persistentVolumeClaim.create -}} + claimName: {{ include "azure-api-management-gateway.fullname" . }} + {{ else -}} + claimName: {{ .Values.gateway.configuration.backup.persistentVolumeClaim.existingName }} + {{- end }} + {{- end }} \ No newline at end of file diff --git a/helm-charts/azure-api-management-gateway/templates/persistent-volume-claim.yaml b/helm-charts/azure-api-management-gateway/templates/persistent-volume-claim.yaml new file mode 100644 index 0000000..77a3d8c --- /dev/null +++ b/helm-charts/azure-api-management-gateway/templates/persistent-volume-claim.yaml @@ -0,0 +1,17 @@ +{{- if and .Values.gateway.configuration.backup.enabled .Values.gateway.configuration.backup.persistentVolumeClaim.create -}} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "azure-api-management-gateway.fullname" . }} + labels: + {{- include "azure-api-management-gateway.labels" . | nindent 4 }} +spec: + {{- if ne .Values.gateway.configuration.backup.persistentVolumeClaim.storageClassName nil }} + storageClassName: {{ .Values.gateway.configuration.backup.persistentVolumeClaim.storageClassName | quote }} + {{- end }} + accessModes: + - {{ .Values.gateway.configuration.backup.persistentVolumeClaim.accessMode }} + resources: + requests: + storage: {{ .Values.gateway.configuration.backup.persistentVolumeClaim.size }} +{{- end }} \ No newline at end of file diff --git a/helm-charts/azure-api-management-gateway/values.yaml b/helm-charts/azure-api-management-gateway/values.yaml index 86cf0f7..484ad20 100644 --- a/helm-charts/azure-api-management-gateway/values.yaml +++ b/helm-charts/azure-api-management-gateway/values.yaml @@ -16,6 +16,14 @@ fullnameOverride: "" gateway: configuration: uri: + backup: + enabled: false + persistentVolumeClaim: + existingName: "" + create: true + storageClassName: null + accessMode: ReadWriteMany + size: 50Mi auth: # When an existing secret is configured, the value specified here will not be used key: