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

RBAC for Traefik CRD

  1. apiVersion: rbac.authorization.k8s.io/v1
  2. kind: ClusterRole
  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. apiVersion: rbac.authorization.k8s.io/v1
  50. kind: ClusterRoleBinding
  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

allowEmptyServices

Optional, Default: false

If the parameter is set to true, it allows the creation of an empty servers load balancer if the targeted Kubernetes service has no endpoints available. With IngressRoute resources, this results in 503 HTTP responses instead of 404 ones.

File (YAML)

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

File (TOML)

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

CLI

  1. --providers.kubernetesCRD.allowEmptyServices=true

allowCrossNamespace

Optional, Default: false

If the parameter is set to true, IngressRoute are able to reference resources in namespaces other 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.