Loads of new features, including live updater

This commit is contained in:
Guilhem Lavaux 2024-11-20 10:32:53 +01:00
parent f25565dff5
commit 13b075660d
7 changed files with 127 additions and 23 deletions

View File

@ -6,3 +6,13 @@ description: A basic Helm chart for Kubernetes
type: application type: application
version: 0.1.0 version: 0.1.0
appVersion: "1.0.0" appVersion: "1.0.0"
dependencies:
- name: postgresql
version: 15.5.0
repository: oci://registry-1.docker.io/bitnamicharts
condition: postgresql.enabled
- name: mysql
version: 11.1.19
repository: oci://registry-1.docker.io/bitnamicharts
condition: mysql.enabled

17
templates/NOTES.txt Normal file
View File

@ -0,0 +1,17 @@
{{- $releaseNamespace := {{ .Release.Namespace }} }}
{{- $secretName := {{ .Release.Name }}-webhook-secret }}
CHART NAME: {{ .Chart.Name }}
CHART VERSION: {{ .Chart.Version }}
APP VERSION: {{ .Chart.AppVersion }}
** Please be patient while the chart is being deployed **
To get the webhook identification run:
export WEBHOOK_SECRET=$(kubectl get secret --namespace {{ $releaseNamespace }} {{ $secretName }} -o jsonpath="{.data.WEBHOOK_SECRET}" | base64 -d)
export API_USERNAME=$(kubectl get secret --namespace {{ $releaseNamespace }} {{ $secretName }} -o jsonpath="{.data.API_USERNAME}" | base64 -d): {{ $apiUsername | b64enc }}
export API_PASSWORD=$(kubectl get secret --namespace {{ $releaseNamespace }} {{ $secretName }} -o jsonpath="{.data.API_PASSWORD}" | base64 -d): {{ $apiUsername | b64enc }}
To build the authentication header:
echo "Basic $(echo -n $API_USERNAME:$API_PASSWORD | base64)"

View File

@ -14,6 +14,26 @@ spec:
labels: labels:
{{- include "basic-app.selectorLabels" . | nindent 8 }} {{- include "basic-app.selectorLabels" . | nindent 8 }}
spec: spec:
initContainers:
- name: git-cloner
image: "{{ .Values.updater.image.repository }}:{{ .Values.updater.image.tag }}"
imagePullPolicy: {{ .Values.updater.image.pullPolicy }}
volumeMounts:
- name: data
mountPath: "/web"
command:
- /bin/sh
- -ec
- |
cd /web
test -d .git && exit 0
git clone ${GIT_URL} .
mkdir lib/config
git lfs install
git lfs pull
env:
- name: GIT_URL
value: "{{ .Values.updater.url }}"
containers: containers:
- name: {{ .Chart.Name }} - name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
@ -21,9 +41,10 @@ spec:
ports: ports:
- containerPort: 80 - containerPort: 80
protocol: TCP protocol: TCP
name: http-svc
volumeMounts: volumeMounts:
- name: data - name: data
mountPath: /data mountPath: /var/www/html
env: env:
{{- with .Values.env.plain }} {{- with .Values.env.plain }}
{{- toYaml . | nindent 12 }} {{- toYaml . | nindent 12 }}
@ -54,15 +75,21 @@ spec:
optional: {{ .optional | default false }} optional: {{ .optional | default false }}
{{- end }} {{- end }}
- name: {{ .Chart.PullName }} - name: {{ .Chart.PullName }}
image: "{{ .Values.puller.image.repository }}:{{ .Values.puller.image.tag }}" image: "{{ .Values.updater.image.repository }}:{{ .Values.updater.image.tag }}"
imagePullPolicy: {{ .Values.puller.image.pullPolicy }} imagePullPolicy: {{ .Values.updater.image.pullPolicy }}
ports: ports:
- containerPort: 80 - containerPort: 8000
protocol: TCP protocol: TCP
name: webhook-svc
volumeMounts: volumeMounts:
- name: data - name: data
mountPath: /data mountPath: /web
env: env:
- name: "DATA_DIR"
value: "/web"
{{- with .Values.updater.env.plain }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.env.plain }} {{- with .Values.env.plain }}
{{- toYaml . | nindent 12 }} {{- toYaml . | nindent 12 }}
{{- end }} {{- end }}
@ -86,6 +113,8 @@ spec:
name: {{ .name }} name: {{ .name }}
optional: {{ .optional | default false }} optional: {{ .optional | default false }}
{{- end }} {{- end }}
- secretRef:
name: {{ .Release.Name }}-webhook-secret
{{- range .Values.env.secretRefs }} {{- range .Values.env.secretRefs }}
- secretRef: - secretRef:
name: {{ .name }} name: {{ .name }}
@ -95,4 +124,3 @@ spec:
- name: data - name: data
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{ .Release.Name }}-pvc claimName: {{ .Release.Name }}-pvc

