Skip to content

Commit

Permalink
Add stack persistent volume claim
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Morillon <[email protected]>
  • Loading branch information
pmorillon authored and jacobweinstock committed Oct 5, 2024
1 parent fe80800 commit 48ecf13
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tinkerbell/stack/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- if eq (include "stack.hookDownloadJobEnabled" .) "false" }}
Warning:

You are using no persistence or ReadWriteOnce access modes on PersistentVolumeClaim, Job `download-hook` is disabled.
You will need to manage hooks artifacts manually.
Also stack Deployment is not scalable.
{{- end }}
11 changes: 11 additions & 0 deletions tinkerbell/stack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- define "stack.hookDownloadJobEnabled" -}}
{{- $result := .Values.stack.persistence.enabled }}
{{- if and .Values.stack.persistence.enabled (eq .Values.stack.persistence.type "pvc") }}
{{- range .Values.stack.persistence.accessModes }}
{{- if eq . "ReadWriteOnce" }}
{{- $result = false}}
{{- end }}
{{- end }}
{{- end }}
{{- $result }}
{{- end -}}
14 changes: 13 additions & 1 deletion tinkerbell/stack/templates/hook.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.stack.hook.enabled }}
{{- $hookDownloadJobEnabled := eq (include "stack.hookDownloadJobEnabled" .) "true" -}}
{{- if and .Values.stack.hook.enabled $hookDownloadJobEnabled }}
---
apiVersion: v1
kind: ConfigMap
Expand Down Expand Up @@ -50,9 +51,20 @@ spec:
restartPolicy: OnFailure
volumes:
- name: hook-artifacts
{{- if .Values.stack.persistence.enabled }}
{{- if eq .Values.stack.persistence.type "hostpath" }}
hostPath:
path: {{ .Values.stack.hook.downloadsDest }}
type: DirectoryOrCreate
{{- else if eq .Values.stack.persistence.type "pvc" }}
persistentVolumeClaim:
claimName: {{ .Values.stack.persistence.existingClaim | default "hook-artifacts" }}
{{- else }}
{{- fail "value for .Values.stack.persistence.type is not as expected" }}
{{- end }}
{{- else }}
emptyDir: {}
{{- end }}
- name: configmap-volume
configMap:
defaultMode: 0700
Expand Down
11 changes: 11 additions & 0 deletions tinkerbell/stack/templates/nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,20 @@ spec:
{{- end }}
{{- if .Values.stack.hook.enabled }}
- name: hook-artifacts
{{- if .Values.stack.persistence.enabled }}
{{- if eq .Values.stack.persistence.type "hostpath" }}
hostPath:
path: {{ .Values.stack.hook.downloadsDest }}
type: DirectoryOrCreate
{{- else if eq .Values.stack.persistence.type "pvc" }}
persistentVolumeClaim:
claimName: {{ .Values.stack.persistence.existingClaim | default "hook-artifacts" }}
{{- else }}
{{- fail "value for .Values.stack.persistence.type is not as expected" }}
{{- end }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}
{{- if and .Values.stack.relay.enabled $listenBroadcast }}
initContainers:
Expand Down
30 changes: 30 additions & 0 deletions tinkerbell/stack/templates/nginx_persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if and .Values.stack.persistence.enabled (not .Values.stack.persistence.existingClaim) (eq .Values.stack.persistence.type "pvc") }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hook-artifacts
labels:
{{- with .Values.stack.persistence.extraPvcLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.stack.persistence.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
accessModes:
{{- range .Values.stack.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.stack.persistence.size | quote }}
{{- with .Values.stack.persistence.storageClassName }}
storageClassName: {{ . }}
{{- end }}
{{- with .Values.stack.persistence.selectorLabels }}
selector:
matchLabels:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions tinkerbell/stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ stack:
lbClass: kube-vip.io/kube-vip-class
# Once the Kubernetes Gateway API is more stable, we will use that for all services instead of nginx.
image: nginx:1.25.1
persistence:
enabled: true
# type hostpath or pvc
type: hostpath
# When type is pvc
# storageClassName: default
accessModes:
- ReadWriteMany
size: 1Gi
# annotations: {}
# selectorLabels: {}
# existingClaim:
extraPvcLabels: {}

hook:
enabled: true
name: hook-files
Expand Down

0 comments on commit 48ecf13

Please sign in to comment.