Traefik & Kubernetes

The Kubernetes Ingress Controller, The Custom Resource Way.

In early versions, Traefik supported Kubernetes only through the Kubernetes Ingress provider, which is a Kubernetes Ingress controller in the strict sense of the term.

However, as the community expressed the need to benefit from Traefik features without resorting to (lots of) annotations, the Traefik engineering team developed a Custom Resource Definition (CRD) for an IngressRoute type, defined below, in order to provide a better way to configure access to a Kubernetes cluster.

Configuration Requirements

All Steps for a Successful Deployment

  • Add/update all the Traefik resources definitions
  • Add/update the RBAC for the Traefik custom resources
  • Use Helm Chart or use a custom Traefik Deployment
    • Enable the kubernetesCRD provider
    • Apply the needed kubernetesCRD provider configuration
  • Add all necessary Traefik custom resources

Deprecated apiextensions.k8s.io/v1beta1 CRD

The apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in Kubernetes v1.16+ and will be removed in v1.22+.

For Kubernetes v1.16+, please use the Traefik apiextensions.k8s.io/v1 CRDs instead.

Initializing Resource Definition and RBAC

Traefik Resource Definition

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

RBAC for Traefik CRD

  1. kind: ClusterRole
  2. apiVersion: rbac.authorization.k8s.io/v1beta1
  3. metadata:
  4. name: traefik-ingress-controller
  5. rules:
  6. - apiGroups:
  7. - ""
  8. resources:
  9. - services
  10. - endpoints
  11. - secrets
  12. verbs:
  13. - get
  14. - list
  15. - watch
  16. - apiGroups:
  17. - extensions
  18. - networking.k8s.io
  19. resources:
  20. - ingresses
  21. - ingressclasses
  22. verbs:
  23. - get
  24. - list
  25. - watch
  26. - apiGroups:
  27. - extensions
  28. resources:
  29. - ingresses/status
  30. verbs:
  31. - update
  32. - apiGroups:
  33. - traefik.containo.us
  34. resources:
  35. - middlewares
  36. - middlewaretcps
  37. - ingressroutes
  38. - traefikservices
  39. - ingressroutetcps
  40. - ingressrouteudps
  41. - tlsoptions
  42. - tlsstores
  43. - serverstransports
  44. verbs:
  45. - get
  46. - list
  47. - watch
  48. ---
  49. kind: ClusterRoleBinding
  50. apiVersion: rbac.authorization.k8s.io/v1beta1
  51. metadata:
  52. name: traefik-ingress-controller
  53. roleRef:
  54. apiGroup: rbac.authorization.k8s.io
  55. kind: ClusterRole
  56. name: traefik-ingress-controller
  57. subjects:
  58. - kind: ServiceAccount
  59. name: traefik-ingress-controller
  60. namespace: default

Resource Configuration

When using KubernetesCRD as a provider, Traefik uses Custom Resource Definition to retrieve its routing configuration. Traefik Custom Resource Definitions are a Kubernetes implementation of the Traefik concepts. The main particularities are:

  • The usage of name and namespace to refer to another Kubernetes resource.
  • The usage of secret for sensitive data (TLS certificates and credentials).
  • The structure of the configuration.
  • The requirement to declare all the definitions.

The Traefik CRDs are building blocks that you can assemble according to your needs. See the list of CRDs in the dedicated routing section.

LetsEncrypt Support with the Custom Resource Definition Provider

By design, Traefik is a stateless application, meaning that it only derives its configuration from the environment it runs in, without additional configuration. For this reason, users can run multiple instances of Traefik at the same time to achieve HA, as is a common pattern in the kubernetes ecosystem.

When using a single instance of Traefik with Let’s Encrypt, you should encounter no issues. However, this could be a single point of failure. Unfortunately, it is not possible to run multiple instances of Traefik Proxy 2.0 with Let’s Encrypt enabled, because there is no way to ensure that the correct instance of Traefik will receive the challenge request and subsequent responses. Previous versions of Traefik used a KV store to attempt to achieve this, but due to sub-optimal performance that feature was dropped in 2.0.

If you need Let’s Encrypt with HA in a Kubernetes environment, we recommend using Traefik Enterprise, which includes distributed Let’s Encrypt as a supported feature.

If you want to keep using Traefik Proxy, high availability for Let’s Encrypt can be achieved by using a Certificate Controller such as Cert-Manager. When using Cert-Manager to manage certificates, it creates secrets in your namespaces that can be referenced as TLS secrets in your ingress objects. When using the Traefik Kubernetes CRD Provider, unfortunately Cert-Manager cannot yet interface directly with the CRDs. A workaround is to enable the Kubernetes Ingress provider to allow Cert-Manager to create ingress objects to complete the challenges. Please note that this still requires manual intervention to create the certificates through Cert-Manager, but once the certificates are created, Cert-Manager keeps them renewed.

Provider Configuration

endpoint

Optional, Default=””

The Kubernetes server endpoint URL.

When deployed into Kubernetes, Traefik reads the environment variables KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT or KUBECONFIG to construct the endpoint.

