Skip to content

Commit

Permalink
fixed caddy persistence, reload on config change
Browse files Browse the repository at this point in the history
  • Loading branch information
BWibo committed Aug 26, 2022
1 parent a920dd6 commit 75e73e1
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 6 deletions.
2 changes: 1 addition & 1 deletion helm/charts/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: tum-gis-iot-stack-k8s
description: Helm Chart for the TUM-GI IoT stack.
type: application
version: 0.2.1
version: 0.2.2
appVersion: "0.0.1"

dependencies:
Expand Down
2 changes: 1 addition & 1 deletion helm/charts/charts/caddy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: caddy
description: Caddy webserver
type: application
version: 0.1.2
version: 0.1.3
appVersion: "2.5.2-alpine"
70 changes: 70 additions & 0 deletions helm/charts/charts/caddy/templates/caddy-depl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{{- if .Values.enabled -}}
{{- if not .Values.persistence.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "caddy.fullname" . }}-{{ .Values.component }}
namespace: {{ .Release.Namespace | quote }}
labels:
{{- include "caddy.labels" . | nindent 4 }}
app.kubernetes.io/part-of: tum-gis-iot-stack-k8s
app.kubernetes.io/component: {{ .Values.component }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "caddy.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: {{ .Values.component }}
template:
metadata:
labels:
{{- include "caddy.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: {{ .Values.component }}
annotations:
checksum/configmap: {{ include (print $.Template.BasePath "/caddy-configMap.yml") . | sha256sum }}
spec:
volumes:
- name: data
persistentVolumeClaim:
claimName: caddy-pvc
- name: settings
configMap:
name: caddy-cfg-settings
containers:
- name: caddy
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: web
containerPort: 80

volumeMounts:
- name: html
mountPath: {{ .Values.persistence.data.mountPath }}
- name: settings
mountPath: "/etc/caddy"
readOnly: true
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

volumes:
- name: html
persistentVolumeClaim:
claimName: {{ include "caddy.fullname" . }}-pvc
- name: settings
configMap:
name: {{ include "caddy.fullname" . }}-cfg-settings
{{- end -}}
{{- end -}}
11 changes: 8 additions & 3 deletions helm/charts/charts/caddy/templates/caddy-statefulset.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.enabled -}}
{{- if .Values.persistence.enabled -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
Expand All @@ -8,8 +9,9 @@ metadata:
{{- include "caddy.labels" . | nindent 4 }}
app.kubernetes.io/part-of: tum-gis-iot-stack-k8s
app.kubernetes.io/component: {{ .Values.component }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/caddy-configMap.yml") . | sha256sum }}
# annotations:
# checksum/configmap: {{ include (print $.Template.BasePath "/caddy-configMap.yml") . | sha256sum }}
# checksum/caddyfile: {{ .Values.caddyfile | sha256sum }}
spec:
serviceName: {{ .Chart.Name }}-svc-headless
replicas: {{ .Values.replicaCount }}
Expand All @@ -22,9 +24,11 @@ spec:
labels:
{{- include "caddy.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: {{ .Values.component }}
annotations:
checksum/configmap: {{ include (print $.Template.BasePath "/caddy-configMap.yml") . | sha256sum }}
spec:
volumes:
- name: data
- name: html
persistentVolumeClaim:
claimName: caddy-pvc
- name: settings
Expand Down Expand Up @@ -67,3 +71,4 @@ spec:
configMap:
name: {{ include "caddy.fullname" . }}-cfg-settings
{{- end -}}
{{- end -}}
4 changes: 3 additions & 1 deletion helm/charts/charts/caddy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ingress:
issuer: letsencrypt-staging

persistence:
enabled: true
storageClassName: azurefile-csi
data:
mountPath: /usr/share/caddy
Expand All @@ -40,5 +41,6 @@ affinity: {}

caddyfile: |-
:80 {
file_server
root * /usr/share/caddy
file_server
}

0 comments on commit 75e73e1

Please sign in to comment.