diff --git a/charts/wasp-open-api/Chart.yaml b/charts/wasp-open-api/Chart.yaml index cb5b4a01..7c06cb74 100644 --- a/charts/wasp-open-api/Chart.yaml +++ b/charts/wasp-open-api/Chart.yaml @@ -31,4 +31,4 @@ maintainers: name: wasp-open-api sources: - https://github.com/digicatapult/wasp-open-api -version: 1.0.1 +version: 1.1.0 diff --git a/charts/wasp-open-api/README.md b/charts/wasp-open-api/README.md index f2e9ca42..234f8ccc 100644 --- a/charts/wasp-open-api/README.md +++ b/charts/wasp-open-api/README.md @@ -77,7 +77,7 @@ The command removes all the Kubernetes components associated with the chart and | `paths` | An array of URLs to the OpenAPI specs to merge | `["http://wasp-reading-service/v1/api-docs","http://wasp-event-service/v1/api-docs","http://wasp-thing-service/v1/api-docs","http://wasp-authentication-service/v1/api-docs","http://wasp-user-service/v1/api-docs"]` | | `output` | The path to the output file | `output/output.swagger.json` | | `baseUrl` | The base URL of the API | `http://localhost:3000/api` | -| `apiDocsFilePath` | The path to the API docs file | `./api-docs.json` | +| `apiDocsFilePath` | The path to the API docs file | `/data/api-docs.json` | | `prepend` | what to prepend to the pathModification in the merged OpenAPI spec | `""` | | `apiDocsMock.enabled` | Enable API docs mock | `false` | | `image.registry` | wasp-open-api image registry | `docker.io` | @@ -157,6 +157,22 @@ The command removes all the Kubernetes components associated with the chart and | `initContainers` | Add additional init containers to the wasp-open-api pod(s) | `[]` | +### Persistence Parameters + +| Name | Description | Value | +| --------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------- | +| `persistence.enabled` | Enable persistence using Persistent Volume Claims | `true` | +| `persistence.mountPath` | Path to mount the volume at. | `/data` | +| `persistence.subPath` | The subdirectory of the volume to mount to, useful in dev environments and one PV for multiple services | `""` | +| `persistence.storageClass` | Storage class of backing PVC | `""` | +| `persistence.annotations` | Persistent Volume Claim annotations | `{}` | +| `persistence.accessModes` | Persistent Volume Access Modes | `["ReadWriteOnce"]` | +| `persistence.size` | Size of data volume | `1Gi` | +| `persistence.existingClaim` | The name of an existing PVC to use for persistence | `""` | +| `persistence.selector` | Selector to match an existing Persistent Volume for WordPress data PVC | `{}` | +| `persistence.dataSource` | Custom PVC data source | `{}` | + + ### Traffic Exposure Parameters | Name | Description | Value | diff --git a/charts/wasp-open-api/templates/deployment.yaml b/charts/wasp-open-api/templates/deployment.yaml index 78856f75..11b5bf16 100644 --- a/charts/wasp-open-api/templates/deployment.yaml +++ b/charts/wasp-open-api/templates/deployment.yaml @@ -146,6 +146,11 @@ spec: lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }} {{- end }} volumeMounts: + - name: data + mountPath: {{ .Values.persistence.mountPath }} + {{- if .Values.persistence.subPath }} + subPath: {{ .Values.persistence.subPath }} + {{- end }} {{- if .Values.extraVolumeMounts }} {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }} {{- end }} @@ -153,6 +158,13 @@ spec: {{- include "common.tplvalues.render" ( dict "value" .Values.sidecars "context" $) | nindent 8 }} {{- end }} volumes: + - name: data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ default (include "common.names.fullname" .) .Values.persistence.existingClaim }} + {{- else }} + emptyDir: {} + {{- end }} {{- if .Values.extraVolumes }} {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }} {{- end }} diff --git a/charts/wasp-open-api/templates/pvc.yaml b/charts/wasp-open-api/templates/pvc.yaml new file mode 100644 index 00000000..13a6a063 --- /dev/null +++ b/charts/wasp-open-api/templates/pvc.yaml @@ -0,0 +1,36 @@ +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "common.names.fullname" . }} + namespace: {{ include "common.names.namespace" . | quote }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + app.kubernetes.io/component: wasp-open-api + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + {{- if or .Values.persistence.annotations .Values.commonAnnotations }} + annotations: + {{- if .Values.persistence.annotations }} + {{- include "common.tplvalues.render" ( dict "value" .Values.persistence.annotations "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} + {{- end }} +spec: + accessModes: + {{- range .Values.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} + {{- if .Values.persistence.selector }} + selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.selector "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.persistence.dataSource }} + dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.dataSource "context" $) | nindent 4 }} + {{- end }} + {{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 2 }} +{{- end -}} diff --git a/charts/wasp-open-api/values.yaml b/charts/wasp-open-api/values.yaml index 4bd74cd7..45723561 100644 --- a/charts/wasp-open-api/values.yaml +++ b/charts/wasp-open-api/values.yaml @@ -82,7 +82,7 @@ output: output/output.swagger.json baseUrl: http://localhost:3000/api ## @param apiDocsFilePath The path to the API docs file ## -apiDocsFilePath: ./api-docs.json +apiDocsFilePath: /data/api-docs.json ## @param prepend what to prepend to the pathModification in the merged OpenAPI spec ## prepend: "" @@ -365,6 +365,55 @@ sidecars: [] ## initContainers: [] +## @section Persistence Parameters +## + +## Enable persistence using Persistent Volume Claims +## ref: https://kubernetes.io/docs/user-guide/persistent-volumes/ +## +persistence: + ## @param persistence.enabled Enable persistence using Persistent Volume Claims + ## + enabled: true + ## @param persistence.mountPath Path to mount the volume at. + ## + mountPath: /data + ## @param persistence.subPath The subdirectory of the volume to mount to, useful in dev environments and one PV for multiple services + ## + subPath: "" + ## @param persistence.storageClass Storage class of backing PVC + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + storageClass: "" + ## @param persistence.annotations Persistent Volume Claim annotations + ## + annotations: {} + ## @param persistence.accessModes Persistent Volume Access Modes + ## + accessModes: + - ReadWriteOnce + ## @param persistence.size Size of data volume + ## + size: 1Gi + ## @param persistence.existingClaim The name of an existing PVC to use for persistence + ## + existingClaim: "" + ## @param persistence.selector Selector to match an existing Persistent Volume for WordPress data PVC + ## If set, the PVC can't have a PV dynamically provisioned for it + ## E.g. + ## selector: + ## matchLabels: + ## app: my-app + ## + selector: {} + ## @param persistence.dataSource Custom PVC data source + ## + dataSource: {} + ## @section Traffic Exposure Parameters ##