The access token is looked up in /var/run/secrets/kubernetes.io/serviceaccount/token and the SSL CA certificate in /var/run/secrets/kubernetes.io/serviceaccount/ca.crt. Both are mounted automatically when deployed inside Kubernetes.

The endpoint may be specified to override the environment variable values inside a cluster.

When the environment variables are not found, Traefik tries to connect to the Kubernetes API server with an external-cluster client. In this case, the endpoint is required. Specifically, it may be set to the URL used by kubectl proxy to connect to a Kubernetes cluster using the granted authentication and authorization of the associated kubeconfig.

File (YAML)

  1. providers:
  2. kubernetesCRD:
  3. endpoint: "http://localhost:8080"
  4. # ...

File (TOML)

  1. [providers.kubernetesCRD]
  2. endpoint = "http://localhost:8080"
  3. # ...

CLI

  1. --providers.kubernetescrd.endpoint=http://localhost:8080

token

Optional, Default=””

Bearer token used for the Kubernetes client configuration.

File (YAML)

  1. providers:
  2. kubernetesCRD:
  3. token: "mytoken"
  4. # ...

File (TOML)

  1. [providers.kubernetesCRD]
  2. token = "mytoken"
  3. # ...

CLI

  1. --providers.kubernetescrd.token=mytoken

certAuthFilePath

Optional, Default=””

Path to the certificate authority file. Used for the Kubernetes client configuration.

File (YAML)

  1. providers:
  2. kubernetesCRD:
  3. certAuthFilePath: "/my/ca.crt"
  4. # ...

File (TOML)

  1. [providers.kubernetesCRD]
  2. certAuthFilePath = "/my/ca.crt"
  3. # ...

CLI

  1. --providers.kubernetescrd.certauthfilepath=/my/ca.crt

namespaces

Optional, Default: []

Array of namespaces to watch. If left empty, watches all namespaces if the value of namespaces.

File (YAML)

  1. providers:
  2. kubernetesCRD:
  3. namespaces:
  4. - "default"
  5. - "production"
  6. # ...

File (TOML)

  1. [providers.kubernetesCRD]
  2. namespaces = ["default", "production"]
  3. # ...

CLI

  1. --providers.kubernetescrd.namespaces=default,production

labelselector

Optional, Default: “”

A label selector can be defined to filter on specific resource objects only, this applies only to Traefik Custom Resources and has no effect on Kubernetes Secrets, Endpoints and Services. If left empty, Traefik processes all resource objects in the configured namespaces.

See label-selectors for details.

Warning

Because the label selector is applied to all Traefik Custom Resources, they all must match the filter.

File (YAML)

  1. providers:
  2. kubernetesCRD:
  3. labelselector: "app=traefik"
  4. # ...

File (TOML)

  1. [providers.kubernetesCRD]
  2. labelselector = "app=traefik"
  3. # ...

CLI

  1. --providers.kubernetescrd.labelselector="app=traefik"

ingressClass

Optional, Default: “”

Value of kubernetes.io/ingress.class annotation that identifies resource objects to be processed.

If the parameter is set, only resources containing an annotation with the same value are processed. Otherwise, resources missing the annotation, having an empty value, or the value traefik are processed.

File (YAML)

  1. providers:
  2. kubernetesCRD:
  3. ingressClass: "traefik-internal"
  4. # ...

File (TOML)

  1. [providers.kubernetesCRD]
  2. ingressClass = "traefik-internal"
  3. # ...

CLI

  1. --providers.kubernetescrd.ingressclass=traefik-internal

throttleDuration

Optional, Default: 0

The throttleDuration option defines how often the provider is allowed to handle events from Kubernetes. This prevents a Kubernetes cluster that updates many times per second from continuously changing your Traefik configuration.

If left empty, the provider does not apply any throttling and does not drop any Kubernetes events.

The value of throttleDuration should be provided in seconds or as a valid duration format, see time.ParseDuration.

File (YAML)

  1. providers:
  2. kubernetesCRD:
  3. throttleDuration: "10s"
  4. # ...

File (TOML)

  1. [providers.kubernetesCRD]
  2. throttleDuration = "10s"
  3. # ...

CLI

  1. --providers.kubernetescrd.throttleDuration=10s

allowCrossNamespace

Optional, Default: false

If the parameter is set to true, IngressRoutes are able to reference resources in other namespaces than theirs.

File (YAML)

  1. providers:
  2. kubernetesCRD:
  3. allowCrossNamespace: true
  4. # ...

File (TOML)

  1. [providers.kubernetesCRD]
  2. allowCrossNamespace = true
  3. # ...

CLI

  1. --providers.kubernetescrd.allowCrossNamespace=true

allowExternalNameServices

Optional, Default: false

If the parameter is set to true, IngressRoutes are able to reference ExternalName services.

File (YAML)

  1. providers:
  2. kubernetesCRD:
  3. allowExternalNameServices: true
  4. # ...

File (TOML)

  1. [providers.kubernetesCRD]
  2. allowExternalNameServices = true
  3. # ...

CLI

  1. --providers.kubernetescrd.allowexternalnameservices=true

Full Example

For additional information, refer to the full example with Let’s Encrypt.