Traefik & CRD & Let’s Encrypt

Traefik with an IngressRoute Custom Resource Definition for Kubernetes, and TLS Through Let’s Encrypt.

This document is intended to be a fully working example demonstrating how to set up Traefik in Kubernetes, with the dynamic configuration coming from the IngressRoute Custom Resource, and TLS setup with Let’s Encrypt. However, for the sake of simplicity, we’re using k3s docker image for the Kubernetes cluster setup.

Please note that for this setup, given that we’re going to use ACME’s TLS-ALPN-01 challenge, the host you’ll be running it on must be able to receive connections from the outside on port 443. And of course its internet facing IP address must match the domain name you intend to use.

In the following, the Kubernetes resources defined in YAML configuration files can be applied to the setup in two different ways:

  • the first, and usual way, is simply with the kubectl apply command.
  • the second, which can be used for this tutorial, is to directly place the files in the directory used by the k3s docker image for such inputs (/var/lib/rancher/k3s/server/manifests).

Kubectl Version

With the rancher/k3s version used in this guide (0.8.0), the kubectl version needs to be >= 1.11.

k3s Docker-compose Configuration

Our starting point is the docker-compose configuration file, to start the k3s cluster. You can start it with:

  1. docker-compose -f k3s.yml up
  1. server:
  2. image: rancher/k3s:v1.17.2-k3s1
  3. command: server --disable-agent --no-deploy traefik
  4. environment:
  5. - K3S_CLUSTER_SECRET=somethingtotallyrandom
  6. - K3S_KUBECONFIG_OUTPUT=/output/kubeconfig.yaml
  7. - K3S_KUBECONFIG_MODE=666
  8. volumes:
  9. # k3s will generate a kubeconfig.yaml in this directory. This volume is mounted
  10. # on your host, so you can then 'export KUBECONFIG=/somewhere/on/your/host/out/kubeconfig.yaml',
  11. # in order for your kubectl commands to work.
  12. - /somewhere/on/your/host/out:/output
  13. # This directory is where you put all the (yaml) configuration files of
  14. # the Kubernetes resources.
  15. - /somewhere/on/your/host/in:/var/lib/rancher/k3s/server/manifests
  16. ports:
  17. - 6443:6443
  18. node:
  19. image: rancher/k3s:v1.17.2-k3s1
  20. privileged: true
  21. links:
  22. - server
  23. environment:
  24. - K3S_URL=https://server:6443
  25. - K3S_CLUSTER_SECRET=somethingtotallyrandom
  26. volumes:
  27. # this is where you would place a alternative traefik image (saved as a .tar file with
  28. # 'docker save'), if you want to use it, instead of the traefik:v2.6 image.
  29. - /sowewhere/on/your/host/custom-image:/var/lib/rancher/k3s/agent/images

Cluster Resources

Let’s now have a look (in the order they should be applied, if using kubectl apply) at all the required resources for the full setup.

IngressRoute Definition

