Merge pull request #7773 from dokku/7665-chart-override
Use values.yaml correctly within internal Kubernetes Helm Chart
This commit is contained in:
@@ -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 }}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
{{- $processName := "CRON_ID" }}
|
||||
{{- $config := index .Values.processes "CRON_ID" }}
|
||||
{{- range $processName, $config := .Values.processes }}
|
||||
# Only process cron jobs
|
||||
{{- if not (and (hasKey $config "cron") (hasKey $config.cron "id")) }}
|
||||
{{- continue }}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
@@ -113,3 +116,4 @@ spec:
|
||||
successfulJobsHistoryLimit: 10
|
||||
suspend: false
|
||||
timeZone: Etc/UTC
|
||||
{{- end }}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
{{- $mappings := dict }}
|
||||
{{- if eq $processName "web" }}
|
||||
{{- range $pdx, $port_map := $config.web.port_maps }}
|
||||
@@ -143,3 +147,4 @@ spec:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
{{- $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")) }}
|
||||
{{- if and ($.Capabilities.APIVersions.Has "http.keda.sh/v1alpha1") (and $config.autoscaling.http_trigger (eq $config.autoscaling.http_trigger.type "http")) }}
|
||||
{{- $routeToKeda = true }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -59,3 +63,4 @@ spec:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
{{- $processName := "PROCESS_NAME" }}
|
||||
{{- $config := index .Values.processes "PROCESS_NAME" }}
|
||||
{{- if .Capabilities.APIVersions.Has "http.keda.sh/v1alpha1" -}}
|
||||
{{- 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")) }}
|
||||
{{- if and $config.autoscaling.http_trigger (eq $config.autoscaling.http_trigger.type "http") }}
|
||||
{{- $mappings := dict }}
|
||||
{{- range $pdx, $port_map := $config.web.port_maps }}
|
||||
{{- $mappings := set $mappings $port_map.name "true" }}
|
||||
@@ -51,3 +56,5 @@ spec:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
{{- $processName := "PROCESS_NAME" }}
|
||||
{{- $config := index .Values.processes "PROCESS_NAME" }}
|
||||
{{- 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" -}}
|
||||
{{- 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"))) }}
|
||||
---
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
@@ -24,3 +28,4 @@ spec:
|
||||
externalName: keda-add-ons-http-interceptor-proxy.keda.svc.cluster.local
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
{{- $processName := "PROCESS_NAME" }}
|
||||
{{- $config := index .Values.processes "PROCESS_NAME" }}
|
||||
{{- if and $config.autoscaling (and $config.autoscaling.enabled (eq $config.autoscaling.type "keda")) }}
|
||||
{{- if .Capabilities.APIVersions.Has "keda.sh/v1alpha1" -}}
|
||||
{{- 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")) }}
|
||||
---
|
||||
apiVersion: keda.sh/v1alpha1
|
||||
kind: ScaledObject
|
||||
@@ -42,3 +46,4 @@ spec:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{{- if .Capabilities.APIVersions.Has "keda.sh/v1alpha1" -}}
|
||||
{{- $config := index .Values.global.keda.authentications "AUTH_NAME" }}
|
||||
{{- range $authName, $config := .Values.global.keda.authentications }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
@@ -21,3 +21,4 @@ data:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{{- if .Capabilities.APIVersions.Has "keda.sh/v1alpha1" -}}
|
||||
{{- $config := index .Values.global.keda.authentications "AUTH_NAME" }}
|
||||
{{- range $authName, $config := .Values.global.keda.authentications }}
|
||||
---
|
||||
apiVersion: keda.sh/v1alpha1
|
||||
kind: TriggerAuthentication
|
||||
@@ -26,3 +26,4 @@ spec:
|
||||
parameter: {{ $k }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -368,7 +368,7 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
|
||||
Processes: map[string]ProcessValues{},
|
||||
}
|
||||
|
||||
for authName := range kedaValues.Authentications {
|
||||
if len(kedaValues.Authentications) > 0 {
|
||||
templateFiles := []string{"keda-secret", "keda-trigger-authentication"}
|
||||
for _, templateName := range templateFiles {
|
||||
b, err := templates.ReadFile(fmt.Sprintf("templates/chart/%s.yaml", templateName))
|
||||
@@ -376,9 +376,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, authName))
|
||||
contents := strings.ReplaceAll(string(b), "AUTH_NAME", authName)
|
||||
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)
|
||||
}
|
||||
@@ -535,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)
|
||||
}
|
||||
@@ -613,15 +611,16 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
|
||||
Volumes: processVolumes,
|
||||
}
|
||||
values.Processes[cronEntry.ID] = processValues
|
||||
}
|
||||
|
||||
if len(cronEntries) > 0 {
|
||||
b, err := templates.ReadFile("templates/chart/cron-job.yaml")
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error reading cron job template: %w", err)
|
||||
}
|
||||
|
||||
cronFile := filepath.Join(chartDir, "templates", fmt.Sprintf("cron-job-%s.yaml", cronEntry.ID))
|
||||
contents := strings.ReplaceAll(string(b), "CRON_ID", cronEntry.ID)
|
||||
err = os.WriteFile(cronFile, []byte(contents), os.FileMode(0644))
|
||||
cronFile := filepath.Join(chartDir, "templates", "cron-job.yaml")
|
||||
err = os.WriteFile(cronFile, b, os.FileMode(0644))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error writing cron job template: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user