refactor: simplify tls handling by always redirecting
This commit is contained in:
@@ -161,12 +161,11 @@ type ProcessCron struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ProcessPortMap struct {
|
type ProcessPortMap struct {
|
||||||
ContainerPort int32 `yaml:"container_port"`
|
ContainerPort int32 `yaml:"container_port"`
|
||||||
HostPort int32 `yaml:"host_port"`
|
HostPort int32 `yaml:"host_port"`
|
||||||
Scheme string `yaml:"scheme"`
|
Scheme string `yaml:"scheme"`
|
||||||
Protocol PortmapProtocol `yaml:"protocol"`
|
Protocol PortmapProtocol `yaml:"protocol"`
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
RedirectToHttps bool `yaml:"redirect_to_https"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PortmapProtocol string
|
type PortmapProtocol string
|
||||||
|
|||||||
@@ -26,16 +26,15 @@ metadata:
|
|||||||
namespace: {{ $.Values.global.namespace }}
|
namespace: {{ $.Values.global.namespace }}
|
||||||
spec:
|
spec:
|
||||||
entryPoints:
|
entryPoints:
|
||||||
{{- if and $config.web.tls.enabled (eq $port_map.scheme "https") }}
|
{{- if $config.web.tls.enabled }}
|
||||||
- websecure
|
- websecure
|
||||||
{{- else }}
|
|
||||||
- web
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
- web
|
||||||
routes:
|
routes:
|
||||||
{{- range $ddx, $domain := $config.web.domains }}
|
{{- range $ddx, $domain := $config.web.domains }}
|
||||||
- kind: Rule
|
- kind: Rule
|
||||||
match: Host(`{{ $domain }}`)
|
match: Host(`{{ $domain }}`)
|
||||||
{{- if and $config.web.tls.enabled (and (eq $port_map.scheme "http") $port_map.redirect_to_https) }}
|
{{- if $config.web.tls.enabled }}
|
||||||
middlewares:
|
middlewares:
|
||||||
- name: {{ $.Values.global.app_name}}-{{ $processName }}-redirect-to-https
|
- name: {{ $.Values.global.app_name}}-{{ $processName }}-redirect-to-https
|
||||||
namespace: {{ $.Values.global.namespace }}
|
namespace: {{ $.Values.global.namespace }}
|
||||||
@@ -47,7 +46,7 @@ spec:
|
|||||||
port: {{ $port_map.name }}
|
port: {{ $port_map.name }}
|
||||||
scheme: http
|
scheme: http
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if and $config.web.tls.enabled (eq $port_map.scheme "https") }}
|
{{- if $config.web.tls.enabled }}
|
||||||
tls:
|
tls:
|
||||||
secretName: tls-{{ $.Values.global.app_name }}-{{ $processName }}
|
secretName: tls-{{ $.Values.global.app_name }}-{{ $processName }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ metadata:
|
|||||||
{{ $k }}: {{ $v | quote }}
|
{{ $k }}: {{ $v | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if $config.web.tls.enabled }}
|
||||||
|
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
|
||||||
|
{{- end }}
|
||||||
labels:
|
labels:
|
||||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}
|
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||||
app.kubernetes.io/name: {{ $processName }}
|
app.kubernetes.io/name: {{ $processName }}
|
||||||
@@ -26,7 +29,7 @@ metadata:
|
|||||||
namespace: {{ $.Values.global.namespace }}
|
namespace: {{ $.Values.global.namespace }}
|
||||||
spec:
|
spec:
|
||||||
ingressClassName: nginx
|
ingressClassName: nginx
|
||||||
{{- if and $config.web.tls.enabled (eq $port_map.scheme "https") }}
|
{{- if $config.web.tls.enabled }}
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
{{- range $ddx, $domain := $config.web.domains }}
|
{{- range $ddx, $domain := $config.web.domains }}
|
||||||
|
|||||||
@@ -417,17 +417,12 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
|
|||||||
protocol = PortmapProtocol_UDP
|
protocol = PortmapProtocol_UDP
|
||||||
}
|
}
|
||||||
|
|
||||||
redirecToHttps := false
|
|
||||||
if _, ok := portMaps[fmt.Sprintf("https-443-%d", portMap.ContainerPort)]; ok && portMap.Scheme == "http" {
|
|
||||||
redirecToHttps = true
|
|
||||||
}
|
|
||||||
processValues.Web.PortMaps = append(processValues.Web.PortMaps, ProcessPortMap{
|
processValues.Web.PortMaps = append(processValues.Web.PortMaps, ProcessPortMap{
|
||||||
ContainerPort: portMap.ContainerPort,
|
ContainerPort: portMap.ContainerPort,
|
||||||
HostPort: portMap.HostPort,
|
HostPort: portMap.HostPort,
|
||||||
Name: portMap.String(),
|
Name: portMap.String(),
|
||||||
Protocol: protocol,
|
Protocol: protocol,
|
||||||
RedirectToHttps: redirecToHttps,
|
Scheme: portMap.Scheme,
|
||||||
Scheme: portMap.Scheme,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user