diff --git a/charts/hammond/Chart.yaml b/charts/hammond/Chart.yaml index 0890b5c4..dc3aa361 100644 --- a/charts/hammond/Chart.yaml +++ b/charts/hammond/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v2 type: application name: hammond description: A Helm chart for hammond -version: 0.0.1 +version: 0.1.0 # renovate: image=ghcr.io/alfhou/hammond appVersion: "v0.0.3" @@ -28,4 +28,4 @@ dependencies: annotations: artifacthub.io/changes: |- - kind: added - description: 'Initial chart implementation.' + description: 'Support data persistence for config and asset volumes.' diff --git a/charts/hammond/README.md b/charts/hammond/README.md index b118d6c7..80643c7b 100644 --- a/charts/hammond/README.md +++ b/charts/hammond/README.md @@ -2,7 +2,7 @@ > A Helm chart for hammond -[![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ](https://charts.pascaliske.dev/charts/hammond/)[![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ](https://charts.pascaliske.dev/charts/hammond/)[![AppVersion: v0.0.3](https://img.shields.io/badge/AppVersion-v0.0.3-informational?style=flat-square) ](https://charts.pascaliske.dev/charts/hammond/) +[![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ](https://charts.pascaliske.dev/charts/hammond/)[![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ](https://charts.pascaliske.dev/charts/hammond/)[![AppVersion: v0.0.3](https://img.shields.io/badge/AppVersion-v0.0.3-informational?style=flat-square) ](https://charts.pascaliske.dev/charts/hammond/) * * @@ -65,6 +65,15 @@ The following values can be used to adjust the helm chart. | ingressRoute.rule | string | `""` | [Matching rule](https://doc.traefik.io/traefik/routing/routers/#rule) for the underlying router. | | ingressRoute.tlsSecretName | string | `""` | Use an existing secret containing the TLS certificate. | | nameOverride | string | `""` | | +| persistentVolumeClaim.accessMode | string | `"ReadWriteOnce"` | Access mode of the persistent volume claim object. | +| persistentVolumeClaim.annotations | object | `{}` | Additional annotations for the persistent volume claim object. | +| persistentVolumeClaim.create | bool | `true` | Create a new persistent volume claim object. | +| persistentVolumeClaim.existingPersistentVolumeClaim | string | `""` | Use an existing persistent volume claim object. | +| persistentVolumeClaim.labels | object | `{}` | Additional labels for the persistent volume claim object. | +| persistentVolumeClaim.mountPath | string | `"/data"` | Mount path of the persistent volume claim object. | +| persistentVolumeClaim.size | string | `"1Gi"` | Storage request size for the persistent volume claim object. | +| persistentVolumeClaim.storageClassName | string | `""` | Storage class name for the persistent volume claim object. | +| persistentVolumeClaim.volumeMode | string | `"Filesystem"` | Volume mode of the persistent volume claim object. | | ports.http.enabled | bool | `true` | Enable the port inside the `Deployment` and `Service` objects. | | ports.http.nodePort | string | `nil` | The external port used if `.service.type` == `NodePort`. | | ports.http.port | int | `3000` | The port used as internal port and cluster-wide port if `.service.type` == `ClusterIP`. | diff --git a/charts/hammond/templates/controller.yaml b/charts/hammond/templates/controller.yaml index 56012552..69d57678 100644 --- a/charts/hammond/templates/controller.yaml +++ b/charts/hammond/templates/controller.yaml @@ -29,6 +29,16 @@ spec: {{- include "hammond.selectorLabels" . | nindent 8 }} spec: serviceAccountName: {{ include "hammond.serviceAccountName" . }} + {{- if eq (include "base.persistence.enabled" . ) "true" }} + initContainers: + - name: init-volumes + image: busybox:latest + imagePullPolicy: IfNotPresent + command: ['sh', '-c', 'mkdir -p {{ .Values.persistentVolumeClaim.mountPath }}/config {{ .Values.persistentVolumeClaim.mountPath }}/assets'] + volumeMounts: + - name: {{ include "base.persistence.suffix" (include "hammond.fullname" . ) }} + mountPath: {{ required "Mandatory value .Values.persistentVolumeClaim.mountPath is empty!" .Values.persistentVolumeClaim.mountPath }} + {{- end }} containers: - name: {{ template "hammond.name" . }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" @@ -50,6 +60,19 @@ spec: {{- toYaml $val.valueFrom | nindent 16 }} {{- end }} {{- end }} + {{- if eq (include "base.persistence.enabled" . ) "true" }} + {{- if not (empty .Values.persistentVolumeClaim.mountPath) }} + - name: CONFIG + value: {{ .Values.persistentVolumeClaim.mountPath }}/config + - name: DATA + value: {{ .Values.persistentVolumeClaim.mountPath }}/assets + {{- end }} + {{- end }} + {{- if eq (include "base.persistence.enabled" . ) "true" }} + volumeMounts: + - name: {{ include "base.persistence.suffix" (include "hammond.fullname" . ) }} + mountPath: {{ required "Mandatory value .Values.persistentVolumeClaim.mountPath is empty!" .Values.persistentVolumeClaim.mountPath }} + {{- end }} livenessProbe: httpGet: path: / @@ -62,6 +85,18 @@ spec: {{- if .Values.resources }} {{- toYaml .Values.resources | nindent 12 }} {{- end }} + {{- if eq (include "base.persistence.enabled" . ) "true" }} + {{- if eq (include "base.persistence.type" . ) "volumes" }} + volumes: + - name: {{ include "base.persistence.suffix" (include "hammond.fullname" . ) }} + persistentVolumeClaim: + {{- if eq (include "base.persistence.created" . ) "true" }} + claimName: {{ include "base.persistence.suffix" (include "hammond.fullname" . ) }} + {{- else }} + claimName: {{ .Values.persistentVolumeClaim.existingPersistentVolumeClaim }} + {{- end }} + {{- end }} + {{- end }} {{- if .Values.securityContext }} securityContext: {{- toYaml .Values.securityContext | nindent 8 }} diff --git a/charts/hammond/templates/persistantvolumeclaim.yaml b/charts/hammond/templates/persistantvolumeclaim.yaml new file mode 100644 index 00000000..d0bb55a6 --- /dev/null +++ b/charts/hammond/templates/persistantvolumeclaim.yaml @@ -0,0 +1,19 @@ +{{- if eq (include "base.persistence.enabled" . ) "true" -}} +{{- if eq (include "base.persistence.type" . ) "volumes" -}} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ printf "%s-storage" (include "hammond.fullname" .) }} + labels: + {{- include "hammond.labels" . | nindent 4 }} + {{- with .Values.persistentVolumeClaim.labels }} + {{ toYaml . | indent 4 }} + {{- end }} + {{- with .Values.persistentVolumeClaim.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- include "base.persistence.spec" . | nindent 2 }} +{{- end }} +{{- end }} diff --git a/charts/hammond/values.yaml b/charts/hammond/values.yaml index 91baba32..d5c69087 100644 --- a/charts/hammond/values.yaml +++ b/charts/hammond/values.yaml @@ -87,6 +87,26 @@ ports: # -- The protocol used for the service. protocol: TCP +persistentVolumeClaim: + # -- Create a new persistent volume claim object. + create: true + # -- Mount path of the persistent volume claim object. + mountPath: /data + # -- Access mode of the persistent volume claim object. + accessMode: ReadWriteOnce + # -- Volume mode of the persistent volume claim object. + volumeMode: Filesystem + # -- Storage request size for the persistent volume claim object. + size: 1Gi + # -- Storage class name for the persistent volume claim object. + storageClassName: '' + # -- Use an existing persistent volume claim object. + existingPersistentVolumeClaim: '' + # -- Additional annotations for the persistent volume claim object. + annotations: {} + # -- Additional labels for the persistent volume claim object. + labels: {} + serviceAccount: # -- Specify the service account used for the controller. name: ''