versia-go/chart/templates/deployment.yaml

144 lines
4.5 KiB
YAML
Raw Normal View History

2024-08-25 00:55:30 +02:00
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "versiago.fullname" . }}
labels:
{{- include "versiago.labels" . | nindent 4 }}
spec:
{{- if eq .Values.database.type "sqlite" }}
{{- if gt (int .Values.pod.replicas) 1 }}
{{- fail "Having multiple replicas with a SQLite database isn't currently possible" }}
{{- end }}
strategy:
type: Recreate
{{- end }}
replicas: {{ .Values.pod.replicas }}
selector:
matchLabels:
{{- include "versiago.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.pod.annotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "versiago.selectorLabels" . | nindent 8 }}
{{- with .Values.pod.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.pod.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.pod.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.pod.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
fsGroup: 1000
{{- if eq .Values.database.type "sqlite" }}
initContainers:
- name: create-db
image: alpine:3.20.2
command:
- touch
- /data/db/db.sqlite3
securityContext:
runAsNonRoot: true
runAsGroup: 1000
runAsUser: 1000
volumeMounts:
- mountPath: /data/db
name: db
{{- end }}
containers:
- name: server
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
startupProbe:
initialDelaySeconds: 20
httpGet:
path: /api/health
port: http
livenessProbe:
httpGet:
path: /api/health
port: http
readinessProbe:
httpGet:
path: /api/health
port: http
resources:
{{- toYaml .Values.pod.resources | nindent 12 }}
securityContext:
# TODO: Investigate if we can drop more caps
runAsNonRoot: true
runAsUser: 1000
env:
- name: ENVIRONMENT
value: {{ .Values.environment | quote }}
- name: VERSIA_PORT
value: "80"
- name: VERSIA_INSTANCE_ADDRESS
value: {{ .Values.versia.instance.address | quote }}
- name: VERSIA_INSTANCE_NAME
value: {{ .Values.versia.instance.name | quote }}
- name: VERSIA_INSTANCE_DESCRIPTION
value: {{ .Values.versia.instance.description | quote }}
- name: NATS_URI
value: {{ .Values.nats.uri | quote }}
- name: NATS_STREAM_NAME
value: {{ include "versiago.name" . | quote }}
{{- if hasKey .Values.versia.telemetry "forwardSpansTo" }}
- name: FORWARD_TRACES_TO
value: {{ .Values.versia.telemetry.forwardSpansTo | quote }}
{{- end }}
{{- if hasKey .Values.versia.telemetry "sentryDSN" }}
- name: SENTRY_DSN
value: {{ .Values.versia.telemetry.sentryDSN | quote }}
{{- end }}
{{- if hasKey .Values.versia.telemetry "otlpEndpoint" }}
- name: OTLP_ENDPOINT
value: {{ .Values.versia.telemetry.otlpEndpoint | quote }}
{{- end }}
- name: DATABASE_URI
{{- if eq .Values.database.type "sqlite" }}
value: "file:/data/db/db.sqlite3?cache=shared&_fk=1"
{{- else }}
{{- if eq .Values.database.type "postgresql" }}
value: {{ required "The database URI is required when using postgresql databases" .Values.database.uri | quote }}
{{- else }}
{{- fail "Unknown database type" }}
{{- end }}
{{- end }}
volumeMounts:
{{- if eq .Values.database.type "sqlite" }}
- name: db
mountPath: /data/db
{{- end }}
volumes:
{{- if eq .Values.database.type "sqlite" }}
- name: db
persistentVolumeClaim:
claimName: {{ include "versiago.fullname" . }}-db
{{- end }}