From 1317be06c97e5c626f32c866162180a51e0b4112 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Wed, 4 Dec 2024 22:07:01 +0100 Subject: [PATCH] Add ssh flag --- Chart.yaml | 4 ++-- templates/deployment.yaml | 26 ++++++++++++++++++++++++-- values.yaml | 6 +++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Chart.yaml b/Chart.yaml index c429f9e..2f20b39 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -4,8 +4,8 @@ name: basic-web-app PullName: basic-app-puller description: A basic Helm chart to have PHP webapps in Kubernetes. It supports webhook for pulling from gitea type: application -version: 2.0.0 -appVersion: "2.0.0" +version: 2.1.0 +appVersion: "2.1.0" dependencies: - name: postgresql diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 7b7895d..408aec0 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -22,14 +22,22 @@ spec: volumeMounts: - name: data mountPath: "/web" + {{- if .Values.updater.ssh.enabled }} + - name: ssh-key + mountPath: "/ssh-key" + readOnly: true + {{- end}} command: - /bin/sh - -ec - | cd /web test -d .git && exit 0 + {{- if .Values.updater.ssh.enabled }} + git clone ${GIT_URL} . --config core.sshCommand="ssh -i /ssh-key" + {{- else }} git clone ${GIT_URL} . - mkdir lib/config + {{- end}} git lfs install git lfs pull env: @@ -78,7 +86,11 @@ spec: - name: updater image: "{{ .Values.updater.image.repository }}:{{ .Values.updater.image.tag }}" imagePullPolicy: {{ .Values.updater.image.pullPolicy }} - command: ["/webhook-runner.sh"] + {{- if .Values.updater.ssh.enabled }} + command: ["/webhook-runner.sh ssh"] + {{- else }} + command: ["/webhook-runner.sh http"] + {{- end }} ports: - containerPort: 8000 protocol: TCP @@ -86,6 +98,11 @@ spec: volumeMounts: - name: data mountPath: /web + {{- if .Values.updater.ssh.enabled }} + - name: ssh-key + mountPath: "/ssh-key" + readOnly: true + {{- end}} env: - name: "DATA_DIR" value: "/web" @@ -126,3 +143,8 @@ spec: - name: data persistentVolumeClaim: claimName: {{ .Release.Name }}-pvc + {{- if .Values.updater.ssh.enabled }} + - name: ssh-key + secret: + secretName: {{ .Values.updater.ssh.secretName }} + {{- end }} diff --git a/values.yaml b/values.yaml index 2273866..65bbf6b 100644 --- a/values.yaml +++ b/values.yaml @@ -15,8 +15,12 @@ updater: image: repository: glvx/web-updater pullPolicy: IfNotPresent - tag: "241120-1" + tag: "241204" url: "https://git.aquila-consortium.org/guilhem_lavaux/gl-website-deployer" + ssh: + enabled: false + secretName: "" + webhook-secret: "" apiUsername: "" apiPassword: ""