helm_website/templates/deployment.yaml

177 lines
5.8 KiB
YAML
Raw Normal View History

2024-11-14 08:13:40 +01:00
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
2024-11-20 10:36:59 +01:00
namespace: {{ .Release.Namespace }}
2024-11-14 08:13:40 +01:00
labels:
{{- include "basic-app.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "basic-app.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "basic-app.selectorLabels" . | nindent 8 }}
spec:
initContainers:
- name: git-cloner
image: "{{ .Values.updater.image.repository }}:{{ .Values.updater.image.tag }}"
imagePullPolicy: {{ .Values.updater.image.pullPolicy }}
volumeMounts:
- name: data
mountPath: "/web"
2024-12-04 22:07:01 +01:00
{{- if .Values.updater.ssh.enabled }}
- name: ssh-key
2024-12-04 22:19:15 +01:00
mountPath: "/ssh"
2024-12-04 22:07:01 +01:00
readOnly: true
{{- end}}
command:
- /bin/sh
- -ec
- |
cd /web
test -d .git && exit 0
2024-12-04 22:07:01 +01:00
{{- if .Values.updater.ssh.enabled }}
2024-12-08 11:37:27 +01:00
GIT_SSH_COMMAND="ssh -i /ssh/ssh-key"
export GIT_SSH_COMMAND
git clone ${GIT_URL} . -o StrictHostKeyChecking=accept-new
2024-12-04 22:07:01 +01:00
{{- else }}
git clone ${GIT_URL} .
2024-12-04 22:07:01 +01:00
{{- end}}
git lfs install
git lfs pull
env:
- name: GIT_URL
value: "{{ .Values.updater.url }}"
2024-11-14 08:13:40 +01:00
containers:
2024-11-20 18:16:42 +01:00
- name: web
2024-11-14 08:13:40 +01:00
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 80
protocol: TCP
name: http-svc
2024-11-14 08:13:40 +01:00
volumeMounts:
- name: data
2024-11-20 18:16:42 +01:00
mountPath: "/var/www/html"
2024-12-05 08:13:26 +01:00
{{- if not (eq "" .Values.configWeb.path) }}
2024-12-05 08:12:27 +01:00
- name: config
2024-12-05 08:13:26 +01:00
mountPath: {{ printf "/var/www/html/%s" .Values.configWeb.path }}
2024-12-05 08:12:27 +01:00
readOnly: true
2024-12-05 08:13:26 +01:00
subPath: {{ .Values.configWeb.key }}
2024-12-05 08:12:27 +01:00
{{- end}}
2024-12-05 11:41:23 +01:00
{{- range .Values.extraVolumesWeb }}
- name: {{ .name }}
mountPath: {{ .path }}
{{- end}}
2024-11-14 08:25:23 +01:00
env:
{{- with .Values.env.plain }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- range .Values.env.configMapKeys }}
- name: {{ .name }}
valueFrom:
configMapKeyRef:
name: {{ .configMapName }}
key: {{ .key }}
{{- end }}
{{- range .Values.env.secretKeys }}
- name: {{ .name }}
valueFrom:
secretKeyRef:
name: {{ .secretName }}
key: {{ .key }}
{{- end }}
envFrom:
{{- range .Values.env.configMapRefs }}
- configMapRef:
name: {{ .name }}
optional: {{ .optional | default false }}
{{- end }}
{{- range .Values.env.secretRefs }}
- secretRef:
name: {{ .name }}
optional: {{ .optional | default false }}
{{- end }}
2024-11-20 18:16:42 +01:00
- name: updater
image: "{{ .Values.updater.image.repository }}:{{ .Values.updater.image.tag }}"
imagePullPolicy: {{ .Values.updater.image.pullPolicy }}
2024-12-04 22:07:01 +01:00
{{- if .Values.updater.ssh.enabled }}
2024-12-04 22:42:05 +01:00
command: ["/webhook-runner.sh", "ssh"]
2024-12-04 22:07:01 +01:00
{{- else }}
2024-12-04 22:42:05 +01:00
command: ["/webhook-runner.sh", "http"]
2024-12-04 22:07:01 +01:00
{{- end }}
2024-11-18 10:12:41 +01:00
ports:
- containerPort: 8000
2024-11-18 10:12:41 +01:00
protocol: TCP
name: webhook-svc
2024-11-18 10:12:41 +01:00
volumeMounts:
- name: data
mountPath: /web
2024-12-04 22:07:01 +01:00
{{- if .Values.updater.ssh.enabled }}
- name: ssh-key
2024-12-08 11:37:27 +01:00
mountPath: "/ssh"
2024-12-04 22:07:01 +01:00
readOnly: true
{{- end}}
env:
- name: "DATA_DIR"
value: "/web"
{{- with .Values.updater.env.plain }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.env.plain }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- range .Values.env.configMapKeys }}
- name: {{ .name }}
valueFrom:
configMapKeyRef:
name: {{ .configMapName }}
key: {{ .key }}
{{- end }}
{{- range .Values.env.secretKeys }}
- name: {{ .name }}
valueFrom:
secretKeyRef:
name: {{ .secretName }}
key: {{ .key }}
{{- end }}
envFrom:
{{- range .Values.env.configMapRefs }}
- configMapRef:
name: {{ .name }}
optional: {{ .optional | default false }}
{{- end }}
- secretRef:
name: {{ .Release.Name }}-webhook-secret
{{- range .Values.env.secretRefs }}
- secretRef:
name: {{ .name }}
optional: {{ .optional | default false }}
{{- end }}
2024-11-14 08:13:40 +01:00
volumes:
- name: data
persistentVolumeClaim:
2024-11-20 18:16:42 +01:00
claimName: {{ .Release.Name }}-pvc
2024-12-04 22:07:01 +01:00
{{- if .Values.updater.ssh.enabled }}
- name: ssh-key
secret:
secretName: {{ .Values.updater.ssh.secretName }}
2024-12-04 22:39:32 +01:00
defaultMode: 0400
2024-12-04 22:07:01 +01:00
{{- end }}
2024-12-05 08:13:51 +01:00
{{- if not (eq "" .Values.configWeb.path) }}
2024-12-05 08:12:27 +01:00
- name: config
secret:
2024-12-05 08:13:51 +01:00
secretName: {{ .Values.configWeb.secretName }}
2024-12-05 08:12:27 +01:00
items:
2024-12-05 08:13:51 +01:00
- key: {{ .Values.configWeb.key }}
path: {{ .Values.configWeb.key }}
2024-12-05 08:12:27 +01:00
{{- end }}
2024-12-05 22:26:14 +01:00
{{- range .Values.extraVolumesWeb }}
- name: {{ .name }}
persistentVolumeClaim:
claimName: {{ .name }}
{{- end}}