View File

@ -24,15 +24,20 @@ spec:
- host: {{ .host | quote }} - host: {{ .host | quote }}
http: http:
paths: paths:
{{- range .paths }} - path: /
- path: {{ .path }} pathType: Prefix
pathType: {{ .pathType }}
backend: backend:
service: service:
name: {{ $.Release.Name }} name: {{ $.Release.Name }}
port: port:
number: {{ $.Values.service.port }} number: 80
{{- end }} - path: "/.webhook"
pathType: Prefix
backend:
service:
name: {{ $.Release.Name }}
port:
number: 8000
{{- end }} {{- end }}
{{- end }} {{- end }}

34
templates/secrets.yaml Normal file
View File

@ -0,0 +1,34 @@
{{- if and (not $webhook_secret) .Values.updater.webhook_secret }}
{{- $webhook_secret = .Values.updater.webhook_secret }}
{{- end }}
{{- if not $webhook_secret }}
{{- $webhook_secret = randAlphaNum 10 }}
{{- end }}
{{- if and (not $apiUsername) .Values.updater.apiUsername }}
{{- $apiUsername = .Values.updater.apiUsername }}
{{- end }}
{{- if and (not $apiPassword) .Values.updater.apiPassword }}
{{- $apiPassword = .Values.updater.apiPassword }}
{{- end }}
{{- if not $apiUsername}}
{{- $apiUsername = randAlphaNum 10 }}
{{- end }}
{{- if not $apiPassword}}
{{- $apiPassword = randAlphaNum 10 }}
{{- end }}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-webhook-secret
namespace: {{ .Release.Namespace }}
type: Opaque
data:
WEBHOOK_SECRET: {{ $webhook_secret | b64enc }}
API_USERNAME: {{ $apiUsername | b64enc }}
API_PASSWORD: {{ $apiPassword | b64enc }}
SCRIPT_NAME: "/.webhook"

View File

@ -2,15 +2,19 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: {{ .Release.Name }} name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels: labels:
{{- include "basic-app.labels" . | nindent 4 }} {{- include "basic-app.labels" . | nindent 4 }}
spec: spec:
type: {{ .Values.service.type }} type: {{ .Values.service.type }}
ports: ports:
- port: {{ .Values.service.port }} - port: 80
targetPort: 80 targetPort: http-svc
protocol: TCP protocol: TCP
name: http name: http
- port: 8000
targetPort: webhook-svc
protocol: TCP
name: webhook
selector: selector:
{{- include "basic-app.selectorLabels" . | nindent 4 }} {{- include "basic-app.selectorLabels" . | nindent 4 }}

View File

@ -5,15 +5,21 @@ image:
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
tag: "latest" tag: "latest"
puller: mysql:
image: enabled: false
repository: nginx
pullPolicy: IfNotPresent
tag: "latest"
service: postgresql:
type: ClusterIP enabled: false
port: 80
updater:
image:
repository: glvx/web-updater
pullPolicy: IfNotPresent
tag: "241120-1"
url: ""
webhook-secret: ""
apiUsername: ""
apiPassword: ""
ingress: ingress:
enabled: true enabled: true