browsertrix/chart/templates/frontend.yaml
Ilya Kreymer 05c1129fb8
Frontend + Backend Integrated Deployment (K8s only) (#45)
* support running backend + frontend together on k8s
* split nginx container into separate frontend service, which uses nignx-base image and the static frontend files
* add nginx-based frontend image to docker-compose build (for building only, docker-based combined deployment not yet supported)

* backend:
- fix paths for email templates
- chart: support '--set backend_only=1' and '--set frontend_only=1' to only force deploy one or the other
- run backend from root /api in uvicorn
2021-12-03 10:17:22 -08:00

100 lines
2.1 KiB
YAML

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.name }}-frontend
namespace: {{ .Release.Namespace }}
spec:
selector:
matchLabels:
app: {{ .Values.name }}
role: frontend
replicas: 1
template:
metadata:
labels:
app: {{ .Values.name }}
role: frontend
annotations:
# force helm to update the deployment each time
{{- if not .Values.backend_only }}
"helm.update": {{ randAlphaNum 5 | quote }}
{{- end }}
spec:
volumes:
- name: nginx-resolver
emptyDir: {}
initContainers:
- name: init-nginx
image: {{ .Values.nginx_image }}
command: ["/bin/sh"]
args: ["-c", "echo resolver $(awk 'BEGIN{ORS=\" \"} $1==\"nameserver\" {print $2}' /etc/resolv.conf) valid=30s \";\" > /etc/nginx/resolvers/resolvers.conf"]
volumeMounts:
- name: nginx-resolver
mountPath: /etc/nginx/resolvers/
containers:
- name: nginx
image: {{ .Values.nginx_image }}
imagePullPolicy: {{ .Values.nginx_pull_policy }}
volumeMounts:
- name: nginx-resolver
mountPath: /etc/nginx/resolvers/
readOnly: true
resources:
limits:
cpu: {{ .Values.nginx_limit_cpu }}
requests:
cpu: {{ .Values.nginx_requests_cpu }}
readinessProbe:
httpGet:
path: /healthz
port: 80
---
apiVersion: v1
kind: Service
metadata:
namespace: {{ .Release.Namespace }}
name: {{ .Values.name }}-frontend
labels:
app: {{ .Values.name }}
role: frontend
{{- if .Values.service }}
{{- if .Values.service.annotations }}
annotations:
{{- range $key, $val := .Values.service.annotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
{{- end }}
spec:
selector:
app: {{ .Values.name }}
role: frontend
{{- if .Values.service }}
{{- if .Values.service.type }}
type: {{ .Values.service.type | quote }}
{{- end }}
{{- end }}
ports:
- protocol: TCP
port: 80
name: frontend