feat: Add ServersTransport annotation to k8s ingress provider
This commit is contained in:
parent
526f493e12
commit
456df0fc19
6 changed files with 24 additions and 5 deletions
|
@ -294,6 +294,14 @@ which in turn will create the resulting routers, services, handlers, etc.
|
||||||
traefik.ingress.kubernetes.io/service.serversscheme: h2c
|
traefik.ingress.kubernetes.io/service.serversscheme: h2c
|
||||||
```
|
```
|
||||||
|
|
||||||
|
??? info "`traefik.ingress.kubernetes.io/service.serverstransport`"
|
||||||
|
|
||||||
|
See [ServersTransport](../services/index.md#serverstransport) for more information.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
traefik.ingress.kubernetes.io/service.serversscheme: mtls@file
|
||||||
|
```
|
||||||
|
|
||||||
??? info "`traefik.ingress.kubernetes.io/service.passhostheader`"
|
??? info "`traefik.ingress.kubernetes.io/service.passhostheader`"
|
||||||
|
|
||||||
See [pass Host header](../services/index.md#pass-host-header) for more information.
|
See [pass Host header](../services/index.md#pass-host-header) for more information.
|
||||||
|
|
|
@ -42,6 +42,7 @@ type ServiceConfig struct {
|
||||||
// ServiceIng is the service's configuration from annotations.
|
// ServiceIng is the service's configuration from annotations.
|
||||||
type ServiceIng struct {
|
type ServiceIng struct {
|
||||||
ServersScheme string `json:"serversScheme,omitempty"`
|
ServersScheme string `json:"serversScheme,omitempty"`
|
||||||
|
ServersTransport string `json:"serversTransport,omitempty"`
|
||||||
PassHostHeader *bool `json:"passHostHeader"`
|
PassHostHeader *bool `json:"passHostHeader"`
|
||||||
Sticky *dynamic.Sticky `json:"sticky,omitempty" label:"allowEmpty"`
|
Sticky *dynamic.Sticky `json:"sticky,omitempty" label:"allowEmpty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ func Test_parseServiceConfig(t *testing.T) {
|
||||||
"ingress.kubernetes.io/foo": "bar",
|
"ingress.kubernetes.io/foo": "bar",
|
||||||
"traefik.ingress.kubernetes.io/foo": "bar",
|
"traefik.ingress.kubernetes.io/foo": "bar",
|
||||||
"traefik.ingress.kubernetes.io/service.serversscheme": "protocol",
|
"traefik.ingress.kubernetes.io/service.serversscheme": "protocol",
|
||||||
|
"traefik.ingress.kubernetes.io/service.serverstransport": "foobar@file",
|
||||||
"traefik.ingress.kubernetes.io/service.passhostheader": "true",
|
"traefik.ingress.kubernetes.io/service.passhostheader": "true",
|
||||||
"traefik.ingress.kubernetes.io/service.sticky.cookie": "true",
|
"traefik.ingress.kubernetes.io/service.sticky.cookie": "true",
|
||||||
"traefik.ingress.kubernetes.io/service.sticky.cookie.httponly": "true",
|
"traefik.ingress.kubernetes.io/service.sticky.cookie.httponly": "true",
|
||||||
|
@ -122,6 +123,7 @@ func Test_parseServiceConfig(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ServersScheme: "protocol",
|
ServersScheme: "protocol",
|
||||||
|
ServersTransport: "foobar@file",
|
||||||
PassHostHeader: Bool(true),
|
PassHostHeader: Bool(true),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -205,6 +207,7 @@ func Test_convertAnnotations(t *testing.T) {
|
||||||
desc: "service annotations",
|
desc: "service annotations",
|
||||||
annotations: map[string]string{
|
annotations: map[string]string{
|
||||||
"traefik.ingress.kubernetes.io/service.serversscheme": "protocol",
|
"traefik.ingress.kubernetes.io/service.serversscheme": "protocol",
|
||||||
|
"traefik.ingress.kubernetes.io/service.serverstransport": "foobar@file",
|
||||||
"traefik.ingress.kubernetes.io/service.passhostheader": "true",
|
"traefik.ingress.kubernetes.io/service.passhostheader": "true",
|
||||||
"traefik.ingress.kubernetes.io/service.sticky.cookie": "true",
|
"traefik.ingress.kubernetes.io/service.sticky.cookie": "true",
|
||||||
"traefik.ingress.kubernetes.io/service.sticky.cookie.httponly": "true",
|
"traefik.ingress.kubernetes.io/service.sticky.cookie.httponly": "true",
|
||||||
|
@ -214,6 +217,7 @@ func Test_convertAnnotations(t *testing.T) {
|
||||||
expected: map[string]string{
|
expected: map[string]string{
|
||||||
"traefik.service.passhostheader": "true",
|
"traefik.service.passhostheader": "true",
|
||||||
"traefik.service.serversscheme": "protocol",
|
"traefik.service.serversscheme": "protocol",
|
||||||
|
"traefik.service.serverstransport": "foobar@file",
|
||||||
"traefik.service.sticky.cookie": "true",
|
"traefik.service.sticky.cookie": "true",
|
||||||
"traefik.service.sticky.cookie.httponly": "true",
|
"traefik.service.sticky.cookie.httponly": "true",
|
||||||
"traefik.service.sticky.cookie.name": "foobar",
|
"traefik.service.sticky.cookie.name": "foobar",
|
||||||
|
|
|
@ -8,6 +8,7 @@ metadata:
|
||||||
ingress.kubernetes.io/foo: bar
|
ingress.kubernetes.io/foo: bar
|
||||||
traefik.ingress.kubernetes.io/foo: bar
|
traefik.ingress.kubernetes.io/foo: bar
|
||||||
traefik.ingress.kubernetes.io/service.serversscheme: protocol
|
traefik.ingress.kubernetes.io/service.serversscheme: protocol
|
||||||
|
traefik.ingress.kubernetes.io/service.serverstransport: foobar@file
|
||||||
traefik.ingress.kubernetes.io/service.passhostheader: "true"
|
traefik.ingress.kubernetes.io/service.passhostheader: "true"
|
||||||
traefik.ingress.kubernetes.io/service.sticky.cookie: "true"
|
traefik.ingress.kubernetes.io/service.sticky.cookie: "true"
|
||||||
traefik.ingress.kubernetes.io/service.sticky.cookie.httponly: "true"
|
traefik.ingress.kubernetes.io/service.sticky.cookie.httponly: "true"
|
||||||
|
|
|
@ -530,6 +530,10 @@ func loadService(client Client, namespace string, backend networkingv1.IngressBa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if svcConfig != nil && svcConfig.Service != nil && svcConfig.Service.ServersTransport != "" {
|
||||||
|
svc.LoadBalancer.ServersTransport = svcConfig.Service.ServersTransport
|
||||||
|
}
|
||||||
|
|
||||||
if service.Spec.Type == corev1.ServiceTypeExternalName {
|
if service.Spec.Type == corev1.ServiceTypeExternalName {
|
||||||
protocol := getProtocol(portSpec, portSpec.Name, svcConfig)
|
protocol := getProtocol(portSpec, portSpec.Name, svcConfig)
|
||||||
hostPort := net.JoinHostPort(service.Spec.ExternalName, strconv.Itoa(int(portSpec.Port)))
|
hostPort := net.JoinHostPort(service.Spec.ExternalName, strconv.Itoa(int(portSpec.Port)))
|
||||||
|
|
|
@ -130,6 +130,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
||||||
URL: "protocol://10.21.0.1:8080",
|
URL: "protocol://10.21.0.1:8080",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
ServersTransport: "foobar@file",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue