uncloud-mravi/k8s/templates/deployment.yaml
Nico Schottelius 2599df6408 k8s: phase in first version
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
2021-12-19 23:18:50 +01:00

181 lines
4.8 KiB
YAML

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-postgres
spec:
selector:
matchLabels:
instance: {{ .Release.Name }}-postgres
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: postgres
instance: {{ .Release.Name }}-postgres
hosting: {{ .Release.Name }}
spec:
containers:
- name: postgres
image: postgres:14
ports:
- containerPort: 5432
envFrom:
- secretRef:
name: {{ .Release.Name }}-postgres-config
volumeMounts:
- name: postgres-data
mountPath: "/var/lib/postgresql/data"
subPath: postgres
resources:
requests:
memory: "64Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "400m"
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: {{ .Release.Name }}-postgres-data
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-postgres
labels:
instance: {{ .Release.Name }}-postgres
app: postgres
hosting: {{ .Release.Name }}
spec:
type: ClusterIP
ports:
- port: 5432
name: postgres
selector:
instance: {{ .Release.Name }}-postgres
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-uncloud
spec:
selector:
matchLabels:
app: {{ .Release.Name }}-uncloud
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: {{ .Release.Name }}-uncloud
use-as-service: {{ .Release.Name }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/nginxconf.yaml") . | sha256sum }}
spec:
containers:
- name: nginx
image: ungleich/ungleich-certbot:0.3.2
ports:
- containerPort: 443
name: https
- containerPort: 80
name: http
env:
- name: DOMAIN
value: "{{ tpl .Values.fqdn . }}"
- name: EMAIL
value: "{{ .Values.email }}"
- name: NGINX
value: "yes"
{{ if eq .Values.letsencryptStaging "no" }}
- name: STAGING
value: "no"
{{ end }}
volumeMounts:
- name: nginx-config
mountPath: "/etc/nginx/conf.d/"
- name: etcletsencrypt
mountPath: "/etc/letsencrypt"
- name: uncloud
image: harbor.ungleich.svc.p10.k8s.ooo/ungleich-public/uncloud:{{ .Chart.AppVersion }}
ports:
- containerPort: 3000
securityContext:
capabilities:
add:
- SYS_CHROOT
env:
- name: USER_UID
value: "1000"
- name: USER_GID
value: "1000"
- name: UNCLOUD__server__DOMAIN
value: "{{ tpl .Values.fqdn . }}"
# Require, otherwise the port :3000 is included
- name: UNCLOUD__server__ROOT_URL
value: "https://{{ tpl .Values.fqdn . }}"
- name: UNCLOUD__database__DB_TYPE
value: "postgres"
- name: UNCLOUD__database__HOST
value: {{ .Release.Name }}-postgres
- name: UNCLOUD__database__NAME
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-postgres-config
key: POSTGRES_DB
- name: UNCLOUD__database__USER
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-postgres-config
key: POSTGRES_USER
- name: UNCLOUD__database__PASSWD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-postgres-config
key: POSTGRES_PASSWORD
volumeMounts:
- name: data
mountPath: "/data"
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ .Release.Name }}-data
- name: etcletsencrypt
persistentVolumeClaim:
claimName: {{ .Release.Name }}-letsencrypt-certs
- name: nginx-config
configMap:
name: {{ .Release.Name }}-nginx-config
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}
labels:
app: {{ .Release.Name }}
spec:
type: ClusterIP
ports:
- port: 22
name: ssh
- port: 80
name: http
- port: 443
name: https
selector:
use-as-service: {{ .Release.Name }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-postgres-config
annotations:
secret-generator.v1.mittwald.de/autogenerate: POSTGRES_PASSWORD
hosting: {{ .Release.Name }}
stringData:
POSTGRES_USER: "uncloud"
POSTGRES_DB: "uncloud"