a3ce2d473c
Ship Proxmox, oVirt, VMware, and OpenStack behind one Postgres stack, Makefile helpers (up/clean/helm up|down/push), and a Helm chart with namespace, Let's Encrypt ingresses, migrate inits, and skip-if-seeded jobs.
112 lines
3.6 KiB
YAML
112 lines
3.6 KiB
YAML
{{- range $name, $sim := .Values.simulators }}
|
|
{{- if $sim.enabled }}
|
|
{{- $fullname := printf "%s-%s" (include "lab.fullname" $) $name }}
|
|
{{- $tag := $sim.image.tag | default $.Values.imageTag }}
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: {{ $fullname }}
|
|
namespace: {{ include "lab.namespace" $ }}
|
|
labels:
|
|
{{- include "lab.labels" $ | nindent 4 }}
|
|
app.kubernetes.io/component: {{ $name }}
|
|
spec:
|
|
type: ClusterIP
|
|
ports:
|
|
- name: http
|
|
port: {{ $sim.port }}
|
|
targetPort: http
|
|
protocol: TCP
|
|
selector:
|
|
{{- include "lab.selectorLabels" $ | nindent 4 }}
|
|
app.kubernetes.io/component: {{ $name }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ $fullname }}
|
|
namespace: {{ include "lab.namespace" $ }}
|
|
labels:
|
|
{{- include "lab.labels" $ | nindent 4 }}
|
|
app.kubernetes.io/component: {{ $name }}
|
|
spec:
|
|
replicas: {{ $sim.replicas | default 1 }}
|
|
selector:
|
|
matchLabels:
|
|
{{- include "lab.selectorLabels" $ | nindent 6 }}
|
|
app.kubernetes.io/component: {{ $name }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
{{- include "lab.selectorLabels" $ | nindent 8 }}
|
|
app.kubernetes.io/component: {{ $name }}
|
|
spec:
|
|
{{- with $.Values.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
initContainers:
|
|
- name: wait-postgres
|
|
image: "{{ $.Values.postgres.image.repository }}:{{ $.Values.postgres.image.tag }}"
|
|
imagePullPolicy: {{ $.Values.postgres.image.pullPolicy }}
|
|
command:
|
|
- sh
|
|
- -ec
|
|
- |
|
|
until pg_isready -h {{ include "lab.postgresHost" $ }} -p 5432 -U {{ $.Values.postgres.auth.username }}; do
|
|
echo "waiting for postgres..."; sleep 2;
|
|
done
|
|
{{- if and $sim.migrate $sim.migrate.enabled }}
|
|
- name: migrate
|
|
image: "{{ $sim.image.repository }}:{{ $tag }}"
|
|
imagePullPolicy: {{ $sim.image.pullPolicy }}
|
|
# Idempotent: migrate_cli applies 0 migrations when schema is already current.
|
|
command: {{- toYaml $sim.migrate.command | nindent 12 }}
|
|
env:
|
|
{{- include "lab.commonEnv" $ | nindent 12 }}
|
|
- name: DATABASE_URL
|
|
value: {{ include "lab.databaseUrl" (dict "root" $ "sim" $sim) | quote }}
|
|
{{- range $k, $v := $sim.env }}
|
|
- name: {{ $k }}
|
|
value: {{ $v | quote }}
|
|
{{- end }}
|
|
{{- end }}
|
|
containers:
|
|
- name: simulator
|
|
image: "{{ $sim.image.repository }}:{{ $tag }}"
|
|
imagePullPolicy: {{ $sim.image.pullPolicy }}
|
|
ports:
|
|
- name: http
|
|
containerPort: {{ $sim.port }}
|
|
protocol: TCP
|
|
env:
|
|
{{- include "lab.commonEnv" $ | nindent 12 }}
|
|
- name: DATABASE_URL
|
|
value: {{ include "lab.databaseUrl" (dict "root" $ "sim" $sim) | quote }}
|
|
{{- range $k, $v := $sim.env }}
|
|
- name: {{ $k }}
|
|
value: {{ $v | quote }}
|
|
{{- end }}
|
|
readinessProbe:
|
|
httpGet:
|
|
path: {{ $sim.healthPath }}
|
|
port: http
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 10
|
|
timeoutSeconds: 3
|
|
failureThreshold: 10
|
|
livenessProbe:
|
|
httpGet:
|
|
path: {{ $sim.healthPath }}
|
|
port: http
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 20
|
|
timeoutSeconds: 3
|
|
{{- with $sim.resources }}
|
|
resources:
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
---
|
|
{{- end }}
|
|
{{- end }}
|