Skip to content

Commit

Permalink
Correct Kubernetes Ingress and IngressRoute port heuristic for choosi…
Browse files Browse the repository at this point in the history
…ng HTTPS
  • Loading branch information
seh authored and traefiker committed Aug 14, 2019
1 parent 5731ae7 commit 2895ad2
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion pkg/provider/kubernetes/crd/fixtures/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ spec:
ports:
- name: web-secure
port: 443
targetPort: 8443
selector:
app: containous
task: whoami2
Expand All @@ -85,7 +86,7 @@ subsets:
- ip: 10.10.0.6
ports:
- name: web-secure
port: 443
port: 8443

---
apiVersion: v1
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/kubernetes/crd/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func loadServers(client Client, namespace string, svc v1alpha1.Service) ([]dynam
case "http", "https", "h2c":
protocol = svc.Scheme
case "":
if port == 443 || strings.HasPrefix(portSpec.Name, "https") {
if portSpec.Port == 443 || strings.HasPrefix(portSpec.Name, "https") {
protocol = "https"
}
default:
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/kubernetes/crd/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1324,10 +1324,10 @@ func TestLoadIngressRoutes(t *testing.T) {
LoadBalancer: &dynamic.LoadBalancerService{
Servers: []dynamic.Server{
{
URL: "https://10.10.0.5:443",
URL: "https://10.10.0.5:8443",
},
{
URL: "https://10.10.0.6:443",
URL: "https://10.10.0.6:8443",
},
},
PassHostHeader: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ subsets:
- addresses:
- ip: 10.10.0.1
ports:
- port: 443
- port: 8443
- addresses:
- ip: 10.21.0.1
ports:
- port: 443
- port: 8443
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ metadata:
spec:
ports:
- port: 443
targetPort: 8443
clusterIp: 10.0.0.1
2 changes: 1 addition & 1 deletion pkg/provider/kubernetes/ingress/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func loadService(client Client, namespace string, backend v1beta1.IngressBackend
}

protocol := "http"
if port == 443 || strings.HasPrefix(portName, "https") {
if portSpec.Port == 443 || strings.HasPrefix(portName, "https") {
protocol = "https"
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/kubernetes/ingress/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,10 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
PassHostHeader: true,
Servers: []dynamic.Server{
{
URL: "https://10.10.0.1:443",
URL: "https://10.10.0.1:8443",
},
{
URL: "https://10.21.0.1:443",
URL: "https://10.21.0.1:8443",
},
},
},
Expand Down

0 comments on commit 2895ad2

Please sign in to comment.