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

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.