Skip to content

Commit 80b3557

Browse files
jbdoumenjoujuliens
authored andcommitted
Define TLS options on the Router configuration for Kubernetes
Co-authored-by: juliens <julien@containo.us>
1 parent 69cf05d commit 80b3557

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2374
-53
lines changed

docs/content/middlewares/overview.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,38 @@ labels:
7171
- "traefik.http.middlewares.foo-add-prefix.addprefix.prefix=/foo"
7272
```
7373
74+
```toml tab="File"
75+
[tlsOptions]
76+
[tlsOptions.default]
77+
minVersion = "VersionTLS12"
78+
```
79+
80+
```yaml tab="Kubernetes"
81+
apiVersion: apiextensions.k8s.io/v1beta1
82+
kind: CustomResourceDefinition
83+
metadata:
84+
name: tlsoptions.traefik.containo.us
85+
86+
spec:
87+
group: traefik.containo.us
88+
version: v1alpha1
89+
names:
90+
kind: TLSOption
91+
plural: tlsoptions
92+
singular: tlsoption
93+
scope: Namespaced
94+
95+
---
96+
apiVersion: traefik.containo.us/v1alpha1
97+
kind: TLSOption
98+
metadata:
99+
name: mytlsoption
100+
namespace: default
101+
102+
spec:
103+
minversion: VersionTLS12
104+
```
105+
74106
```toml tab="File"
75107
# As Toml Configuration File
76108
[providers]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: tlsoptions.traefik.containo.us
5+
6+
spec:
7+
group: traefik.containo.us
8+
version: v1alpha1
9+
names:
10+
kind: TLSOption
11+
plural: tlsoptions
12+
singular: tlsoption
13+
scope: Namespaced

docs/content/providers/kubernetes-crd.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,51 @@ spec:
230230
231231
More information about available middlewares in the dedicated [middlewares section](../middlewares/overview.md).
232232
233+
### Traefik TLS Option Definition
234+
235+
Additionally, to allow for the use of tls options in an IngressRoute, we defined the CRD below for the TLSOption kind.
236+
More information about TLS Options is available in the dedicated [TLS Configuration Options](../../https/tls/#tls-options).
237+
238+
```yaml
239+
--8<-- "content/providers/crd_tls_option.yml"
240+
```
241+
242+
Once the TLSOption kind has been registered with the Kubernetes cluster or defined in the File Provider, it can then be used in IngressRoute definitions, such as:
243+
244+
```yaml
245+
apiVersion: traefik.containo.us/v1alpha1
246+
kind: TLSOption
247+
metadata:
248+
name: mytlsoption
249+
namespace: default
250+
251+
spec:
252+
minversion: VersionTLS12
253+
254+
---
255+
apiVersion: traefik.containo.us/v1alpha1
256+
kind: IngressRoute
257+
metadata:
258+
name: ingressroutebar
259+
260+
spec:
261+
entryPoints:
262+
- web
263+
routes:
264+
- match: Host(`bar.com`) && PathPrefix(`/stripit`)
265+
kind: Rule
266+
services:
267+
- name: whoami
268+
port: 80
269+
tls:
270+
options:
271+
name: mytlsoption
272+
namespace: default
273+
```
274+
275+
!!! note "TLS Option reference and namespace"
276+
If the optional `namespace` attribute is not set, the configuration will be applied with the namespace of the IngressRoute.
277+
233278
### TLS
234279

235280
To allow for TLS, we made use of the `Secret` kind, as it was already defined, and it can be directly used in an `IngressRoute`:

docs/content/reference/dynamic-configuration/kubernetes-crd.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ spec:
2626
singular: middleware
2727
scope: Namespaced
2828

29+
---
30+
apiVersion: apiextensions.k8s.io/v1beta1
31+
kind: CustomResourceDefinition
32+
metadata:
33+
name: tlsoptions.traefik.containo.us
34+
35+
spec:
36+
group: traefik.containo.us
37+
version: v1alpha1
38+
names:
39+
kind: TLSOption
40+
plural: tlsoptions
41+
singular: tlsoption
42+
scope: Namespaced
43+
2944
---
3045
apiVersion: apiextensions.k8s.io/v1beta1
3146
kind: CustomResourceDefinition
@@ -85,6 +100,9 @@ spec:
85100
# use an empty tls object for TLS with Let's Encrypt
86101
tls:
87102
secretName: supersecret
103+
options:
104+
name: myTLSOption
105+
namespace: default
88106

89107
---
90108
apiVersion: traefik.containo.us/v1alpha1
@@ -104,3 +122,6 @@ spec:
104122
tls:
105123
secretName: foosecret
106124
passthrough: false
125+
options:
126+
name: myTLSOption
127+
namespace: default

integration/fixtures/https/https_tls_options.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ level = "DEBUG"
4444
[[http.services.service2.LoadBalancer.Servers]]
4545
URL = "http://127.0.0.1:9020"
4646

47-
4847
[[tls]]
4948
[tls.certificate]
5049
certFile = "fixtures/https/snitest.com.cert"

integration/fixtures/k8s/01-crd.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,18 @@ spec:
4141
plural: ingressroutetcps
4242
singular: ingressroutetcp
4343
scope: Namespaced
44+
45+
---
46+
apiVersion: apiextensions.k8s.io/v1beta1
47+
kind: CustomResourceDefinition
48+
metadata:
49+
name: tlsoptions.traefik.containo.us
50+
51+
spec:
52+
group: traefik.containo.us
53+
version: v1alpha1
54+
names:
55+
kind: TLSOption
56+
plural: tlsoptions
57+
singular: tlsoption
58+
scope: Namespaced

integration/fixtures/k8s/03-ingressroute.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ spec:
1515
services:
1616
- name: whoami
1717
port: 80
18+
19+
tls:
20+
options:
21+
name: mytlsoption
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: traefik.containo.us/v1alpha1
2+
kind: TLSOption
3+
metadata:
4+
name: mytlsoption
5+
namespace: default
6+
7+
spec:
8+
minversion: VersionTLS12
9+
snistrict: true
10+
ciphersuites:
11+
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
12+
- TLS_RSA_WITH_AES_256_GCM_SHA384

integration/fixtures/k8s/05-ingressroutetcp.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ spec:
1212
services:
1313
- name: whoamitcp
1414
port: 8080
15+
tls:
16+
options:
17+
name: mytlsoption

integration/https_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (s *HTTPSSuite) TestWithTLSOptions(c *check.C) {
191191
c.Assert(err.Error(), checker.Contains, "protocol version not supported")
192192

193193
// with unknown tls option
194-
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("unknown TLS options: unknown"))
194+
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("unknown TLS options: unknown@file"))
195195
c.Assert(err, checker.IsNil)
196196
}
197197

0 commit comments

Comments
 (0)