fp/charts/trigger/templates/trigger.yaml

95 lines
2.9 KiB
YAML
Raw Normal View History

2024-07-10 02:34:23 +00:00
{{- $trigger := .Values.trigger -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "trigger.name" . }}
namespace: futureporn
annotations:
updatedAt: {{ now | date "2006-01-01 MST 15:04:05" | quote }}
{{- with $trigger.deploymentAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "trigger.labels" . | nindent 4 }}
spec:
replicas: {{ $trigger.replicaCount }}
selector:
matchLabels:
{{- include "trigger.matchLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "trigger.matchLabels" . | nindent 8 }}
annotations:
updatedAt: {{ now | date "2006-01-01 MST 15:04:05" | quote }}
{{- with $trigger.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with $trigger.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ $trigger.name }}
image: "{{ $trigger.image.repository }}:{{ $trigger.image.tag | default "latest" }}"
imagePullPolicy: {{ $trigger.image.pullPolicy }}
ports:
- name: http
containerPort: 3000
protocol: TCP
readinessProbe:
httpGet:
path: /
port: 3000
envFrom:
- secretRef:
name: {{ $trigger.kubeSecretRef | default (include "trigger.name" .) }}
{{- if $trigger.resources }}
resources: {{- toYaml $trigger.resources | nindent 12 }}
{{- end }}
---
apiVersion: v1
kind: Service
metadata:
name: trigger
labels:
annotations:
spec:
type: {{ $trigger.service.type }}
selector:
{{- include "trigger.matchLabels" . | nindent 8 }}
ports:
- port: 3000
targetPort: 3000
protocol: TCP
{{- if eq $trigger.service.type "NodePort" }}
nodePort: {{ $trigger.service.nodePort }}
{{- end }}
---
{{ if not $trigger.kubeSecretRef }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "trigger.name" . }}
annotations:
"helm.sh/resource-policy": "keep"
type: Opaque
stringData:
{{- $requiredVars := dict "MAGIC_LINK_SECRET" (randAlphaNum 32 | lower)
"SESSION_SECRET" (randAlphaNum 32 | lower)
"ENCRYPTION_KEY" (randAlphaNum 32 | lower)
"DIRECT_URL" (include "trigger.postgresql.connectionString" .)
"DATABASE_URL" (include "trigger.postgresql.connectionString" .) }}
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace (include "trigger.name" .)) | default dict }}
{{- $secretData := (get $secretObj "data") | default dict }}
{{ range $key, $value := .Values.trigger.env }}
{{- $default := get $requiredVars $key -}}
{{- $current := get $secretData $key | b64dec -}}
{{- $v := $value | default ($current | default $default) -}}
{{ $key }}: {{ $v | quote }}
{{ end -}}
{{- end }}