Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/contour: support ingress.kubernetes.io/force-ssl-redirect: true #149

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/contour/virtualhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ func (v *VirtualHostCache) recomputevhost(vhost string, ingresses []*v1beta1.Ing
}}
continue
}
if i.Annotations["ingress.kubernetes.io/force-ssl-redirect"] == "true" {
// set blanket 301 redirect
vv.RequireTls = v2.VirtualHost_ALL
vv.Routes = []*v2.Route{{
Match: prefixmatch("/"), // match all
Action: clusteraction("dummy"),
}}
continue
}
for _, rule := range i.Spec.Rules {
if rule.Host != "" && rule.Host != vhost {
continue
Expand Down
39 changes: 39 additions & 0 deletions internal/contour/virtualhost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,45 @@ func TestVirtualHostCacheRecomputevhost(t *testing.T) {
}},
}},
},
"tls, force https": {
vhost: "httpbin.org",
ingresses: []*v1beta1.Ingress{{
ObjectMeta: metav1.ObjectMeta{
Name: "httpbin",
Namespace: "default",
Annotations: map[string]string{
"ingress.kubernetes.io/force-ssl-redirect": "true",
},
},
Spec: v1beta1.IngressSpec{
TLS: []v1beta1.IngressTLS{{
Hosts: []string{"httpbin.org"},
SecretName: "secret",
}},
Rules: []v1beta1.IngressRule{{
Host: "httpbin.org",
IngressRuleValue: ingressrulevalue(backend("httpbin-org", intstr.FromInt(80))),
}},
},
}},
ingress_http: []*v2.VirtualHost{{
Name: "httpbin.org",
Domains: []string{"httpbin.org"},
Routes: []*v2.Route{{
Match: prefixmatch("/"), // match all
Action: clusteraction("dummy"),
}},
RequireTls: v2.VirtualHost_ALL,
}},
ingress_https: []*v2.VirtualHost{{
Name: "httpbin.org",
Domains: []string{"httpbin.org"},
Routes: []*v2.Route{{
Match: prefixmatch("/"), // match all
Action: clusteraction("default/httpbin-org/80"),
}},
}},
},
"regex vhost without match characters": {
vhost: "httpbin.org",
ingresses: []*v1beta1.Ingress{{
Expand Down