refactor use chart values directly instead of attempting to template out cron-job and keda files

This commit is contained in:
Jose Diaz-Gonzalez
2025-07-04 02:04:45 -04:00
parent 1b95e01ea3
commit c472c2a3c7
9 changed files with 58 additions and 19 deletions

View File

@@ -1,5 +1,9 @@
{{- $processName := "PROCESS_NAME" }}
{{- $config := index .Values.processes "PROCESS_NAME" }}
{{- range $processName, $config := .Values.processes }}
# Skip cron jobs
{{- if and (hasKey $config "cron") (hasKey $config.cron "id") }}
{{- continue }}
{{- end }}
{{- if and $config.web.tls.enabled $config.web.domains }}
---
apiVersion: cert-manager.io/v1
@@ -34,3 +38,4 @@ spec:
- {{ $domain.name }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -1,5 +1,9 @@
{{- $processName := "PROCESS_NAME" }}
{{- $config := index .Values.processes "PROCESS_NAME" }}
{{- range $processName, $config := .Values.processes }}
# Skip cron jobs
{{- if and (hasKey $config "cron") (hasKey $config.cron "id") }}
{{- continue }}
{{- end }}
{{- if and $config.web.domains (eq $.Values.global.network.ingress_class "traefik") }}
---
apiVersion: traefik.io/v1alpha1
@@ -22,3 +26,4 @@ spec:
scheme: https
permanent: true
{{- end }}
{{- end }}

View File

@@ -1,5 +1,9 @@
{{- $processName := "PROCESS_NAME" }}
{{- $config := index .Values.processes "PROCESS_NAME" }}
{{- range $processName, $config := .Values.processes }}
# Skip cron jobs
{{- if and (hasKey $config "cron") (hasKey $config.cron "id") }}
{{- continue }}
{{- end }}
{{- if and $config.web.domains (eq $.Values.global.network.ingress_class "traefik") }}
{{- $mappings := dict }}
{{- range $pdx, $port_map := $config.web.port_maps }}
@@ -53,3 +57,4 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -1,5 +1,9 @@
{{- $processName := "PROCESS_NAME" }}
{{- $config := index .Values.processes "PROCESS_NAME" }}
{{- range $processName, $config := .Values.processes }}
# Skip cron jobs
{{- if and (hasKey $config "cron") (hasKey $config.cron "id") }}
{{- continue }}
{{- end }}
{{- $routeToKeda := false }}
{{- if and (eq $processName "web") (and $config.autoscaling (and $config.autoscaling.enabled (eq $config.autoscaling.type "keda"))) }}
{{- if and (.Capabilities.APIVersions.Has "http.keda.sh/v1alpha1") (and $config.autoscaling.http_trigger (eq $config.autoscaling.http_trigger.type "http")) }}
@@ -59,3 +63,4 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -1,5 +1,9 @@
{{- $processName := "PROCESS_NAME" }}
{{- $config := index .Values.processes "PROCESS_NAME" }}
{{- range $processName, $config := .Values.processes }}
# Skip cron jobs
{{- if and (hasKey $config "cron") (hasKey $config.cron "id") }}
{{- continue }}
{{- end }}
{{- if and (eq $processName "web") (and $config.autoscaling (and $config.autoscaling.enabled (eq $config.autoscaling.type "keda"))) }}
{{- if and (.Capabilities.APIVersions.Has "http.keda.sh/v1alpha1") (and $config.autoscaling.http_trigger (eq $config.autoscaling.http_trigger.type "http")) }}
{{- $mappings := dict }}
@@ -51,3 +55,4 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -1,5 +1,9 @@
{{- $processName := "PROCESS_NAME" }}
{{- $config := index .Values.processes "PROCESS_NAME" }}
{{- range $processName, $config := .Values.processes }}
# Skip cron jobs
{{- if and (hasKey $config "cron") (hasKey $config.cron "id") }}
{{- continue }}
{{- end }}
{{- if and (eq $processName "web") (and $config.autoscaling (and $config.autoscaling.enabled (eq $config.autoscaling.type "keda"))) }}
{{- if .Capabilities.APIVersions.Has "http.keda.sh/v1alpha1" -}}
---
@@ -24,3 +28,4 @@ spec:
externalName: keda-add-ons-http-interceptor-proxy.keda.svc.cluster.local
{{- end }}
{{- end }}
{{- end }}

View File

@@ -1,5 +1,9 @@
{{- $processName := "PROCESS_NAME" }}
{{- $config := index .Values.processes "PROCESS_NAME" }}
{{- range $processName, $config := .Values.processes }}
# Skip cron jobs
{{- if and (hasKey $config "cron") (hasKey $config.cron "id") }}
{{- continue }}
{{- end }}
{{- if and $config.autoscaling (and $config.autoscaling.enabled (eq $config.autoscaling.type "keda")) }}
{{- if .Capabilities.APIVersions.Has "keda.sh/v1alpha1" -}}
---
@@ -42,3 +46,4 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -1,5 +1,9 @@
{{- $processName := "PROCESS_NAME" }}
{{- $config := index .Values.processes "PROCESS_NAME" }}
{{- range $processName, $config := .Values.processes }}
# Skip cron jobs
{{- if and (hasKey $config "cron") (hasKey $config.cron "id") }}
{{- continue }}
{{- end }}
---
apiVersion: v1
kind: Service
@@ -28,3 +32,4 @@ spec:
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}
app.kubernetes.io/name: {{ $processName }}
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
{{- end }}

View File

@@ -534,9 +534,8 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
return fmt.Errorf("Error reading %s template: %w", templateName, err)
}
filename := filepath.Join(chartDir, "templates", fmt.Sprintf("%s-%s.yaml", templateName, processType))
contents := strings.ReplaceAll(string(b), "PROCESS_NAME", processType)
err = os.WriteFile(filename, []byte(contents), os.FileMode(0644))
filename := filepath.Join(chartDir, "templates", fmt.Sprintf("%s.yaml", templateName))
err = os.WriteFile(filename, b, os.FileMode(0644))
if err != nil {
return fmt.Errorf("Error writing %s template: %w", templateName, err)
}