refactor: move templating into pseudo-generated helm chart
The previous mechanism of constructing the helm chart was pretty obnoxious due to needing to have some things in the object and some in template files that were appended afterwards. This change simplifies that by using template files per type with minimal replacements.
This commit is contained in:
1 parent
75539273e3
commit
2336063ca2
15 files changed
+752
-970
No files matched your search
@@ -0,0 +1,32 @@
|
||||
{{- $processName := "PROCESS_NAME" }}
|
||||
{{- $config := .Values.processes.PROCESS_NAME }}
|
||||
{{- if and $config.web.tls $config.domains }}
|
||||
---
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
annotations:
|
||||
dokku.com/managed: "true"
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
name: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
namespace: {{ $.Values.global.namespace }}
|
||||
spec:
|
||||
issuerRef:
|
||||
kind: ClusterIssuer
|
||||
name: {{ $config.tls.issuer_name }}
|
||||
secretName: tls-{{ $.Values.global.app_name }}-{{ $processName }}
|
||||
secretTemplate:
|
||||
annotations:
|
||||
dokku.com/managed: "true"
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
status: {}
|
||||
dnsNames:
|
||||
{{- range $config.domains }}
|
||||
- {{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,103 @@
|
||||
{{- $processName := "CRON_ID" }}
|
||||
{{- $config := .Values.processes.CRON_ID }}
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
annotations:
|
||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
||||
dokku.com/builder-type: {{ $.Values.global.image.type }}
|
||||
dokku.com/cron-id: {{ $config.cron.id }}
|
||||
dokku.com/job-suffix: {{ $config.cron.suffix }}
|
||||
dokku.com/managed: "true"
|
||||
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-cron
|
||||
labels:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-cron-{{ $config.cron.suffix }}
|
||||
app.kubernetes.io/name: cron
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
dokku.com/cron-id: {{ $config.cron.id }}
|
||||
name: {{ $.Values.global.app_name }}-cron-{{ $config.cron.suffix }}
|
||||
namespace: default
|
||||
spec:
|
||||
concurrencyPolicy: Allow
|
||||
failedJobsHistoryLimit: 10
|
||||
jobTemplate:
|
||||
metadata:
|
||||
annotations:
|
||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
||||
dokku.com/builder-type: {{ $.Values.global.image.type }}
|
||||
dokku.com/cron-id: {{ $config.cron.id }}
|
||||
dokku.com/job-suffix: {{ $config.cron.suffix }}
|
||||
dokku.com/managed: "true"
|
||||
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-cron
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-cron-{{ $config.cron.suffix }}
|
||||
app.kubernetes.io/name: cron
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
dokku.com/cron-id: {{ $config.cron.id }}
|
||||
spec:
|
||||
backoffLimit: 0
|
||||
podReplacementPolicy: Failed
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
||||
dokku.com/builder-type: {{ $.Values.global.image.type }}
|
||||
dokku.com/cron-id: {{ $config.cron.id }}
|
||||
dokku.com/job-suffix: {{ $config.cron.suffix }}
|
||||
dokku.com/managed: "true"
|
||||
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-cron
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-cron-{{ $config.cron.suffix }}
|
||||
app.kubernetes.io/name: cron
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
dokku.com/cron-id: {{ $config.cron.id }}
|
||||
spec:
|
||||
containers:
|
||||
- args:
|
||||
{{- range $config.args }}
|
||||
- {{ . }}
|
||||
{{- end }}
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
|
||||
optional: true
|
||||
image: {{ $.Values.global.image.name }}
|
||||
imagePullPolicy: Always
|
||||
name: {{ $.Values.global.app_name }}-cron
|
||||
{{- if and $config.resources (or $config.resources.limits $config.resources.requests) }}
|
||||
resources:
|
||||
{{- if $config.resources.limits }}
|
||||
limits:
|
||||
{{- if $config.resources.limits.cpu }}
|
||||
cpu: {{ $config.resources.limits.cpu }}
|
||||
{{- end }}
|
||||
{{- if $config.resources.limits.memory }}
|
||||
memory: {{ $config.resources.limits.memory }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $config.resources.requests }}
|
||||
requests:
|
||||
{{- if $config.resources.requests.cpu }}
|
||||
cpu: {{ $config.resources.requests.cpu }}
|
||||
{{- end }}
|
||||
{{- if $config.resources.requests.memory }}
|
||||
memory: {{ $config.resources.requests.memory }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $.Values.global.image.working_dir }}
|
||||
workingDir: {{ $.Values.global.image.working_dir }}
|
||||
{{- end }}
|
||||
{{- if $.Values.global.image.image_pull_secrets }}
|
||||
imagePullSecrets: {{ $.Values.global.image.image_pull_secrets }}
|
||||
{{- end }}
|
||||
restartPolicy: Never
|
||||
ttlSecondsAfterFinished: 60
|
||||
schedule: {{ $config.cron.schedule }}
|
||||
startingDeadlineSeconds: 60
|
||||
successfulJobsHistoryLimit: 10
|
||||
suspend: false
|
||||
timeZone: Etc/UTC
|
||||
@@ -0,0 +1,96 @@
|
||||
{{- $processName := "PROCESS_NAME" }}
|
||||
{{- $config := .Values.processes.PROCESS_NAME }}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
||||
dokku.com/builder-type: {{ $.Values.global.image.type }}
|
||||
dokku.com/managed: "true"
|
||||
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
app.kubernetes.io/name: {{ $processName }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
name: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
namespace: default
|
||||
spec:
|
||||
replicas: {{ $config.replicas }}
|
||||
revisionHistoryLimit: 5
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
app.kubernetes.io/name: {{ $processName }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
strategy: {}
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
||||
dokku.com/builder-type: {{ $.Values.global.image.type }}
|
||||
dokku.com/managed: "true"
|
||||
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
app.kubernetes.io/name: {{ $processName }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
spec:
|
||||
containers:
|
||||
- args:
|
||||
{{- range $config.args }}
|
||||
- {{ . }}
|
||||
{{- end }}
|
||||
{{- if eq $processName "web" }}
|
||||
env:
|
||||
- name: PORT
|
||||
value: "{{ $.Values.global.primary_port }}"
|
||||
{{- end }}
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
|
||||
optional: true
|
||||
image: {{ $.Values.global.image.name }}
|
||||
imagePullPolicy: Always
|
||||
name: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
{{- if eq $processName "web" }}
|
||||
ports:
|
||||
{{- range $pdx, $port_map := $config.web.port_maps }}
|
||||
- containerPort: {{ $port_map.container_port }}
|
||||
name: {{ $port_map.name }}
|
||||
protocol: {{ $port_map.protocol }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and $config.resources (or $config.resources.limits $config.resources.requests) }}
|
||||
resources:
|
||||
{{- if $config.resources.limits }}
|
||||
limits:
|
||||
{{- if $config.resources.limits.cpu }}
|
||||
cpu: {{ $config.resources.limits.cpu }}
|
||||
{{- end }}
|
||||
{{- if $config.resources.limits.memory }}
|
||||
memory: {{ $config.resources.limits.memory }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $config.resources.requests }}
|
||||
requests:
|
||||
{{- if $config.resources.requests.cpu }}
|
||||
cpu: {{ $config.resources.requests.cpu }}
|
||||
{{- end }}
|
||||
{{- if $config.resources.requests.memory }}
|
||||
memory: {{ $config.resources.requests.memory }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $config.healthchecks.startup }}
|
||||
startupProbe:
|
||||
{{ $config.healthchecks.startup | toJson | indent 10 }}
|
||||
{{- end }}
|
||||
{{- if $.Values.global.image.working_dir }}
|
||||
workingDir: {{ $.Values.global.image.working_dir }}
|
||||
{{- end }}
|
||||
{{- if $.Values.global.image.image_pull_secrets }}
|
||||
imagePullSecrets: {{ $.Values.global.image.image_pull_secrets }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,35 @@
|
||||
{{- $processName := "PROCESS_NAME" }}
|
||||
{{- $config := .Values.processes.PROCESS_NAME }}
|
||||
{{- if $config.web.domains }}
|
||||
{{- range $pdx, $port_map := $config.web.port_maps }}
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
annotations:
|
||||
dokku.com/managed: "true"
|
||||
labels:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
app.kubernetes.io/name: {{ $processName }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
name: {{ $.Values.global.app_name }}-{{ $processName }}-{{ $port_map.name }}
|
||||
namespace: {{ $.Values.global.namespace }}
|
||||
spec:
|
||||
entryPoints:
|
||||
- web
|
||||
{{- if and $config.web.tls (eq $port_map "https") }}
|
||||
- websecure
|
||||
{{- end }}
|
||||
routes:
|
||||
{{- range $ddx, $domain := $config.web.domains }}
|
||||
- kind: Rule
|
||||
match: Host(`{{ $domain }}`)
|
||||
services:
|
||||
- name: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
namespace: {{ $.Values.global.namespace }}
|
||||
passHostHeader: true
|
||||
port: {{ $port_map.name }}
|
||||
scheme: {{ $port_map.scheme }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
annotations:
|
||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
||||
dokku.com/managed: "true"
|
||||
labels:
|
||||
app.kubernetes.io/instance: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
|
||||
app.kubernetes.io/name: env-{{ $.Values.global.app_name }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
|
||||
namespace: {{ $.Values.global.namespace }}
|
||||
{{- with .Values.global.secrets }}
|
||||
data:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,26 @@
|
||||
{{- $processName := "PROCESS_NAME" }}
|
||||
{{- $config := .Values.processes.PROCESS_NAME }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
dokku.com/managed: "true"
|
||||
labels:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
app.kubernetes.io/name: {{ $processName }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
name: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
namespace: default
|
||||
spec:
|
||||
ports:
|
||||
{{- range $pdx, $port_map := $config.web.port_maps }}
|
||||
- name: {{ $port_map.name }}
|
||||
port: {{ $port_map.host_port }}
|
||||
protocol: TCP
|
||||
targetPort: {{ $port_map.name }}
|
||||
{{- end }}
|
||||
selector:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
app.kubernetes.io/name: {{ $processName }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
Reference in new issue
Block a user