Add possibility to set a protocol

This commit is contained in:
Manuel Zapf 2018-07-31 17:12:03 +02:00 committed by Traefiker Bot
parent 402f7011d4
commit 09b489a614
4 changed files with 110 additions and 1 deletions

View file

@ -43,6 +43,8 @@ const (
traefikDefaultIngressClass = "traefik"
defaultBackendName = "global-default-backend"
defaultFrontendName = "global-default-frontend"
allowedProtocolHTTPS = "https"
allowedProtocolH2C = "h2c"
)
// IngressEndpoint holds the endpoint information for the Kubernetes provider
@ -312,6 +314,16 @@ func (p *Provider) loadIngresses(k8sClient Client) (*types.Configuration, error)
protocol = "https"
}
protocol = getStringValue(i.Annotations, annotationKubernetesProtocol, protocol)
switch protocol {
case allowedProtocolHTTPS:
case allowedProtocolH2C:
case label.DefaultProtocol:
default:
log.Errorf("Invalid protocol %s/%s specified for Ingress %s - skipping", annotationKubernetesProtocol, i.Namespace, i.Name)
continue
}
if service.Spec.Type == "ExternalName" {
url := protocol + "://" + service.Spec.ExternalName
if port.Port != 443 && port.Port != 80 {