From 316b3ea46fed4292395b54041b740af6ec11f53e Mon Sep 17 00:00:00 2001 From: Pascal Morillon Date: Fri, 27 Oct 2023 10:10:32 +0200 Subject: [PATCH] Update stack helm chart after review on PR #72 Signed-off-by: Pascal Morillon --- tinkerbell/stack/templates/NOTES.txt | 7 ---- tinkerbell/stack/templates/_helpers.tpl | 19 ++++++----- tinkerbell/stack/templates/hook.yaml | 10 +++--- tinkerbell/stack/templates/nginx.yaml | 10 +++--- .../nginx_persistentvolumeclaim.yaml | 14 ++++---- tinkerbell/stack/values.yaml | 32 +++++++++++-------- 6 files changed, 47 insertions(+), 45 deletions(-) diff --git a/tinkerbell/stack/templates/NOTES.txt b/tinkerbell/stack/templates/NOTES.txt index 9d773114..e69de29b 100644 --- a/tinkerbell/stack/templates/NOTES.txt +++ b/tinkerbell/stack/templates/NOTES.txt @@ -1,7 +0,0 @@ -{{- 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 }} \ No newline at end of file diff --git a/tinkerbell/stack/templates/_helpers.tpl b/tinkerbell/stack/templates/_helpers.tpl index c31a0605..88167d04 100644 --- a/tinkerbell/stack/templates/_helpers.tpl +++ b/tinkerbell/stack/templates/_helpers.tpl @@ -1,11 +1,14 @@ {{- 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}} + {{- $result := false }} + {{- if and .Values.stack.hook.enabled .Values.stack.hook.persistence.enabled -}} + {{- $result = true -}} + {{- if and .Values.stack.hook.persistence.enabled (eq .Values.stack.hook.persistence.type "pvc") }} + {{- range .Values.stack.hook.persistence.accessModes }} + {{- if eq . "ReadWriteOnce" }} + {{- $result = false}} + {{- end }} + {{- end }} {{- end }} - {{- end }} -{{- end }} -{{- $result }} + {{- end -}} + {{- $result }} {{- end -}} \ No newline at end of file diff --git a/tinkerbell/stack/templates/hook.yaml b/tinkerbell/stack/templates/hook.yaml index d0d2238b..13ed1a36 100644 --- a/tinkerbell/stack/templates/hook.yaml +++ b/tinkerbell/stack/templates/hook.yaml @@ -51,16 +51,16 @@ spec: restartPolicy: OnFailure volumes: - name: hook-artifacts - {{- if .Values.stack.persistence.enabled }} - {{- if eq .Values.stack.persistence.type "hostpath" }} + {{- if .Values.stack.hook.persistence.enabled }} + {{- if eq .Values.stack.hook.persistence.type "hostpath" }} hostPath: path: {{ .Values.stack.hook.downloadsDest }} type: DirectoryOrCreate - {{- else if eq .Values.stack.persistence.type "pvc" }} + {{- else if eq .Values.stack.hook.persistence.type "pvc" }} persistentVolumeClaim: - claimName: {{ .Values.stack.persistence.existingClaim | default "hook-artifacts" }} + claimName: {{ .Values.stack.hook.persistence.existingClaim | default "hook-artifacts" }} {{- else }} - {{- fail "value for .Values.stack.persistence.type is not as expected" }} + {{- fail "value for .Values.stack.hook.persistence.type is not as expected" }} {{- end }} {{- else }} emptyDir: {} diff --git a/tinkerbell/stack/templates/nginx.yaml b/tinkerbell/stack/templates/nginx.yaml index e620bf9a..8d121558 100644 --- a/tinkerbell/stack/templates/nginx.yaml +++ b/tinkerbell/stack/templates/nginx.yaml @@ -123,16 +123,16 @@ spec: {{- end }} {{- if .Values.stack.hook.enabled }} - name: hook-artifacts - {{- if .Values.stack.persistence.enabled }} - {{- if eq .Values.stack.persistence.type "hostpath" }} + {{- if .Values.stack.hook.persistence.enabled }} + {{- if eq .Values.stack.hook.persistence.type "hostpath" }} hostPath: path: {{ .Values.stack.hook.downloadsDest }} type: DirectoryOrCreate - {{- else if eq .Values.stack.persistence.type "pvc" }} + {{- else if eq .Values.stack.hook.persistence.type "pvc" }} persistentVolumeClaim: - claimName: {{ .Values.stack.persistence.existingClaim | default "hook-artifacts" }} + claimName: {{ .Values.stack.hook.persistence.existingClaim | default "hook-artifacts" }} {{- else }} - {{- fail "value for .Values.stack.persistence.type is not as expected" }} + {{- fail "value for .Values.stack.hook.persistence.type is not as expected" }} {{- end }} {{- else }} emptyDir: {} diff --git a/tinkerbell/stack/templates/nginx_persistentvolumeclaim.yaml b/tinkerbell/stack/templates/nginx_persistentvolumeclaim.yaml index 0bb934d5..5b4d4327 100644 --- a/tinkerbell/stack/templates/nginx_persistentvolumeclaim.yaml +++ b/tinkerbell/stack/templates/nginx_persistentvolumeclaim.yaml @@ -1,28 +1,28 @@ -{{- if and .Values.stack.persistence.enabled (not .Values.stack.persistence.existingClaim) (eq .Values.stack.persistence.type "pvc") }} +{{- if and .Values.stack.hook.enabled .Values.stack.hook.persistence.enabled (not .Values.stack.hook.persistence.existingClaim) (eq .Values.stack.hook.persistence.type "pvc") }} apiVersion: v1 kind: PersistentVolumeClaim metadata: name: hook-artifacts labels: - {{- with .Values.stack.persistence.extraPvcLabels }} + {{- with .Values.stack.hook.persistence.extraPvcLabels }} {{- toYaml . | nindent 4 }} {{- end }} - {{- with .Values.stack.persistence.annotations }} + {{- with .Values.stack.hook.persistence.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: accessModes: - {{- range .Values.stack.persistence.accessModes }} + {{- range .Values.stack.hook.persistence.accessModes }} - {{ . | quote }} {{- end }} resources: requests: - storage: {{ .Values.stack.persistence.size | quote }} - {{- with .Values.stack.persistence.storageClassName }} + storage: {{ .Values.stack.hook.persistence.size | quote }} + {{- with .Values.stack.hook.persistence.storageClassName }} storageClassName: {{ . }} {{- end }} - {{- with .Values.stack.persistence.selectorLabels }} + {{- with .Values.stack.hook.persistence.selectorLabels }} selector: matchLabels: {{- toYaml . | nindent 6 }} diff --git a/tinkerbell/stack/values.yaml b/tinkerbell/stack/values.yaml index 3d31a8ef..567daae6 100644 --- a/tinkerbell/stack/values.yaml +++ b/tinkerbell/stack/values.yaml @@ -18,19 +18,7 @@ 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 @@ -41,6 +29,24 @@ stack: # downloadURL only works with the > 0.8.1 Hook release because # previous Hook versions didn't provide a checksum file. downloadURL: https://github.com/tinkerbell/hook/releases/download/v0.9.1 + persistence: + enabled: true + ## type hostpath or pvc + # hostpath : only works on a single worker node cluster + type: hostpath + ## When type is pvc + # storageClassName: default + + ## PVC accessModes : + # Require ReadWriteMany in order to download Hook and scale up kubernetes tink-stack Deployment resource. + # If ReadWriteOnce is used, you will need to download manually Hook into stack Pod (/usr/share/nginx/html/). + accessModes: + - ReadWriteMany + size: 1Gi + # annotations: {} + # selectorLabels: {} + # existingClaim: + extraPvcLabels: {} kubevip: enabled: true name: kube-vip