forked from LaconicNetwork/kompose
TLS improvements (#1317)
* Fix tls hostname for ingress with path * Possibility to set ExposeServiceTLS to true * keep full path when extracting host Co-authored-by: Tomas Kral <tomas.kral@gmail.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
|||||||
|
name: Go
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Set up Go 1.x
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ^1.13
|
||||||
|
id: go
|
||||||
|
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: make bin
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: make test
|
||||||
|
|
||||||
|
- name: Upload a Build Artifact
|
||||||
|
uses: actions/upload-artifact@v2.1.4
|
||||||
|
with:
|
||||||
|
path: "kompose"
|
||||||
@@ -421,7 +421,7 @@ func (k *Kubernetes) initIngress(name string, service kobject.ServiceConfig, por
|
|||||||
Rules: make([]networkingv1beta1.IngressRule, len(hosts)),
|
Rules: make([]networkingv1beta1.IngressRule, len(hosts)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
tlsHosts := make([]string, len(hosts))
|
||||||
for i, host := range hosts {
|
for i, host := range hosts {
|
||||||
host, p := transformer.ParseIngressPath(host)
|
host, p := transformer.ParseIngressPath(host)
|
||||||
ingress.Spec.Rules[i] = networkingv1beta1.IngressRule{
|
ingress.Spec.Rules[i] = networkingv1beta1.IngressRule{
|
||||||
@@ -443,15 +443,23 @@ func (k *Kubernetes) initIngress(name string, service kobject.ServiceConfig, por
|
|||||||
}
|
}
|
||||||
if host != "true" {
|
if host != "true" {
|
||||||
ingress.Spec.Rules[i].Host = host
|
ingress.Spec.Rules[i].Host = host
|
||||||
|
tlsHosts[i] = host
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if service.ExposeServiceTLS != "" {
|
if service.ExposeServiceTLS != "" {
|
||||||
ingress.Spec.TLS = []networkingv1beta1.IngressTLS{
|
if service.ExposeServiceTLS != "true" {
|
||||||
{
|
ingress.Spec.TLS = []networkingv1beta1.IngressTLS{
|
||||||
Hosts: hosts,
|
{
|
||||||
SecretName: service.ExposeServiceTLS,
|
Hosts: tlsHosts,
|
||||||
},
|
SecretName: service.ExposeServiceTLS,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ingress.Spec.TLS = []networkingv1beta1.IngressTLS{
|
||||||
|
{
|
||||||
|
Hosts: tlsHosts,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ func ParseVolume(volume string) (name, host, container, mode string, err error)
|
|||||||
func ParseIngressPath(url string) (string, string) {
|
func ParseIngressPath(url string) (string, string) {
|
||||||
if strings.Contains(url, "/") {
|
if strings.Contains(url, "/") {
|
||||||
splits := strings.Split(url, "/")
|
splits := strings.Split(url, "/")
|
||||||
return splits[0], "/" + splits[1]
|
return splits[0], "/" + strings.Join(splits[1:], "/")
|
||||||
}
|
}
|
||||||
return url, ""
|
return url, ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user