From 29760e8ecdd1493f276832ea3c08a5fd2c94b139 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 22 Jan 2024 07:36:42 -0500 Subject: [PATCH] feat: add support to tls for ingress-route If tls is enabled on the process, we create add the https entrypoint and also add the requisite tls secret-name --- plugins/scheduler-k3s/template.go | 9 ++------- .../scheduler-k3s/templates/ingress-routes-append.yaml | 9 ++++++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/scheduler-k3s/template.go b/plugins/scheduler-k3s/template.go index e2338ec86..3ea21ef1f 100644 --- a/plugins/scheduler-k3s/template.go +++ b/plugins/scheduler-k3s/template.go @@ -86,7 +86,7 @@ func createIngressRoutesFiles(input CreateIngressRoutesInput) error { return fmt.Errorf("Error reading ingress route append file: %w", err) } - contents := string(bytes.Join([][]byte{b, append}, []byte(""))) + contents := strings.Join([]string{strings.TrimSpace(string(b)), string(append)}, "") contents = strings.ReplaceAll(contents, " routes: null", "") contents = strings.Join([]string{ "{{- if .Values.processes.PROCESS_TYPE.domains }}", @@ -731,11 +731,6 @@ type IngressRoute struct { } func templateKubernetesIngressRoute(input IngressRoute) traefikv1alpha1.IngressRoute { - entryPoint := IngressRouteEntrypoint_HTTP - if input.PortMap.Scheme == "https" { - entryPoint = IngressRouteEntrypoint_HTTPS - } - labels := map[string]string{ "app.kubernetes.io/instance": fmt.Sprintf("%s-%s", input.AppName, input.ProcessType), "app.kubernetes.io/name": input.ProcessType, @@ -754,7 +749,7 @@ func templateKubernetesIngressRoute(input IngressRoute) traefikv1alpha1.IngressR Annotations: annotations, }, Spec: traefikv1alpha1.IngressRouteSpec{ - EntryPoints: []string{string(entryPoint)}, + EntryPoints: []string{string(IngressRouteEntrypoint_HTTP)}, }, } diff --git a/plugins/scheduler-k3s/templates/ingress-routes-append.yaml b/plugins/scheduler-k3s/templates/ingress-routes-append.yaml index a4b0a1e98..237ebeef9 100644 --- a/plugins/scheduler-k3s/templates/ingress-routes-append.yaml +++ b/plugins/scheduler-k3s/templates/ingress-routes-append.yaml @@ -1,3 +1,6 @@ + {{ if .Values.processes.PROCESS_TYPE.tls }} + - websecure + {{- end }} routes: {{- range .Values.processes.PROCESS_TYPE.domains }} - kind: Rule @@ -8,4 +11,8 @@ passHostHeader: true port: PORT_MAPPING scheme: PORT_SCHEME - {{- end }} \ No newline at end of file + {{- end }} + {{ if .Values.processes.PROCESS_TYPE.tls }} + tls: + secretName: tls-APP_NAME-PROCESS_TYPE + {{- end }}