Skip to content

Commit

Permalink
Merge pull request #247 from pascaliske/feature/hammond-persistence-s…
Browse files Browse the repository at this point in the history
…upport
  • Loading branch information
pascaliske authored Mar 17, 2023
2 parents 2569090 + 36fce1d commit 2071f80
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 3 deletions.
4 changes: 2 additions & 2 deletions charts/hammond/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -28,4 +28,4 @@ dependencies:
annotations:
artifacthub.io/changes: |-
- kind: added
description: 'Initial chart implementation.'
description: 'Support data persistence for config and asset volumes.'
11 changes: 10 additions & 1 deletion charts/hammond/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

* <https://github.com/pascaliske/helm-charts>
* <https://github.com/AlfHou/hammond>
Expand Down Expand Up @@ -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`. |
Expand Down
35 changes: 35 additions & 0 deletions charts/hammond/templates/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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: /
Expand All @@ -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 }}
Expand Down
19 changes: 19 additions & 0 deletions charts/hammond/templates/persistantvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
20 changes: 20 additions & 0 deletions charts/hammond/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand Down

0 comments on commit 2071f80

Please sign in to comment.