77 lines
2.5 KiB
YAML
77 lines
2.5 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ .Release.Name }}-web
|
|
spec:
|
|
replicas: {{ .Values.replicaCount }}
|
|
selector:
|
|
matchLabels:
|
|
app: {{ .Release.Name }}-web
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: {{ .Release.Name }}-web
|
|
spec:
|
|
# 1. INIT-CONTAINER: Sammelt statische Dateien beim Pod-Start
|
|
initContainers:
|
|
- name: collectstatic
|
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
python manage.py migrate --noinput && \
|
|
python manage.py collectstatic --noinput
|
|
env:
|
|
- name: DEBUG
|
|
value: {{ .Values.django.debug | quote }}
|
|
- name: SECRET_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ .Release.Name }}-secrets
|
|
key: django-secret-key
|
|
volumeMounts:
|
|
- name: static-assets
|
|
mountPath: /code/staticfiles
|
|
|
|
containers:
|
|
# 2. HAUPT-CONTAINER: Django / Gunicorn
|
|
- name: django
|
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
command: ["gunicorn", "boday_it.wsgi:application", "--bind", "0.0.0.0:8000"]
|
|
env:
|
|
- name: DEBUG
|
|
value: {{ .Values.django.debug | quote }}
|
|
- name: ALLOWED_HOSTS
|
|
value: {{ .Values.django.allowedHosts | quote }}
|
|
- name: SECRET_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ .Release.Name }}-secrets
|
|
key: django-secret-key
|
|
- name: DATABASE_URL
|
|
value: "postgres://{{ .Values.postgres.user }}:$(POSTGRES_PASSWORD)@{{ .Release.Name }}-db:5432/{{ .Values.postgres.database }}"
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ .Release.Name }}-secrets
|
|
key: postgres-password
|
|
ports:
|
|
- containerPort: 8000
|
|
name: webport
|
|
|
|
# 3. SIDECAR-CONTAINER: Nginx für superschnelles Static-Asset Delivery
|
|
- name: nginx-static
|
|
image: nginx:alpine
|
|
volumeMounts:
|
|
- name: static-assets
|
|
mountPath: /usr/share/nginx/html/static
|
|
ports:
|
|
- containerPort: 80
|
|
name: staticport
|
|
|
|
volumes:
|
|
- name: static-assets
|
|
emptyDir: {}
|