First, the definition of the IngressRoute and the Middleware kinds. Also note the RBAC authorization resources; they’ll be referenced through the serviceAccountName of the deployment, later on.

  1. ---
  2. apiVersion: apiextensions.k8s.io/v1
  3. kind: CustomResourceDefinition
  4. metadata:
  5. annotations:
  6. controller-gen.kubebuilder.io/version: v0.6.2
  7. creationTimestamp: null
  8. name: ingressroutes.traefik.containo.us
  9. spec:
  10. group: traefik.containo.us
  11. names:
  12. kind: IngressRoute
  13. listKind: IngressRouteList
  14. plural: ingressroutes
  15. singular: ingressroute
  16. scope: Namespaced
  17. versions:
  18. - name: v1alpha1
  19. schema:
  20. openAPIV3Schema:
  21. description: IngressRoute is an Ingress CRD specification.
  22. properties:
  23. apiVersion:
  24. description: 'APIVersion defines the versioned schema of this representation
  25. of an object. Servers should convert recognized schemas to the latest
  26. internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
  27. type: string
  28. kind:
  29. description: 'Kind is a string value representing the REST resource this
  30. object represents. Servers may infer this from the endpoint the client
  31. submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
  32. type: string
  33. metadata:
  34. type: object
  35. spec:
  36. description: IngressRouteSpec is a specification for a IngressRouteSpec
  37. resource.
  38. properties:
  39. entryPoints:
  40. items:
  41. type: string
  42. type: array
  43. routes:
  44. items:
  45. description: Route contains the set of routes.
  46. properties:
  47. kind:
  48. enum:
  49. - Rule
  50. type: string
  51. match:
  52. type: string
  53. middlewares:
  54. items:
  55. description: MiddlewareRef is a ref to the Middleware resources.
  56. properties:
  57. name:
  58. type: string
  59. namespace:
  60. type: string
  61. required:
  62. - name
  63. type: object
  64. type: array
  65. priority:
  66. type: integer
  67. services:
  68. items:
  69. description: Service defines an upstream to proxy traffic.
  70. properties:
  71. kind:
  72. enum:
  73. - Service
  74. - TraefikService
  75. type: string
  76. name:
  77. description: Name is a reference to a Kubernetes Service
  78. object (for a load-balancer of servers), or to a TraefikService
  79. object (service load-balancer, mirroring, etc). The
  80. differentiation between the two is specified in the
  81. Kind field.
  82. type: string
  83. namespace:
  84. type: string
  85. passHostHeader:
  86. type: boolean
  87. port:
  88. anyOf:
  89. - type: integer
  90. - type: string
  91. x-kubernetes-int-or-string: true
  92. responseForwarding:
  93. description: ResponseForwarding holds configuration for
  94. the forward of the response.
  95. properties:
  96. flushInterval:
  97. type: string
  98. type: object
  99. scheme:
  100. type: string
  101. serversTransport:
  102. type: string
  103. sticky:
  104. description: Sticky holds the sticky configuration.
  105. properties:
  106. cookie:
  107. description: Cookie holds the sticky configuration
  108. based on cookie.
  109. properties:
  110. httpOnly:
  111. type: boolean
  112. name:
  113. type: string
  114. sameSite:
  115. type: string
  116. secure:
  117. type: boolean
  118. type: object
  119. type: object
  120. strategy:
  121. type: string
  122. weight:
  123. description: Weight should only be specified when Name
  124. references a TraefikService object (and to be precise,
  125. one that embeds a Weighted Round Robin).
  126. type: integer
  127. required:
  128. - name
  129. type: object
  130. type: array
  131. required:
  132. - kind
  133. - match
  134. type: object
  135. type: array
  136. tls:
  137. description: "TLS contains the TLS certificates configuration of the
  138. routes. To enable Let's Encrypt, use an empty TLS struct, e.g. in
  139. YAML: \n \t tls: {} # inline format \n \t tls: \t secretName:
  140. # block format"
  141. properties:
  142. certResolver:
  143. type: string
  144. domains:
  145. items:
  146. description: Domain holds a domain name with SANs.
  147. properties:
  148. main:
  149. type: string
  150. sans:
  151. items:
  152. type: string
  153. type: array
  154. type: object
  155. type: array
  156. options:
  157. description: Options is a reference to a TLSOption, that specifies
  158. the parameters of the TLS connection.
  159. properties:
  160. name:
  161. type: string
  162. namespace:
  163. type: string
  164. required:
  165. - name
  166. type: object
  167. secretName:
  168. description: SecretName is the name of the referenced Kubernetes
  169. Secret to specify the certificate details.
  170. type: string
  171. store:
  172. description: Store is a reference to a TLSStore, that specifies
  173. the parameters of the TLS store.
  174. properties:
  175. name:
  176. type: string
  177. namespace:
  178. type: string
  179. required:
  180. - name
  181. type: object
  182. type: object
  183. required:
  184. - routes
  185. type: object
  186. required:
  187. - metadata
  188. - spec
  189. type: object
  190. served: true
  191. storage: true
  192. status:
  193. acceptedNames:
  194. kind: ""
  195. plural: ""
  196. conditions: []
  197. storedVersions: []
  198. ---
  199. apiVersion: apiextensions.k8s.io/v1
  200. kind: CustomResourceDefinition
  201. metadata:
  202. annotations:
  203. controller-gen.kubebuilder.io/version: v0.6.2
  204. creationTimestamp: null
  205. name: ingressroutetcps.traefik.containo.us
  206. spec:
  207. group: traefik.containo.us
  208. names:
  209. kind: IngressRouteTCP
  210. listKind: IngressRouteTCPList
  211. plural: ingressroutetcps
  212. singular: ingressroutetcp
  213. scope: Namespaced
  214. versions:
  215. - name: v1alpha1
  216. schema:
  217. openAPIV3Schema:
  218. description: IngressRouteTCP is an Ingress CRD specification.
  219. properties:
  220. apiVersion:
  221. description: 'APIVersion defines the versioned schema of this representation
  222. of an object. Servers should convert recognized schemas to the latest
  223. internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
  224. type: string
  225. kind:
  226. description: 'Kind is a string value representing the REST resource this
  227. object represents. Servers may infer this from the endpoint the client
  228. submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
  229. type: string
  230. metadata:
  231. type: object
  232. spec:
  233. description: IngressRouteTCPSpec is a specification for a IngressRouteTCPSpec
  234. resource.
  235. properties:
  236. entryPoints:
  237. items:
  238. type: string
  239. type: array
  240. routes:
  241. items:
  242. description: RouteTCP contains the set of routes.
  243. properties:
  244. match:
  245. type: string
  246. middlewares:
  247. description: Middlewares contains references to MiddlewareTCP
  248. resources.
  249. items:
  250. description: ObjectReference is a generic reference to a Traefik
  251. resource.
  252. properties:
  253. name:
  254. type: string
  255. namespace:
  256. type: string
  257. required:
  258. - name
  259. type: object
  260. type: array
  261. services:
  262. items:
  263. description: ServiceTCP defines an upstream to proxy traffic.
  264. properties:
  265. name:
  266. type: string
  267. namespace:
  268. type: string
  269. port:
  270. anyOf:
  271. - type: integer
  272. - type: string
  273. x-kubernetes-int-or-string: true
  274. proxyProtocol:
  275. description: ProxyProtocol holds the ProxyProtocol configuration.
  276. properties:
  277. version:
  278. type: integer
  279. type: object
  280. terminationDelay:
  281. type: integer
  282. weight:
  283. type: integer
  284. required:
  285. - name
  286. - port
  287. type: object
  288. type: array
  289. required:
  290. - match
  291. type: object
  292. type: array
  293. tls:
  294. description: "TLSTCP contains the TLS certificates configuration of
  295. the routes. To enable Let's Encrypt, use an empty TLS struct, e.g.
  296. in YAML: \n \t tls: {} # inline format \n \t tls: \t secretName:
  297. # block format"
  298. properties:
  299. certResolver:
  300. type: string
  301. domains:
  302. items:
  303. description: Domain holds a domain name with SANs.
  304. properties:
  305. main:
  306. type: string
  307. sans:
  308. items:
  309. type: string
  310. type: array
  311. type: object
  312. type: array
  313. options:
  314. description: Options is a reference to a TLSOption, that specifies
  315. the parameters of the TLS connection.
  316. properties:
  317. name:
  318. type: string
  319. namespace:
  320. type: string
  321. required:
  322. - name
  323. type: object
  324. passthrough:
  325. type: boolean
  326. secretName:
  327. description: SecretName is the name of the referenced Kubernetes
  328. Secret to specify the certificate details.
  329. type: string
  330. store:
  331. description: Store is a reference to a TLSStore, that specifies
  332. the parameters of the TLS store.
  333. properties:
  334. name:
  335. type: string
  336. namespace:
  337. type: string
  338. required:
  339. - name
  340. type: object
  341. type: object
  342. required:
  343. - routes
  344. type: object
  345. required:
  346. - metadata
  347. - spec
  348. type: object
  349. served: true
  350. storage: true
  351. status:
  352. acceptedNames:
  353. kind: ""
  354. plural: ""
  355. conditions: []
  356. storedVersions: []
  357. ---
  358. apiVersion: apiextensions.k8s.io/v1
  359. kind: CustomResourceDefinition
  360. metadata:
  361. annotations:
  362. controller-gen.kubebuilder.io/version: v0.6.2
  363. creationTimestamp: null
  364. name: ingressrouteudps.traefik.containo.us
  365. spec:
  366. group: traefik.containo.us
  367. names:
  368. kind: IngressRouteUDP
  369. listKind: IngressRouteUDPList
  370. plural: ingressrouteudps
  371. singular: ingressrouteudp
  372. scope: Namespaced
  373. versions:
  374. - name: v1alpha1
  375. schema:
  376. openAPIV3Schema:
  377. description: IngressRouteUDP is an Ingress CRD specification.
  378. properties:
  379. apiVersion:
  380. description: 'APIVersion defines the versioned schema of this representation
  381. of an object. Servers should convert recognized schemas to the latest
  382. internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
  383. type: string
  384. kind:
  385. description: 'Kind is a string value representing the REST resource this
  386. object represents. Servers may infer this from the endpoint the client
  387. submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
  388. type: string
  389. metadata:
  390. type: object
  391. spec:
  392. description: IngressRouteUDPSpec is a specification for a IngressRouteUDPSpec
  393. resource.
  394. properties:
  395. entryPoints:
  396. items:
  397. type: string
  398. type: array
  399. routes:
  400. items:
  401. description: RouteUDP contains the set of routes.
  402. properties:
  403. services:
  404. items:
  405. description: ServiceUDP defines an upstream to proxy traffic.
  406. properties:
  407. name:
  408. type: string
  409. namespace:
  410. type: string
  411. port:
  412. anyOf:
  413. - type: integer
  414. - type: string
  415. x-kubernetes-int-or-string: true
  416. weight:
  417. type: integer
  418. required:
  419. - name
  420. - port
  421. type: object
  422. type: array
  423. type: object
  424. type: array
  425. required:
  426. - routes
  427. type: object
  428. required:
  429. - metadata
  430. - spec
  431. type: object
  432. served: true
  433. storage: true
  434. status:
  435. acceptedNames:
  436. kind: ""
  437. plural: ""
  438. conditions: []
  439. storedVersions: []
  440. ---
  441. apiVersion: apiextensions.k8s.io/v1
  442. kind: CustomResourceDefinition
  443. metadata:
  444. annotations:
  445. controller-gen.kubebuilder.io/version: v0.6.2
  446. creationTimestamp: null
  447. name: middlewares.traefik.containo.us
  448. spec:
  449. group: traefik.containo.us
  450. names:
  451. kind: Middleware
  452. listKind: MiddlewareList
  453. plural: middlewares
  454. singular: middleware
  455. scope: Namespaced
  456. versions:
  457. - name: v1alpha1
  458. schema:
  459. openAPIV3Schema:
  460. description: Middleware is a specification for a Middleware resource.
  461. properties:
  462. apiVersion:
  463. description: 'APIVersion defines the versioned schema of this representation
  464. of an object. Servers should convert recognized schemas to the latest
  465. internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
  466. type: string
  467. kind:
  468. description: 'Kind is a string value representing the REST resource this
  469. object represents. Servers may infer this from the endpoint the client
  470. submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
  471. type: string
  472. metadata:
  473. type: object
  474. spec:
  475. description: MiddlewareSpec holds the Middleware configuration.
  476. properties:
  477. addPrefix:
  478. description: AddPrefix holds the AddPrefix configuration.
  479. properties:
  480. prefix:
  481. type: string
  482. type: object
  483. basicAuth:
  484. description: BasicAuth holds the HTTP basic authentication configuration.
  485. properties:
  486. headerField:
  487. type: string
  488. realm:
  489. type: string
  490. removeHeader:
  491. type: boolean
  492. secret:
  493. type: string
  494. type: object
  495. buffering:
  496. description: Buffering holds the request/response buffering configuration.
  497. properties:
  498. maxRequestBodyBytes:
  499. format: int64
  500. type: integer
  501. maxResponseBodyBytes:
  502. format: int64
  503. type: integer
  504. memRequestBodyBytes:
  505. format: int64
  506. type: integer
  507. memResponseBodyBytes:
  508. format: int64
  509. type: integer
  510. retryExpression:
  511. type: string
  512. type: object
  513. chain:
  514. description: Chain holds a chain of middlewares.
  515. properties:
  516. middlewares:
  517. items:
  518. description: MiddlewareRef is a ref to the Middleware resources.
  519. properties:
  520. name:
  521. type: string
  522. namespace:
  523. type: string
  524. required:
  525. - name
  526. type: object
  527. type: array
  528. type: object
  529. circuitBreaker:
  530. description: CircuitBreaker holds the circuit breaker configuration.
  531. properties:
  532. expression:
  533. type: string
  534. type: object
  535. compress:
  536. description: Compress holds the compress configuration.
  537. properties:
  538. excludedContentTypes:
  539. items:
  540. type: string
  541. type: array
  542. minResponseBodyBytes:
  543. type: integer
  544. type: object
  545. contentType:
  546. description: ContentType middleware - or rather its unique `autoDetect`
  547. option - specifies whether to let the `Content-Type` header, if
  548. it has not been set by the backend, be automatically set to a value
  549. derived from the contents of the response. As a proxy, the default
  550. behavior should be to leave the header alone, regardless of what
  551. the backend did with it. However, the historic default was to always
  552. auto-detect and set the header if it was nil, and it is going to
  553. be kept that way in order to support users currently relying on
  554. it. This middleware exists to enable the correct behavior until
  555. at least the default one can be changed in a future version.
  556. properties:
  557. autoDetect:
  558. type: boolean
  559. type: object
  560. digestAuth:
  561. description: DigestAuth holds the Digest HTTP authentication configuration.
  562. properties:
  563. headerField:
  564. type: string
  565. realm:
  566. type: string
  567. removeHeader:
  568. type: boolean
  569. secret:
  570. type: string
  571. type: object
  572. errors:
  573. description: ErrorPage holds the custom error page configuration.
  574. properties:
  575. query:
  576. type: string
  577. service:
  578. description: Service defines an upstream to proxy traffic.
  579. properties:
  580. kind:
  581. enum:
  582. - Service
  583. - TraefikService
  584. type: string
  585. name:
  586. description: Name is a reference to a Kubernetes Service object
  587. (for a load-balancer of servers), or to a TraefikService
  588. object (service load-balancer, mirroring, etc). The differentiation
  589. between the two is specified in the Kind field.
  590. type: string
  591. namespace:
  592. type: string
  593. passHostHeader:
  594. type: boolean
  595. port:
  596. anyOf:
  597. - type: integer
  598. - type: string
  599. x-kubernetes-int-or-string: true
  600. responseForwarding:
  601. description: ResponseForwarding holds configuration for the
  602. forward of the response.
  603. properties:
  604. flushInterval:
  605. type: string
  606. type: object
  607. scheme:
  608. type: string
  609. serversTransport:
  610. type: string
  611. sticky:
  612. description: Sticky holds the sticky configuration.
  613. properties:
  614. cookie:
  615. description: Cookie holds the sticky configuration based
  616. on cookie.
  617. properties:
  618. httpOnly:
  619. type: boolean
  620. name:
  621. type: string
  622. sameSite:
  623. type: string
  624. secure:
  625. type: boolean
  626. type: object
  627. type: object
  628. strategy:
  629. type: string
  630. weight:
  631. description: Weight should only be specified when Name references
  632. a TraefikService object (and to be precise, one that embeds
  633. a Weighted Round Robin).
  634. type: integer
  635. required:
  636. - name
  637. type: object
  638. status:
  639. items:
  640. type: string
  641. type: array
  642. type: object
  643. forwardAuth:
  644. description: ForwardAuth holds the http forward authentication configuration.
  645. properties:
  646. address:
  647. type: string
  648. authRequestHeaders:
  649. items:
  650. type: string
  651. type: array
  652. authResponseHeaders:
  653. items:
  654. type: string
  655. type: array
  656. authResponseHeadersRegex:
  657. type: string
  658. tls:
  659. description: ClientTLS holds TLS specific configurations as client.
  660. properties:
  661. caOptional:
  662. type: boolean
  663. caSecret:
  664. type: string
  665. certSecret:
  666. type: string
  667. insecureSkipVerify:
  668. type: boolean
  669. type: object
  670. trustForwardHeader:
  671. type: boolean
  672. type: object
  673. headers:
  674. description: Headers holds the custom header configuration.
  675. properties:
  676. accessControlAllowCredentials:
  677. description: AccessControlAllowCredentials is only valid if true.
  678. false is ignored.
  679. type: boolean
  680. accessControlAllowHeaders:
  681. description: AccessControlAllowHeaders must be used in response
  682. to a preflight request with Access-Control-Request-Headers set.
  683. items:
  684. type: string
  685. type: array
  686. accessControlAllowMethods:
  687. description: AccessControlAllowMethods must be used in response
  688. to a preflight request with Access-Control-Request-Method set.
  689. items:
  690. type: string
  691. type: array
  692. accessControlAllowOriginList:
  693. description: AccessControlAllowOriginList is a list of allowable
  694. origins. Can also be a wildcard origin "*".
  695. items:
  696. type: string
  697. type: array
  698. accessControlAllowOriginListRegex:
  699. description: AccessControlAllowOriginListRegex is a list of allowable
  700. origins written following the Regular Expression syntax (https://golang.org/pkg/regexp/).
  701. items:
  702. type: string
  703. type: array
  704. accessControlExposeHeaders:
  705. description: AccessControlExposeHeaders sets valid headers for
  706. the response.
  707. items:
  708. type: string
  709. type: array
  710. accessControlMaxAge:
  711. description: AccessControlMaxAge sets the time that a preflight
  712. request may be cached.
  713. format: int64
  714. type: integer
  715. addVaryHeader:
  716. description: AddVaryHeader controls if the Vary header is automatically
  717. added/updated when the AccessControlAllowOriginList is set.
  718. type: boolean
  719. allowedHosts:
  720. items:
  721. type: string
  722. type: array
  723. browserXssFilter:
  724. type: boolean
  725. contentSecurityPolicy:
  726. type: string
  727. contentTypeNosniff:
  728. type: boolean
  729. customBrowserXSSValue:
  730. type: string
  731. customFrameOptionsValue:
  732. type: string
  733. customRequestHeaders:
  734. additionalProperties:
  735. type: string
  736. type: object
  737. customResponseHeaders:
  738. additionalProperties:
  739. type: string
  740. type: object
  741. featurePolicy:
  742. description: 'Deprecated: use PermissionsPolicy instead.'
  743. type: string
  744. forceSTSHeader:
  745. type: boolean
  746. frameDeny:
  747. type: boolean
  748. hostsProxyHeaders:
  749. items:
  750. type: string
  751. type: array
  752. isDevelopment:
  753. type: boolean
  754. permissionsPolicy:
  755. type: string
  756. publicKey:
  757. type: string
  758. referrerPolicy:
  759. type: string
  760. sslForceHost:
  761. description: 'Deprecated: use RedirectRegex instead.'
  762. type: boolean
  763. sslHost:
  764. description: 'Deprecated: use RedirectRegex instead.'
  765. type: string
  766. sslProxyHeaders:
  767. additionalProperties:
  768. type: string
  769. type: object
  770. sslRedirect:
  771. description: 'Deprecated: use EntryPoint redirection or RedirectScheme
  772. instead.'
  773. type: boolean
  774. sslTemporaryRedirect:
  775. description: 'Deprecated: use EntryPoint redirection or RedirectScheme
  776. instead.'
  777. type: boolean
  778. stsIncludeSubdomains:
  779. type: boolean
  780. stsPreload:
  781. type: boolean
  782. stsSeconds:
  783. format: int64
  784. type: integer
  785. type: object
  786. inFlightReq:
  787. description: InFlightReq limits the number of requests being processed
  788. and served concurrently.
  789. properties:
  790. amount:
  791. format: int64
  792. type: integer
  793. sourceCriterion:
  794. description: SourceCriterion defines what criterion is used to
  795. group requests as originating from a common source. If none
  796. are set, the default is to use the request's remote address
  797. field. All fields are mutually exclusive.
  798. properties:
  799. ipStrategy:
  800. description: IPStrategy holds the ip strategy configuration.
  801. properties:
  802. depth:
  803. type: integer
  804. excludedIPs:
  805. items:
  806. type: string
  807. type: array
  808. type: object
  809. requestHeaderName:
  810. type: string
  811. requestHost:
  812. type: boolean
  813. type: object
  814. type: object
  815. ipWhiteList:
  816. description: IPWhiteList holds the ip white list configuration.
  817. properties:
  818. ipStrategy:
  819. description: IPStrategy holds the ip strategy configuration.
  820. properties:
  821. depth:
  822. type: integer
  823. excludedIPs:
  824. items:
  825. type: string
  826. type: array
  827. type: object
  828. sourceRange:
  829. items:
  830. type: string
  831. type: array
  832. type: object
  833. passTLSClientCert:
  834. description: PassTLSClientCert holds the TLS client cert headers configuration.
  835. properties:
  836. info:
  837. description: TLSClientCertificateInfo holds the client TLS certificate
  838. info configuration.
  839. properties:
  840. issuer:
  841. description: TLSClientCertificateIssuerDNInfo holds the client
  842. TLS certificate distinguished name info configuration. cf
  843. https://tools.ietf.org/html/rfc3739
  844. properties:
  845. commonName:
  846. type: boolean
  847. country:
  848. type: boolean
  849. domainComponent:
  850. type: boolean
  851. locality:
  852. type: boolean
  853. organization:
  854. type: boolean
  855. province:
  856. type: boolean
  857. serialNumber:
  858. type: boolean
  859. type: object
  860. notAfter:
  861. type: boolean
  862. notBefore:
  863. type: boolean
  864. sans:
  865. type: boolean
  866. serialNumber:
  867. type: boolean
  868. subject:
  869. description: TLSClientCertificateSubjectDNInfo holds the client
  870. TLS certificate distinguished name info configuration. cf
  871. https://tools.ietf.org/html/rfc3739
  872. properties:
  873. commonName:
  874. type: boolean
  875. country:
  876. type: boolean
  877. domainComponent:
  878. type: boolean
  879. locality:
  880. type: boolean
  881. organization:
  882. type: boolean
  883. organizationalUnit:
  884. type: boolean
  885. province:
  886. type: boolean
  887. serialNumber:
  888. type: boolean
  889. type: object
  890. type: object
  891. pem:
  892. type: boolean
  893. type: object
  894. plugin:
  895. additionalProperties:
  896. x-kubernetes-preserve-unknown-fields: true
  897. type: object
  898. rateLimit:
  899. description: RateLimit holds the rate limiting configuration for a
  900. given router.
  901. properties:
  902. average:
  903. format: int64
  904. type: integer
  905. burst:
  906. format: int64
  907. type: integer
  908. period:
  909. anyOf:
  910. - type: integer
  911. - type: string
  912. x-kubernetes-int-or-string: true
  913. sourceCriterion:
  914. description: SourceCriterion defines what criterion is used to
  915. group requests as originating from a common source. If none
  916. are set, the default is to use the request's remote address
  917. field. All fields are mutually exclusive.
  918. properties:
  919. ipStrategy:
  920. description: IPStrategy holds the ip strategy configuration.
  921. properties:
  922. depth:
  923. type: integer
  924. excludedIPs:
  925. items:
  926. type: string
  927. type: array
  928. type: object
  929. requestHeaderName:
  930. type: string
  931. requestHost:
  932. type: boolean
  933. type: object
  934. type: object
  935. redirectRegex:
  936. description: RedirectRegex holds the redirection configuration.
  937. properties:
  938. permanent:
  939. type: boolean
  940. regex:
  941. type: string
  942. replacement:
  943. type: string
  944. type: object
  945. redirectScheme:
  946. description: RedirectScheme holds the scheme redirection configuration.
  947. properties:
  948. permanent:
  949. type: boolean
  950. port:
  951. type: string
  952. scheme:
  953. type: string
  954. type: object
  955. replacePath:
  956. description: ReplacePath holds the ReplacePath configuration.
  957. properties:
  958. path:
  959. type: string
  960. type: object
  961. replacePathRegex:
  962. description: ReplacePathRegex holds the ReplacePathRegex configuration.
  963. properties:
  964. regex:
  965. type: string
  966. replacement:
  967. type: string
  968. type: object
  969. retry:
  970. description: Retry holds the retry configuration.
  971. properties:
  972. attempts:
  973. type: integer
  974. initialInterval:
  975. anyOf:
  976. - type: integer
  977. - type: string
  978. x-kubernetes-int-or-string: true
  979. type: object
  980. stripPrefix:
  981. description: StripPrefix holds the StripPrefix configuration.
  982. properties:
  983. forceSlash:
  984. type: boolean
  985. prefixes:
  986. items:
  987. type: string
  988. type: array
  989. type: object
  990. stripPrefixRegex:
  991. description: StripPrefixRegex holds the StripPrefixRegex configuration.
  992. properties:
  993. regex:
  994. items:
  995. type: string
  996. type: array
  997. type: object
  998. type: object
  999. required:
  1000. - metadata
  1001. - spec
  1002. type: object
  1003. served: true
  1004. storage: true
  1005. status:
  1006. acceptedNames:
  1007. kind: ""
  1008. plural: ""
  1009. conditions: []
  1010. storedVersions: []
  1011. ---
  1012. apiVersion: apiextensions.k8s.io/v1
  1013. kind: CustomResourceDefinition
  1014. metadata:
  1015. annotations:
  1016. controller-gen.kubebuilder.io/version: v0.6.2
  1017. creationTimestamp: null
  1018. name: middlewaretcps.traefik.containo.us
  1019. spec:
  1020. group: traefik.containo.us
  1021. names:
  1022. kind: MiddlewareTCP
  1023. listKind: MiddlewareTCPList
  1024. plural: middlewaretcps
  1025. singular: middlewaretcp
  1026. scope: Namespaced
  1027. versions:
  1028. - name: v1alpha1
  1029. schema:
  1030. openAPIV3Schema:
  1031. description: MiddlewareTCP is a specification for a MiddlewareTCP resource.
  1032. properties:
  1033. apiVersion:
  1034. description: 'APIVersion defines the versioned schema of this representation
  1035. of an object. Servers should convert recognized schemas to the latest
  1036. internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
  1037. type: string
  1038. kind:
  1039. description: 'Kind is a string value representing the REST resource this
  1040. object represents. Servers may infer this from the endpoint the client
  1041. submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
  1042. type: string
  1043. metadata:
  1044. type: object
  1045. spec:
  1046. description: MiddlewareTCPSpec holds the MiddlewareTCP configuration.
  1047. properties:
  1048. inFlightConn:
  1049. description: TCPInFlightConn holds the TCP in flight connection configuration.
  1050. properties:
  1051. amount:
  1052. format: int64
  1053. type: integer
  1054. type: object
  1055. ipWhiteList:
  1056. description: TCPIPWhiteList holds the TCP ip white list configuration.
  1057. properties:
  1058. sourceRange:
  1059. items:
  1060. type: string
  1061. type: array
  1062. type: object
  1063. type: object
  1064. required:
  1065. - metadata
  1066. - spec
  1067. type: object
  1068. served: true
  1069. storage: true
  1070. status:
  1071. acceptedNames:
  1072. kind: ""
  1073. plural: ""
  1074. conditions: []
  1075. storedVersions: []
  1076. ---
  1077. apiVersion: apiextensions.k8s.io/v1
  1078. kind: CustomResourceDefinition
  1079. metadata:
  1080. annotations:
  1081. controller-gen.kubebuilder.io/version: v0.6.2
  1082. creationTimestamp: null
  1083. name: serverstransports.traefik.containo.us
  1084. spec:
  1085. group: traefik.containo.us
  1086. names:
  1087. kind: ServersTransport
  1088. listKind: ServersTransportList
  1089. plural: serverstransports
  1090. singular: serverstransport
  1091. scope: Namespaced
  1092. versions:
  1093. - name: v1alpha1
  1094. schema:
  1095. openAPIV3Schema:
  1096. description: ServersTransport is a specification for a ServersTransport resource.
  1097. properties:
  1098. apiVersion:
  1099. description: 'APIVersion defines the versioned schema of this representation
  1100. of an object. Servers should convert recognized schemas to the latest
  1101. internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
  1102. type: string
  1103. kind:
  1104. description: 'Kind is a string value representing the REST resource this
  1105. object represents. Servers may infer this from the endpoint the client
  1106. submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
  1107. type: string
  1108. metadata:
  1109. type: object
  1110. spec:
  1111. description: ServersTransportSpec options to configure communication between
  1112. Traefik and the servers.
  1113. properties:
  1114. certificatesSecrets:
  1115. description: Certificates for mTLS.
  1116. items:
  1117. type: string
  1118. type: array
  1119. disableHTTP2:
  1120. description: Disable HTTP/2 for connections with backend servers.
  1121. type: boolean
  1122. forwardingTimeouts:
  1123. description: Timeouts for requests forwarded to the backend servers.
  1124. properties:
  1125. dialTimeout:
  1126. anyOf:
  1127. - type: integer
  1128. - type: string
  1129. description: DialTimeout is the amount of time to wait until a
  1130. connection to a backend server can be established. If zero,
  1131. no timeout exists.
  1132. x-kubernetes-int-or-string: true
  1133. idleConnTimeout:
  1134. anyOf:
  1135. - type: integer
  1136. - type: string
  1137. description: IdleConnTimeout is the maximum period for which an
  1138. idle HTTP keep-alive connection will remain open before closing
  1139. itself.
  1140. x-kubernetes-int-or-string: true
  1141. pingTimeout:
  1142. anyOf:
  1143. - type: integer
  1144. - type: string
  1145. description: PingTimeout is the timeout after which the HTTP/2
  1146. connection will be closed if a response to ping is not received.
  1147. x-kubernetes-int-or-string: true
  1148. readIdleTimeout:
  1149. anyOf:
  1150. - type: integer
  1151. - type: string
  1152. description: ReadIdleTimeout is the timeout after which a health
  1153. check using ping frame will be carried out if no frame is received
  1154. on the HTTP/2 connection. If zero, no health check is performed.
  1155. x-kubernetes-int-or-string: true
  1156. responseHeaderTimeout:
  1157. anyOf:
  1158. - type: integer
  1159. - type: string
  1160. description: ResponseHeaderTimeout is the amount of time to wait
  1161. for a server's response headers after fully writing the request
  1162. (including its body, if any). If zero, no timeout exists.
  1163. x-kubernetes-int-or-string: true
  1164. type: object
  1165. insecureSkipVerify:
  1166. description: Disable SSL certificate verification.
  1167. type: boolean
  1168. maxIdleConnsPerHost:
  1169. description: If non-zero, controls the maximum idle (keep-alive) to
  1170. keep per-host. If zero, DefaultMaxIdleConnsPerHost is used.
  1171. type: integer
  1172. peerCertURI:
  1173. description: URI used to match against SAN URI during the peer certificate
  1174. verification.
  1175. type: string
  1176. rootCAsSecrets:
  1177. description: Add cert file for self-signed certificate.
  1178. items:
  1179. type: string
  1180. type: array
  1181. serverName:
  1182. description: ServerName used to contact the server.
  1183. type: string
  1184. type: object
  1185. required:
  1186. - metadata
  1187. - spec
  1188. type: object
  1189. served: true
  1190. storage: true
  1191. status:
  1192. acceptedNames:
  1193. kind: ""
  1194. plural: ""
  1195. conditions: []
  1196. storedVersions: []
  1197. ---
  1198. apiVersion: apiextensions.k8s.io/v1
  1199. kind: CustomResourceDefinition
  1200. metadata:
  1201. annotations:
  1202. controller-gen.kubebuilder.io/version: v0.6.2
  1203. creationTimestamp: null
  1204. name: tlsoptions.traefik.containo.us
  1205. spec:
  1206. group: traefik.containo.us
  1207. names:
  1208. kind: TLSOption
  1209. listKind: TLSOptionList
  1210. plural: tlsoptions
  1211. singular: tlsoption
  1212. scope: Namespaced
  1213. versions:
  1214. - name: v1alpha1
  1215. schema:
  1216. openAPIV3Schema:
  1217. description: TLSOption is a specification for a TLSOption resource.
  1218. properties:
  1219. apiVersion:
  1220. description: 'APIVersion defines the versioned schema of this representation
  1221. of an object. Servers should convert recognized schemas to the latest
  1222. internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
  1223. type: string
  1224. kind:
  1225. description: 'Kind is a string value representing the REST resource this
  1226. object represents. Servers may infer this from the endpoint the client
  1227. submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
  1228. type: string
  1229. metadata:
  1230. type: object
  1231. spec:
  1232. description: TLSOptionSpec configures TLS for an entry point.
  1233. properties:
  1234. alpnProtocols:
  1235. items:
  1236. type: string
  1237. type: array
  1238. cipherSuites:
  1239. items:
  1240. type: string
  1241. type: array
  1242. clientAuth:
  1243. description: ClientAuth defines the parameters of the client authentication
  1244. part of the TLS connection, if any.
  1245. properties:
  1246. clientAuthType:
  1247. description: ClientAuthType defines the client authentication
  1248. type to apply.
  1249. enum:
  1250. - NoClientCert
  1251. - RequestClientCert
  1252. - RequireAnyClientCert
  1253. - VerifyClientCertIfGiven
  1254. - RequireAndVerifyClientCert
  1255. type: string
  1256. secretNames:
  1257. description: SecretName is the name of the referenced Kubernetes
  1258. Secret to specify the certificate details.
  1259. items:
  1260. type: string
  1261. type: array
  1262. type: object
  1263. curvePreferences:
  1264. items:
  1265. type: string
  1266. type: array
  1267. maxVersion:
  1268. type: string
  1269. minVersion:
  1270. type: string
  1271. preferServerCipherSuites:
  1272. type: boolean
  1273. sniStrict:
  1274. type: boolean
  1275. type: object
  1276. required:
  1277. - metadata
  1278. - spec
  1279. type: object
  1280. served: true
  1281. storage: true
  1282. status:
  1283. acceptedNames:
  1284. kind: ""
  1285. plural: ""
  1286. conditions: []
  1287. storedVersions: []
  1288. ---
  1289. apiVersion: apiextensions.k8s.io/v1
  1290. kind: CustomResourceDefinition
  1291. metadata:
  1292. annotations:
  1293. controller-gen.kubebuilder.io/version: v0.6.2
  1294. creationTimestamp: null
  1295. name: tlsstores.traefik.containo.us
  1296. spec:
  1297. group: traefik.containo.us
  1298. names:
  1299. kind: TLSStore
  1300. listKind: TLSStoreList
  1301. plural: tlsstores
  1302. singular: tlsstore
  1303. scope: Namespaced
  1304. versions:
  1305. - name: v1alpha1
  1306. schema:
  1307. openAPIV3Schema:
  1308. description: TLSStore is a specification for a TLSStore resource.
  1309. properties:
  1310. apiVersion:
  1311. description: 'APIVersion defines the versioned schema of this representation
  1312. of an object. Servers should convert recognized schemas to the latest
  1313. internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
  1314. type: string
  1315. kind:
  1316. description: 'Kind is a string value representing the REST resource this
  1317. object represents. Servers may infer this from the endpoint the client
  1318. submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
  1319. type: string
  1320. metadata:
  1321. type: object
  1322. spec:
  1323. description: TLSStoreSpec configures a TLSStore resource.
  1324. properties:
  1325. defaultCertificate:
  1326. description: DefaultCertificate holds a secret name for the TLSOption
  1327. resource.
  1328. properties:
  1329. secretName:
  1330. description: SecretName is the name of the referenced Kubernetes
  1331. Secret to specify the certificate details.
  1332. type: string
  1333. required:
  1334. - secretName
  1335. type: object
  1336. required:
  1337. - defaultCertificate
  1338. type: object
  1339. required:
  1340. - metadata
  1341. - spec
  1342. type: object
  1343. served: true
  1344. storage: true
  1345. status:
  1346. acceptedNames:
  1347. kind: ""
  1348. plural: ""
  1349. conditions: []
  1350. storedVersions: []
  1351. ---
  1352. apiVersion: apiextensions.k8s.io/v1
  1353. kind: CustomResourceDefinition
  1354. metadata:
  1355. annotations:
  1356. controller-gen.kubebuilder.io/version: v0.6.2
  1357. creationTimestamp: null
  1358. name: traefikservices.traefik.containo.us
  1359. spec:
  1360. group: traefik.containo.us
  1361. names:
  1362. kind: TraefikService
  1363. listKind: TraefikServiceList
  1364. plural: traefikservices
  1365. singular: traefikservice
  1366. scope: Namespaced
  1367. versions:
  1368. - name: v1alpha1
  1369. schema:
  1370. openAPIV3Schema:
  1371. description: TraefikService is the specification for a service (that an IngressRoute
  1372. refers to) that is usually not a terminal service (i.e. not a pod of servers),
  1373. as opposed to a Kubernetes Service. That is to say, it usually refers to
  1374. other (children) services, which themselves can be TraefikServices or Services.
  1375. properties:
  1376. apiVersion:
  1377. description: 'APIVersion defines the versioned schema of this representation
  1378. of an object. Servers should convert recognized schemas to the latest
  1379. internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
  1380. type: string
  1381. kind:
  1382. description: 'Kind is a string value representing the REST resource this
  1383. object represents. Servers may infer this from the endpoint the client
  1384. submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
  1385. type: string
  1386. metadata:
  1387. type: object
  1388. spec:
  1389. description: ServiceSpec defines whether a TraefikService is a load-balancer
  1390. of services or a mirroring service.
  1391. properties:
  1392. mirroring:
  1393. description: Mirroring defines a mirroring service, which is composed
  1394. of a main load-balancer, and a list of mirrors.
  1395. properties:
  1396. kind:
  1397. enum:
  1398. - Service
  1399. - TraefikService
  1400. type: string
  1401. maxBodySize:
  1402. format: int64
  1403. type: integer
  1404. mirrors:
  1405. items:
  1406. description: MirrorService defines one of the mirrors of a Mirroring
  1407. service.
  1408. properties:
  1409. kind:
  1410. enum:
  1411. - Service
  1412. - TraefikService
  1413. type: string
  1414. name:
  1415. description: Name is a reference to a Kubernetes Service
  1416. object (for a load-balancer of servers), or to a TraefikService
  1417. object (service load-balancer, mirroring, etc). The differentiation
  1418. between the two is specified in the Kind field.
  1419. type: string
  1420. namespace:
  1421. type: string
  1422. passHostHeader:
  1423. type: boolean
  1424. percent:
  1425. type: integer
  1426. port:
  1427. anyOf:
  1428. - type: integer
  1429. - type: string
  1430. x-kubernetes-int-or-string: true
  1431. responseForwarding:
  1432. description: ResponseForwarding holds configuration for
  1433. the forward of the response.
  1434. properties:
  1435. flushInterval:
  1436. type: string
  1437. type: object
  1438. scheme:
  1439. type: string
  1440. serversTransport:
  1441. type: string
  1442. sticky:
  1443. description: Sticky holds the sticky configuration.
  1444. properties:
  1445. cookie:
  1446. description: Cookie holds the sticky configuration based
  1447. on cookie.
  1448. properties:
  1449. httpOnly:
  1450. type: boolean
  1451. name:
  1452. type: string
  1453. sameSite:
  1454. type: string
  1455. secure:
  1456. type: boolean
  1457. type: object
  1458. type: object
  1459. strategy:
  1460. type: string
  1461. weight:
  1462. description: Weight should only be specified when Name references
  1463. a TraefikService object (and to be precise, one that embeds
  1464. a Weighted Round Robin).
  1465. type: integer
  1466. required:
  1467. - name
  1468. type: object
  1469. type: array
  1470. name:
  1471. description: Name is a reference to a Kubernetes Service object
  1472. (for a load-balancer of servers), or to a TraefikService object
  1473. (service load-balancer, mirroring, etc). The differentiation
  1474. between the two is specified in the Kind field.
  1475. type: string
  1476. namespace:
  1477. type: string
  1478. passHostHeader:
  1479. type: boolean
  1480. port:
  1481. anyOf:
  1482. - type: integer
  1483. - type: string
  1484. x-kubernetes-int-or-string: true
  1485. responseForwarding:
  1486. description: ResponseForwarding holds configuration for the forward
  1487. of the response.
  1488. properties:
  1489. flushInterval:
  1490. type: string
  1491. type: object
  1492. scheme:
  1493. type: string
  1494. serversTransport:
  1495. type: string
  1496. sticky:
  1497. description: Sticky holds the sticky configuration.
  1498. properties:
  1499. cookie:
  1500. description: Cookie holds the sticky configuration based on
  1501. cookie.
  1502. properties:
  1503. httpOnly:
  1504. type: boolean
  1505. name:
  1506. type: string
  1507. sameSite:
  1508. type: string
  1509. secure:
  1510. type: boolean
  1511. type: object
  1512. type: object
  1513. strategy:
  1514. type: string
  1515. weight:
  1516. description: Weight should only be specified when Name references
  1517. a TraefikService object (and to be precise, one that embeds
  1518. a Weighted Round Robin).
  1519. type: integer
  1520. required:
  1521. - name
  1522. type: object
  1523. weighted:
  1524. description: WeightedRoundRobin defines a load-balancer of services.
  1525. properties:
  1526. services:
  1527. items:
  1528. description: Service defines an upstream to proxy traffic.
  1529. properties:
  1530. kind:
  1531. enum:
  1532. - Service
  1533. - TraefikService
  1534. type: string
  1535. name:
  1536. description: Name is a reference to a Kubernetes Service
  1537. object (for a load-balancer of servers), or to a TraefikService
  1538. object (service load-balancer, mirroring, etc). The differentiation
  1539. between the two is specified in the Kind field.
  1540. type: string
  1541. namespace:
  1542. type: string
  1543. passHostHeader:
  1544. type: boolean
  1545. port:
  1546. anyOf:
  1547. - type: integer
  1548. - type: string
  1549. x-kubernetes-int-or-string: true
  1550. responseForwarding:
  1551. description: ResponseForwarding holds configuration for
  1552. the forward of the response.
  1553. properties:
  1554. flushInterval:
  1555. type: string
  1556. type: object
  1557. scheme:
  1558. type: string
  1559. serversTransport:
  1560. type: string
  1561. sticky:
  1562. description: Sticky holds the sticky configuration.
  1563. properties:
  1564. cookie:
  1565. description: Cookie holds the sticky configuration based
  1566. on cookie.
  1567. properties:
  1568. httpOnly:
  1569. type: boolean
  1570. name:
  1571. type: string
  1572. sameSite:
  1573. type: string
  1574. secure:
  1575. type: boolean
  1576. type: object
  1577. type: object
  1578. strategy:
  1579. type: string
  1580. weight:
  1581. description: Weight should only be specified when Name references
  1582. a TraefikService object (and to be precise, one that embeds
  1583. a Weighted Round Robin).
  1584. type: integer
  1585. required:
  1586. - name
  1587. type: object
  1588. type: array
  1589. sticky:
  1590. description: Sticky holds the sticky configuration.
  1591. properties:
  1592. cookie:
  1593. description: Cookie holds the sticky configuration based on
  1594. cookie.
  1595. properties:
  1596. httpOnly:
  1597. type: boolean
  1598. name:
  1599. type: string
  1600. sameSite:
  1601. type: string
  1602. secure:
  1603. type: boolean
  1604. type: object
  1605. type: object
  1606. type: object
  1607. type: object
  1608. required:
  1609. - metadata
  1610. - spec
  1611. type: object
  1612. served: true
  1613. storage: true
  1614. status:
  1615. acceptedNames:
  1616. kind: ""
  1617. plural: ""
  1618. conditions: []
  1619. storedVersions: []
  1620. ---
  1621. apiVersion: rbac.authorization.k8s.io/v1
  1622. kind: ClusterRole
  1623. metadata:
  1624. name: traefik-ingress-controller
  1625. rules:
  1626. - apiGroups:
  1627. - ""
  1628. resources:
  1629. - services
  1630. - endpoints
  1631. - secrets
  1632. verbs:
  1633. - get
  1634. - list
  1635. - watch
  1636. - apiGroups:
  1637. - extensions
  1638. - networking.k8s.io
  1639. resources:
  1640. - ingresses
  1641. - ingressclasses
  1642. verbs:
  1643. - get
  1644. - list
  1645. - watch
  1646. - apiGroups:
  1647. - extensions
  1648. resources:
  1649. - ingresses/status
  1650. verbs:
  1651. - update
  1652. - apiGroups:
  1653. - traefik.containo.us
  1654. resources:
  1655. - middlewares
  1656. - middlewaretcps
  1657. - ingressroutes
  1658. - traefikservices
  1659. - ingressroutetcps
  1660. - ingressrouteudps
  1661. - tlsoptions
  1662. - tlsstores
  1663. - serverstransports
  1664. verbs:
  1665. - get
  1666. - list
  1667. - watch
  1668. ---
  1669. apiVersion: rbac.authorization.k8s.io/v1
  1670. kind: ClusterRoleBinding
  1671. metadata:
  1672. name: traefik-ingress-controller
  1673. roleRef:
  1674. apiGroup: rbac.authorization.k8s.io
  1675. kind: ClusterRole
  1676. name: traefik-ingress-controller
  1677. subjects:
  1678. - kind: ServiceAccount
  1679. name: traefik-ingress-controller
  1680. namespace: default

Services

Then, the services. One for Traefik itself, and one for the app it routes for, i.e. in this case our demo HTTP server: whoami.

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. name: traefik
  5. spec:
  6. ports:
  7. - protocol: TCP
  8. name: web
  9. port: 8000
  10. - protocol: TCP
  11. name: admin
  12. port: 8080
  13. - protocol: TCP
  14. name: websecure
  15. port: 4443
  16. selector:
  17. app: traefik
  18. ---
  19. apiVersion: v1
  20. kind: Service
  21. metadata:
  22. name: whoami
  23. spec:
  24. ports:
  25. - protocol: TCP
  26. name: web
  27. port: 80
  28. selector:
  29. app: whoami

Deployments

Next, the deployments, i.e. the actual pods behind the services. Again, one pod for Traefik, and one for the whoami app.

  1. apiVersion: v1
  2. kind: ServiceAccount
  3. metadata:
  4. namespace: default
  5. name: traefik-ingress-controller
  6. ---
  7. kind: Deployment
  8. apiVersion: apps/v1
  9. metadata:
  10. namespace: default
  11. name: traefik
  12. labels:
  13. app: traefik
  14. spec:
  15. replicas: 1
  16. selector:
  17. matchLabels:
  18. app: traefik
  19. template:
  20. metadata:
  21. labels:
  22. app: traefik
  23. spec:
  24. serviceAccountName: traefik-ingress-controller
  25. containers:
  26. - name: traefik
  27. image: traefik:v2.6
  28. args:
  29. - --api.insecure
  30. - --accesslog
  31. - --entrypoints.web.Address=:8000
  32. - --entrypoints.websecure.Address=:4443
  33. - --providers.kubernetescrd
  34. - --certificatesresolvers.myresolver.acme.tlschallenge
  35. - --certificatesresolvers.myresolver.acme.email=foo@you.com
  36. - --certificatesresolvers.myresolver.acme.storage=acme.json
  37. # Please note that this is the staging Let's Encrypt server.
  38. # Once you get things working, you should remove that whole line altogether.
  39. - --certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
  40. ports:
  41. - name: web
  42. containerPort: 8000
  43. - name: websecure
  44. containerPort: 4443
  45. - name: admin
  46. containerPort: 8080
  47. ---
  48. kind: Deployment
  49. apiVersion: apps/v1
  50. metadata:
  51. namespace: default
  52. name: whoami
  53. labels:
  54. app: whoami
  55. spec:
  56. replicas: 2
  57. selector:
  58. matchLabels:
  59. app: whoami
  60. template:
  61. metadata:
  62. labels:
  63. app: whoami
  64. spec:
  65. containers:
  66. - name: whoami
  67. image: traefik/whoami
  68. ports:
  69. - name: web
  70. containerPort: 80

Port Forwarding

Now, as an exception to what we said above, please note that you should not let the ingressRoute resources below be applied automatically to your cluster. The reason is, as soon as the ACME provider of Traefik detects we have TLS routers, it will try to generate the certificates for the corresponding domains. And this will not work, because as it is, our Traefik pod is not reachable from the outside, which will make the ACME TLS challenge fail. Therefore, for the whole thing to work, we must delay applying the ingressRoute resources until we have port-forwarding set up properly, which is the next step.

  1. kubectl port-forward --address 0.0.0.0 service/traefik 8000:8000 8080:8080 443:4443 -n default

Also, and this is out of the scope if this guide, please note that because of the privileged ports limitation on Linux, the above command might fail to listen on port 443. In which case you can use tricks such as elevating caps of kubectl with setcaps, or using authbind, or setting up a NAT between your host and the WAN. Look it up.

Traefik Routers

We can now finally apply the actual ingressRoutes, with:

  1. kubectl apply -f 04-ingressroutes.yml
  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: simpleingressroute
  5. namespace: default
  6. spec:
  7. entryPoints:
  8. - web
  9. routes:
  10. - match: Host(`your.example.com`) && PathPrefix(`/notls`)
  11. kind: Rule
  12. services:
  13. - name: whoami
  14. port: 80
  15. ---
  16. apiVersion: traefik.containo.us/v1alpha1
  17. kind: IngressRoute
  18. metadata:
  19. name: ingressroutetls
  20. namespace: default
  21. spec:
  22. entryPoints:
  23. - websecure
  24. routes:
  25. - match: Host(`your.example.com`) && PathPrefix(`/tls`)
  26. kind: Rule
  27. services:
  28. - name: whoami
  29. port: 80
  30. tls:
  31. certResolver: myresolver

Give it a few seconds for the ACME TLS challenge to complete, and you should then be able to access your whoami pod (routed through Traefik), from the outside. Both with or (just for fun, do not do that in production) without TLS:

  1. curl [-k] https://your.example.com/tls
  1. curl http://your.example.com:8000/notls

Note that you’ll have to use -k as long as you’re using the staging server of Let’s Encrypt, since it is not an authorized certificate authority on systems where it hasn’t been manually added.