Skip to content

Commit

Permalink
Adding a writable pvc to wasp-open-api (#24)
Browse files Browse the repository at this point in the history
* Adding a writable pvc to wasp-open-api
  • Loading branch information
dblane-digicatapult authored Feb 21, 2023
1 parent 6121661 commit c5363fb
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/wasp-open-api/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 17 additions & 1 deletion charts/wasp-open-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down Expand Up @@ -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 |
Expand Down
12 changes: 12 additions & 0 deletions charts/wasp-open-api/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,25 @@ 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 }}
{{- if .Values.sidecars }}
{{- 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 }}
36 changes: 36 additions & 0 deletions charts/wasp-open-api/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -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 -}}
51 changes: 50 additions & 1 deletion charts/wasp-open-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand Down Expand Up @@ -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: <storageClass>
## 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
##

Expand Down

0 comments on commit c5363fb

Please sign in to comment.