Traefik & Kubernetes

The Kubernetes Ingress Controller, The Custom Resource Way.

Configuration Examples

Configuring KubernetesCRD and Deploying/Exposing Services

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

  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

Traefik

  1. apiVersion: v1
  2. kind: ServiceAccount
  3. metadata:
  4. name: traefik-ingress-controller
  5. ---
  6. kind: Deployment
  7. apiVersion: apps/v1
  8. metadata:
  9. name: traefik
  10. labels:
  11. app: traefik
  12. spec:
  13. replicas: 1
  14. selector:
  15. matchLabels:
  16. app: traefik
  17. template:
  18. metadata:
  19. labels:
  20. app: traefik
  21. spec:
  22. serviceAccountName: traefik-ingress-controller
  23. containers:
  24. - name: traefik
  25. image: traefik:v2.7
  26. args:
  27. - --log.level=DEBUG
  28. - --api
  29. - --api.insecure
  30. - --entrypoints.web.address=:80
  31. - --entrypoints.tcpep.address=:8000
  32. - --entrypoints.udpep.address=:9000/udp
  33. - --providers.kubernetescrd
  34. ports:
  35. - name: web
  36. containerPort: 80
  37. - name: admin
  38. containerPort: 8080
  39. - name: tcpep
  40. containerPort: 8000
  41. - name: udpep
  42. containerPort: 9000
  43. ---
  44. apiVersion: v1
  45. kind: Service
  46. metadata:
  47. name: traefik
  48. spec:
  49. type: LoadBalancer
  50. selector:
  51. app: traefik
  52. ports:
  53. - protocol: TCP
  54. port: 80
  55. name: web
  56. targetPort: 80
  57. - protocol: TCP
  58. port: 8080
  59. name: admin
  60. targetPort: 8080
  61. - protocol: TCP
  62. port: 8000
  63. name: tcpep
  64. targetPort: 8000
  65. ---
  66. apiVersion: v1
  67. kind: Service
  68. metadata:
  69. name: traefikudp
  70. spec:
  71. type: LoadBalancer
  72. selector:
  73. app: traefik
  74. ports:
  75. - protocol: UDP
  76. port: 9000
  77. name: udpep
  78. targetPort: 9000

IngressRoute

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: myingressroute
  5. namespace: default
  6. spec:
  7. entryPoints:
  8. - web
  9. routes:
  10. - match: Host(`foo`) && PathPrefix(`/bar`)
  11. kind: Rule
  12. services:
  13. - name: whoami
  14. port: 80
  15. ---
  16. apiVersion: traefik.containo.us/v1alpha1
  17. kind: IngressRouteTCP
  18. metadata:
  19. name: ingressroute.tcp
  20. namespace: default
  21. spec:
  22. entryPoints:
  23. - tcpep
  24. routes:
  25. - match: HostSNI(`bar`)
  26. services:
  27. - name: whoamitcp
  28. port: 8080
  29. ---
  30. apiVersion: traefik.containo.us/v1alpha1
  31. kind: IngressRouteUDP
  32. metadata:
  33. name: ingressroute.udp
  34. namespace: default
  35. spec:
  36. entryPoints:
  37. - udpep
  38. routes:
  39. - services:
  40. - name: whoamiudp
  41. port: 8080

Whoami

  1. kind: Deployment
  2. apiVersion: apps/v1
  3. metadata:
  4. name: whoami
  5. namespace: default
  6. labels:
  7. app: traefiklabs
  8. name: whoami
  9. spec:
  10. replicas: 2
  11. selector:
  12. matchLabels:
  13. app: traefiklabs
  14. task: whoami
  15. template:
  16. metadata:
  17. labels:
  18. app: traefiklabs
  19. task: whoami
  20. spec:
  21. containers:
  22. - name: whoami
  23. image: traefik/whoami
  24. ports:
  25. - containerPort: 80
  26. ---
  27. apiVersion: v1
  28. kind: Service
  29. metadata:
  30. name: whoami
  31. namespace: default
  32. spec:
  33. ports:
  34. - name: http
  35. port: 80
  36. selector:
  37. app: traefiklabs
  38. task: whoami
  39. ---
  40. kind: Deployment
  41. apiVersion: apps/v1
  42. metadata:
  43. name: whoamitcp
  44. namespace: default
  45. labels:
  46. app: traefiklabs
  47. name: whoamitcp
  48. spec:
  49. replicas: 2
  50. selector:
  51. matchLabels:
  52. app: traefiklabs
  53. task: whoamitcp
  54. template:
  55. metadata:
  56. labels:
  57. app: traefiklabs
  58. task: whoamitcp
  59. spec:
  60. containers:
  61. - name: whoamitcp
  62. image: traefik/whoamitcp
  63. ports:
  64. - containerPort: 8080
  65. ---
  66. apiVersion: v1
  67. kind: Service
  68. metadata:
  69. name: whoamitcp
  70. namespace: default
  71. spec:
  72. ports:
  73. - protocol: TCP
  74. port: 8080
  75. selector:
  76. app: traefiklabs
  77. task: whoamitcp
  78. ---
  79. kind: Deployment
  80. apiVersion: apps/v1
  81. metadata:
  82. name: whoamiudp
  83. namespace: default
  84. labels:
  85. app: traefiklabs
  86. name: whoamiudp
  87. spec:
  88. replicas: 2
  89. selector:
  90. matchLabels:
  91. app: traefiklabs
  92. task: whoamiudp
  93. template:
  94. metadata:
  95. labels:
  96. app: traefiklabs
  97. task: whoamiudp
  98. spec:
  99. containers:
  100. - name: whoamiudp
  101. image: traefik/whoamiudp:latest
  102. ports:
  103. - containerPort: 8080
  104. ---
  105. apiVersion: v1
  106. kind: Service
  107. metadata:
  108. name: whoamiudp
  109. namespace: default
  110. spec:
  111. ports:
  112. - port: 8080
  113. selector:
  114. app: traefiklabs
  115. task: whoamiudp

Routing Configuration

Custom Resource Definition (CRD)

  • You can find an exhaustive list, generated from Traefik’s source code, of the custom resources and their attributes in the reference page.
  • Validate that the prerequisites are fulfilled before using the Traefik custom resources.
  • Traefik CRDs are building blocks that you can assemble according to your needs.

You can find an excerpt of the available custom resources in the table below:

KindPurposeConcept Behind
IngressRouteHTTP RoutingHTTP router
MiddlewareTweaks the HTTP requests before they are sent to your serviceHTTP Middlewares
TraefikServiceAbstraction for HTTP loadbalancing/mirroringHTTP service
IngressRouteTCPTCP RoutingTCP router
MiddlewareTCPTweaks the TCP requests before they are sent to your serviceTCP Middlewares
IngressRouteUDPUDP RoutingUDP router
TLSOptionsAllows to configure some parameters of the TLS connectionTLSOptions
TLSStoresAllows to configure the default TLS storeTLSStores
ServersTransportAllows to configure the transport between Traefik and the backendsServersTransport

Kind: IngressRoute

IngressRoute is the CRD implementation of a Traefik HTTP router.

Register the IngressRoute kind in the Kubernetes cluster before creating IngressRoute objects.

IngressRoute Attributes

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: foo
  5. namespace: bar
  6. spec:
  7. entryPoints: # [1]
  8. - foo
  9. routes: # [2]
  10. - kind: Rule
  11. match: Host(`test.example.com`) # [3]
  12. priority: 10 # [4]
  13. middlewares: # [5]
  14. - name: middleware1 # [6]
  15. namespace: default # [7]
  16. services: # [8]
  17. - kind: Service
  18. name: foo
  19. namespace: default
  20. passHostHeader: true
  21. port: 80 # [9]
  22. responseForwarding:
  23. flushInterval: 1ms
  24. scheme: https
  25. serversTransport: transport # [10]
  26. sticky:
  27. cookie:
  28. httpOnly: true
  29. name: cookie
  30. secure: true
  31. sameSite: none
  32. strategy: RoundRobin
  33. weight: 10
  34. tls: # [11]
  35. secretName: supersecret # [12]
  36. options: # [13]
  37. name: opt # [14]
  38. namespace: default # [15]
  39. certResolver: foo # [16]
  40. domains: # [17]
  41. - main: example.net # [18]
  42. sans: # [19]
  43. - a.example.net
  44. - b.example.net
RefAttributePurpose
[1]entryPointsList of entry points names
[2]routesList of routes
[3]routes[n].matchDefines the rule corresponding to an underlying router.
[4]routes[n].priorityDefines the priority to disambiguate rules of the same length, for route matching
[5]routes[n].middlewaresList of reference to Middleware
[6]middlewares[n].nameDefines the Middleware name
[7]middlewares[n].namespaceDefines the Middleware namespace
[8]routes[n].servicesList of any combination of TraefikService and reference to a Kubernetes service (See below for ExternalName Service setup)
[9]services[n].portDefines the port of a Kubernetes service. This can be a reference to a named port.
[10]services[n].serversTransportDefines the reference to a ServersTransport. The ServersTransport namespace is assumed to be the Kubernetes service namespace (see ServersTransport reference).
[11]tlsDefines TLS certificate configuration
[12]tls.secretNameDefines the secret name used to store the certificate (in the IngressRoute namespace)
[13]tls.optionsDefines the reference to a TLSOption
[14]options.nameDefines the TLSOption name
[15]options.namespaceDefines the TLSOption namespace
[16]tls.certResolverDefines the reference to a CertResolver
[17]tls.domainsList of domains
[18]domains[n].mainDefines the main domain name
[19]domains[n].sansList of SANs (alternative domains)

Declaring an IngressRoute

IngressRoute

  1. # All resources definition must be declared
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: IngressRoute
  4. metadata:
  5. name: test-name
  6. namespace: default
  7. spec:
  8. entryPoints:
  9. - web
  10. routes:
  11. - kind: Rule
  12. match: Host(`test.example.com`)
  13. middlewares:
  14. - name: middleware1
  15. namespace: default
  16. priority: 10
  17. services:
  18. - kind: Service
  19. name: foo
  20. namespace: default
  21. passHostHeader: true
  22. port: 80
  23. responseForwarding:
  24. flushInterval: 1ms
  25. scheme: https
  26. sticky:
  27. cookie:
  28. httpOnly: true
  29. name: cookie
  30. secure: true
  31. strategy: RoundRobin
  32. weight: 10
  33. tls:
  34. certResolver: foo
  35. domains:
  36. - main: example.net
  37. sans:
  38. - a.example.net
  39. - b.example.net
  40. options:
  41. name: opt
  42. namespace: default
  43. secretName: supersecret

Middlewares

  1. # All resources definition must be declared
  2. # Prefixing with /foo
  3. apiVersion: traefik.containo.us/v1alpha1
  4. kind: Middleware
  5. metadata:
  6. name: middleware1
  7. namespace: default
  8. spec:
  9. addPrefix:
  10. prefix: /foo

TLSOption

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: TLSOption
  3. metadata:
  4. name: opt
  5. namespace: default
  6. spec:
  7. minVersion: VersionTLS12

Secret

  1. apiVersion: v1
  2. kind: Secret
  3. metadata:
  4. name: supersecret
  5. data:
  6. tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=
  7. tls.key: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0=

Configuring Backend Protocol

There are 3 ways to configure the backend protocol for communication between Traefik and your pods:

  • Setting the scheme explicitly (http/https/h2c)
  • Configuring the name of the kubernetes service port to start with https (https)
  • Setting the kubernetes service port to use port 443 (https)

If you do not configure the above, Traefik will assume an http connection.

Using Kubernetes ExternalName Service

Traefik backends creation needs a port to be set, however Kubernetes ExternalName Service could be defined without any port. Accordingly, Traefik supports defining a port in two ways:

  • only on IngressRoute service
  • on both sides, you’ll be warned if the ports don’t match, and the IngressRoute service port is used

Thus, in case of two sides port definition, Traefik expects a match between ports.

Examples

IngressRoute

  1. ---
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: IngressRoute
  4. metadata:
  5. name: test.route
  6. namespace: default
  7. spec:
  8. entryPoints:
  9. - foo
  10. routes:
  11. - match: Host(`example.net`)
  12. kind: Rule
  13. services:
  14. - name: external-svc
  15. port: 80
  16. ---
  17. apiVersion: v1
  18. kind: Service
  19. metadata:
  20. name: external-svc
  21. namespace: default
  22. spec:
  23. externalName: external.domain
  24. type: ExternalName

ExternalName Service

  1. ---
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: IngressRoute
  4. metadata:
  5. name: test.route
  6. namespace: default
  7. spec:
  8. entryPoints:
  9. - foo
  10. routes:
  11. - match: Host(`example.net`)
  12. kind: Rule
  13. services:
  14. - name: external-svc
  15. ---
  16. apiVersion: v1
  17. kind: Service
  18. metadata:
  19. name: external-svc
  20. namespace: default
  21. spec:
  22. externalName: external.domain
  23. type: ExternalName
  24. ports:
  25. - port: 80

Both sides

  1. ---
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: IngressRoute
  4. metadata:
  5. name: test.route
  6. namespace: default
  7. spec:
  8. entryPoints:
  9. - foo
  10. routes:
  11. - match: Host(`example.net`)
  12. kind: Rule
  13. services:
  14. - name: external-svc
  15. port: 80
  16. ---
  17. apiVersion: v1
  18. kind: Service
  19. metadata:
  20. name: external-svc
  21. namespace: default
  22. spec:
  23. externalName: external.domain
  24. type: ExternalName
  25. ports:
  26. - port: 80

Kind: Middleware

Middleware is the CRD implementation of a Traefik middleware.

Register the Middleware kind in the Kubernetes cluster before creating Middleware objects or referencing middlewares in the IngressRoute objects.

Declaring and Referencing a Middleware

Middleware

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: Middleware
  3. metadata:
  4. name: stripprefix
  5. namespace: foo
  6. spec:
  7. stripPrefix:
  8. prefixes:
  9. - /stripit

IngressRoute

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: ingressroutebar
  5. spec:
  6. entryPoints:
  7. - web
  8. routes:
  9. - match: Host(`example.com`) && PathPrefix(`/stripit`)
  10. kind: Rule
  11. services:
  12. - name: whoami
  13. port: 80
  14. middlewares:
  15. - name: stripprefix
  16. namespace: foo

Cross-provider namespace

As Kubernetes also has its own notion of namespace, one should not confuse the kubernetes namespace of a resource (in the reference to the middleware) with the provider namespace, when the definition of the middleware comes from another provider. In this context, specifying a namespace when referring to the resource does not make any sense, and will be ignored. Additionally, when you want to reference a Middleware from the CRD Provider, you have to append the namespace of the resource in the resource-name as Traefik appends the namespace internally automatically.

More information about available middlewares in the dedicated middlewares section.

Kind: TraefikService

TraefikService is the CRD implementation of a “Traefik Service”.

Register the TraefikService kind in the Kubernetes cluster before creating TraefikService objects, referencing services in the IngressRoute objects, or recursively in others TraefikService objects.

Disambiguate Traefik and Kubernetes Services

As the field name can reference different types of objects, use the field kind to avoid any ambiguity.

The field kind allows the following values:

TraefikService object allows to use any (valid) combinations of:

Server Load Balancing

More information in the dedicated server load balancing section.

Declaring and Using Server Load Balancing

IngressRoute

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: ingressroutebar
  5. namespace: default
  6. spec:
  7. entryPoints:
  8. - web
  9. routes:
  10. - match: Host(`example.com`) && PathPrefix(`/foo`)
  11. kind: Rule
  12. services:
  13. - name: svc1
  14. namespace: default
  15. - name: svc2
  16. namespace: default

K8s Service

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. name: svc1
  5. namespace: default
  6. spec:
  7. ports:
  8. - name: http
  9. port: 80
  10. selector:
  11. app: traefiklabs
  12. task: app1
  13. ---
  14. apiVersion: v1
  15. kind: Service
  16. metadata:
  17. name: svc2
  18. namespace: default
  19. spec:
  20. ports:
  21. - name: http
  22. port: 80
  23. selector:
  24. app: traefiklabs
  25. task: app2

Weighted Round Robin

More information in the dedicated Weighted Round Robin service load balancing section.

Declaring and Using Weighted Round Robin

IngressRoute

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: ingressroutebar
  5. namespace: default
  6. spec:
  7. entryPoints:
  8. - web
  9. routes:
  10. - match: Host(`example.com`) && PathPrefix(`/foo`)
  11. kind: Rule
  12. services:
  13. - name: wrr1
  14. namespace: default
  15. kind: TraefikService

Weighted Round Robin

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: TraefikService
  3. metadata:
  4. name: wrr1
  5. namespace: default
  6. spec:
  7. weighted:
  8. services:
  9. - name: svc1
  10. port: 80
  11. weight: 1
  12. - name: wrr2
  13. kind: TraefikService
  14. weight: 1
  15. - name: mirror1
  16. kind: TraefikService
  17. weight: 1
  18. ---
  19. apiVersion: traefik.containo.us/v1alpha1
  20. kind: TraefikService
  21. metadata:
  22. name: wrr2
  23. namespace: default
  24. spec:
  25. weighted:
  26. services:
  27. - name: svc2
  28. port: 80
  29. weight: 1
  30. - name: svc3
  31. port: 80
  32. weight: 1

K8s Service

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. name: svc1
  5. namespace: default
  6. spec:
  7. ports:
  8. - name: http
  9. port: 80
  10. selector:
  11. app: traefiklabs
  12. task: app1
  13. ---
  14. apiVersion: v1
  15. kind: Service
  16. metadata:
  17. name: svc2
  18. namespace: default
  19. spec:
  20. ports:
  21. - name: http
  22. port: 80
  23. selector:
  24. app: traefiklabs
  25. task: app2
  26. ---
  27. apiVersion: v1
  28. kind: Service
  29. metadata:
  30. name: svc3
  31. namespace: default
  32. spec:
  33. ports:
  34. - name: http
  35. port: 80
  36. selector:
  37. app: traefiklabs
  38. task: app3

Mirroring

More information in the dedicated mirroring service section.

Declaring and Using Mirroring

IngressRoute

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: ingressroutebar
  5. namespace: default
  6. spec:
  7. entryPoints:
  8. - web
  9. routes:
  10. - match: Host(`example.com`) && PathPrefix(`/foo`)
  11. kind: Rule
  12. services:
  13. - name: mirror1
  14. namespace: default
  15. kind: TraefikService

Mirroring k8s Service

  1. # Mirroring from a k8s Service
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: TraefikService
  4. metadata:
  5. name: mirror1
  6. namespace: default
  7. spec:
  8. mirroring:
  9. name: svc1
  10. port: 80
  11. mirrors:
  12. - name: svc2
  13. port: 80
  14. percent: 20
  15. - name: svc3
  16. kind: TraefikService
  17. percent: 20

Mirroring Traefik Service

  1. # Mirroring from a Traefik Service
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: TraefikService
  4. metadata:
  5. name: mirror1
  6. namespace: default
  7. spec:
  8. mirroring:
  9. name: wrr1
  10. kind: TraefikService
  11. mirrors:
  12. - name: svc2
  13. port: 80
  14. percent: 20
  15. - name: svc3
  16. kind: TraefikService
  17. percent: 20

K8s Service

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. name: svc1
  5. namespace: default
  6. spec:
  7. ports:
  8. - name: http
  9. port: 80
  10. selector:
  11. app: traefiklabs
  12. task: app1
  13. ---
  14. apiVersion: v1
  15. kind: Service
  16. metadata:
  17. name: svc2
  18. namespace: default
  19. spec:
  20. ports:
  21. - name: http
  22. port: 80
  23. selector:
  24. app: traefiklabs
  25. task: app2

References and namespaces

If the optional namespace attribute is not set, the configuration will be applied with the namespace of the current resource.

Additionally, when the definition of the TraefikService is from another provider, the cross-provider syntax (service@provider) should be used to refer to the TraefikService, just as in the middleware case.

Specifying a namespace attribute in this case would not make any sense, and will be ignored (except if the provider is kubernetescrd).

Stickiness and load-balancing

As explained in the section about Sticky sessions, for stickiness to work all the way, it must be specified at each load-balancing level.

For instance, in the example below, there is a first level of load-balancing because there is a (Weighted Round Robin) load-balancing of the two whoami services, and there is a second level because each whoami service is a replicaset and is thus handled as a load-balancer of servers.

Stickiness on two load-balancing levels

IngressRoute

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: ingressroutebar
  5. namespace: default
  6. spec:
  7. entryPoints:
  8. - web
  9. routes:
  10. - match: Host(`example.com`) && PathPrefix(`/foo`)
  11. kind: Rule
  12. services:
  13. - name: wrr1
  14. namespace: default
  15. kind: TraefikService

Weighted Round Robin

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: TraefikService
  3. metadata:
  4. name: wrr1
  5. namespace: default
  6. spec:
  7. weighted:
  8. services:
  9. - name: whoami1
  10. kind: Service
  11. port: 80
  12. weight: 1
  13. sticky:
  14. cookie:
  15. name: lvl2
  16. - name: whoami2
  17. kind: Service
  18. weight: 1
  19. port: 80
  20. sticky:
  21. cookie:
  22. name: lvl2
  23. sticky:
  24. cookie:
  25. name: lvl1

K8s Service

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. name: whoami1
  5. spec:
  6. ports:
  7. - protocol: TCP
  8. name: web
  9. port: 80
  10. selector:
  11. app: whoami1
  12. ---
  13. apiVersion: v1
  14. kind: Service
  15. metadata:
  16. name: whoami2
  17. spec:
  18. ports:
  19. - protocol: TCP
  20. name: web
  21. port: 80
  22. selector:
  23. app: whoami2

Deployment (to illustrate replicas)

  1. kind: Deployment
  2. apiVersion: apps/v1
  3. metadata:
  4. namespace: default
  5. name: whoami1
  6. labels:
  7. app: whoami1
  8. spec:
  9. replicas: 2
  10. selector:
  11. matchLabels:
  12. app: whoami1
  13. template:
  14. metadata:
  15. labels:
  16. app: whoami1
  17. spec:
  18. containers:
  19. - name: whoami1
  20. image: traefik/whoami
  21. ports:
  22. - name: web
  23. containerPort: 80
  24. ---
  25. kind: Deployment
  26. apiVersion: apps/v1
  27. metadata:
  28. namespace: default
  29. name: whoami2
  30. labels:
  31. app: whoami2
  32. spec:
  33. replicas: 2
  34. selector:
  35. matchLabels:
  36. app: whoami2
  37. template:
  38. metadata:
  39. labels:
  40. app: whoami2
  41. spec:
  42. containers:
  43. - name: whoami2
  44. image: traefik/whoami
  45. ports:
  46. - name: web
  47. containerPort: 80

To keep a session open with the same server, the client would then need to specify the two levels within the cookie for each request, e.g. with curl:

  1. curl -H Host:example.com -b "lvl1=default-whoami1-80; lvl2=http://10.42.0.6:80" http://localhost:8000/foo

assuming 10.42.0.6 is the IP address of one of the replicas (a pod then) of the whoami1 service.

Kind IngressRouteTCP

IngressRouteTCP is the CRD implementation of a Traefik TCP router.

Register the IngressRouteTCP kind in the Kubernetes cluster before creating IngressRouteTCP objects.

IngressRouteTCP Attributes

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRouteTCP
  3. metadata:
  4. name: ingressroutetcpfoo
  5. spec:
  6. entryPoints: # [1]
  7. - footcp
  8. routes: # [2]
  9. - match: HostSNI(`*`) # [3]
  10. priority: 10 # [4]
  11. middlewares:
  12. - name: middleware1 # [5]
  13. namespace: default # [6]
  14. services: # [7]
  15. - name: foo # [8]
  16. port: 8080 # [9]
  17. weight: 10 # [10]
  18. terminationDelay: 400 # [11]
  19. proxyProtocol: # [12]
  20. version: 1 # [13]
  21. tls: # [14]
  22. secretName: supersecret # [15]
  23. options: # [16]
  24. name: opt # [17]
  25. namespace: default # [18]
  26. certResolver: foo # [19]
  27. domains: # [20]
  28. - main: example.net # [21]
  29. sans: # [22]
  30. - a.example.net
  31. - b.example.net
  32. passthrough: false # [23]
RefAttributePurpose
[1]entryPointsList of entrypoints names
[2]routesList of routes
[3]routes[n].matchDefines the rule of the underlying router
[4]routes[n].priorityDefines the priority to disambiguate rules of the same length, for route matching
[5]middlewares[n].nameDefines the MiddlewareTCP name
[6]middlewares[n].namespaceDefines the MiddlewareTCP namespace
[7]routes[n].servicesList of Kubernetes service definitions (See below for ExternalName Service setup)
[8]services[n].nameDefines the name of a Kubernetes service
[9]services[n].portDefines the port of a Kubernetes service. This can be a reference to a named port.
[10]services[n].weightDefines the weight to apply to the server load balancing
[11]services[n].terminationDelaycorresponds to the deadline that the proxy sets, after one of its connected peers indicates it has closed the writing capability of its connection, to close the reading capability as well, hence fully terminating the connection. It is a duration in milliseconds, defaulting to 100. A negative value means an infinite deadline (i.e. the reading capability is never closed).
[12]proxyProtocolDefines the PROXY protocol configuration
[13]versionDefines the PROXY protocol version
[14]tlsDefines TLS certificate configuration
[15]tls.secretNameDefines the secret name used to store the certificate (in the IngressRoute namespace)
[16]tls.optionsDefines the reference to a TLSOption
[17]options.nameDefines the TLSOption name
[18]options.namespaceDefines the TLSOption namespace
[19]tls.certResolverDefines the reference to a CertResolver
[20]tls.domainsList of domains
[21]domains[n].mainDefines the main domain name
[22]domains[n].sansList of SANs (alternative domains)
[23]tls.passthroughIf true, delegates the TLS termination to the backend

Declaring an IngressRouteTCP

IngressRouteTCP

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRouteTCP
  3. metadata:
  4. name: ingressroutetcpfoo
  5. spec:
  6. entryPoints:
  7. - footcp
  8. routes:
  9. # Match is the rule corresponding to an underlying router.
  10. - match: HostSNI(`*`)
  11. priority: 10
  12. services:
  13. - name: foo
  14. port: 8080
  15. terminationDelay: 400
  16. weight: 10
  17. - name: bar
  18. port: 8081
  19. terminationDelay: 500
  20. weight: 10
  21. tls:
  22. certResolver: foo
  23. domains:
  24. - main: example.net
  25. sans:
  26. - a.example.net
  27. - b.example.net
  28. options:
  29. name: opt
  30. namespace: default
  31. secretName: supersecret
  32. passthrough: false

TLSOption

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: TLSOption
  3. metadata:
  4. name: opt
  5. namespace: default
  6. spec:
  7. minVersion: VersionTLS12

Secret

  1. apiVersion: v1
  2. kind: Secret
  3. metadata:
  4. name: supersecret
  5. data:
  6. tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=
  7. tls.key: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0=

Using Kubernetes ExternalName Service

Traefik backends creation needs a port to be set, however Kubernetes ExternalName Service could be defined without any port. Accordingly, Traefik supports defining a port in two ways:

  • only on IngressRouteTCP service
  • on both sides, you’ll be warned if the ports don’t match, and the IngressRouteTCP service port is used

Thus, in case of two sides port definition, Traefik expects a match between ports.

Examples

Only on IngressRouteTCP

  1. ---
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: IngressRouteTCP
  4. metadata:
  5. name: test.route
  6. namespace: default
  7. spec:
  8. entryPoints:
  9. - foo
  10. routes:
  11. - match: HostSNI(`*`)
  12. services:
  13. - name: external-svc
  14. port: 80
  15. ---
  16. apiVersion: v1
  17. kind: Service
  18. metadata:
  19. name: external-svc
  20. namespace: default
  21. spec:
  22. externalName: external.domain
  23. type: ExternalName

On both sides

  1. ---
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: IngressRouteTCP
  4. metadata:
  5. name: test.route
  6. namespace: default
  7. spec:
  8. entryPoints:
  9. - foo
  10. routes:
  11. - match: HostSNI(`*`)
  12. services:
  13. - name: external-svc
  14. port: 80
  15. ---
  16. apiVersion: v1
  17. kind: Service
  18. metadata:
  19. name: external-svc
  20. namespace: default
  21. spec:
  22. externalName: external.domain
  23. type: ExternalName
  24. ports:
  25. - port: 80

Kind: MiddlewareTCP

MiddlewareTCP is the CRD implementation of a Traefik TCP middleware.

Register the MiddlewareTCP kind in the Kubernetes cluster before creating MiddlewareTCP objects or referencing TCP middlewares in the IngressRouteTCP objects.

Declaring and Referencing a MiddlewareTCP

Middleware

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: MiddlewareTCP
  3. metadata:
  4. name: ipwhitelist
  5. spec:
  6. ipWhiteList:
  7. sourceRange:
  8. - 127.0.0.1/32
  9. - 192.168.1.7

IngressRoute

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: ingressroutebar
  5. spec:
  6. entryPoints:
  7. - web
  8. routes:
  9. - match: Host(`example.com`) && PathPrefix(`/whitelist`)
  10. kind: Rule
  11. services:
  12. - name: whoami
  13. port: 80
  14. middlewares:
  15. - name: ipwhitelist
  16. namespace: foo

Cross-provider namespace

As Kubernetes also has its own notion of namespace, one should not confuse the kubernetes namespace of a resource (in the reference to the middleware) with the provider namespace, when the definition of the TCP middleware comes from another provider. In this context, specifying a namespace when referring to the resource does not make any sense, and will be ignored. Additionally, when you want to reference a MiddlewareTCP from the CRD Provider, you have to append the namespace of the resource in the resource-name as Traefik appends the namespace internally automatically.

More information about available TCP middlewares in the dedicated middlewares section.

Kind IngressRouteUDP

IngressRouteUDP is the CRD implementation of a Traefik UDP router.

Register the IngressRouteUDP kind in the Kubernetes cluster before creating IngressRouteUDP objects.

IngressRouteUDP Attributes

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRouteUDP
  3. metadata:
  4. name: ingressrouteudpfoo
  5. spec:
  6. entryPoints: # [1]
  7. - fooudp
  8. routes: # [2]
  9. - services: # [3]
  10. - name: foo # [4]
  11. port: 8080 # [5]
  12. weight: 10 # [6]
RefAttributePurpose
[1]entryPointsList of entrypoints names
[2]routesList of routes
[3]routes[n].servicesList of Kubernetes service definitions (See below for ExternalName Service setup)
[4]services[n].nameDefines the name of a Kubernetes service
[6]services[n].portDefines the port of a Kubernetes service. This can be a reference to a named port.
[7]services[n].weightDefines the weight to apply to the server load balancing

Declaring an IngressRouteUDP

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRouteUDP
  3. metadata:
  4. name: ingressrouteudpfoo
  5. spec:
  6. entryPoints:
  7. - fooudp
  8. routes:
  9. - services:
  10. - name: foo
  11. port: 8080
  12. weight: 10
  13. - name: bar
  14. port: 8081
  15. weight: 10

Using Kubernetes ExternalName Service

Traefik backends creation needs a port to be set, however Kubernetes ExternalName Service could be defined without any port. Accordingly, Traefik supports defining a port in two ways:

  • only on IngressRouteUDP service
  • on both sides, you’ll be warned if the ports don’t match, and the IngressRouteUDP service port is used

Thus, in case of two sides port definition, Traefik expects a match between ports.

Examples

IngressRouteUDP

  1. ---
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: IngressRouteUDP
  4. metadata:
  5. name: test.route
  6. namespace: default
  7. spec:
  8. entryPoints:
  9. - foo
  10. routes:
  11. - services:
  12. - name: external-svc
  13. port: 80
  14. ---
  15. apiVersion: v1
  16. kind: Service
  17. metadata:
  18. name: external-svc
  19. namespace: default
  20. spec:
  21. externalName: external.domain
  22. type: ExternalName

ExternalName Service

  1. ---
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: IngressRouteUDP
  4. metadata:
  5. name: test.route
  6. namespace: default
  7. spec:
  8. entryPoints:
  9. - foo
  10. routes:
  11. - services:
  12. - name: external-svc
  13. ---
  14. apiVersion: v1
  15. kind: Service
  16. metadata:
  17. name: external-svc
  18. namespace: default
  19. spec:
  20. externalName: external.domain
  21. type: ExternalName
  22. ports:
  23. - port: 80

Both sides

  1. ---
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: IngressRouteUDP
  4. metadata:
  5. name: test.route
  6. namespace: default
  7. spec:
  8. entryPoints:
  9. - foo
  10. routes:
  11. - services:
  12. - name: external-svc
  13. port: 80
  14. ---
  15. apiVersion: v1
  16. kind: Service
  17. metadata:
  18. name: external-svc
  19. namespace: default
  20. spec:
  21. externalName: external.domain
  22. type: ExternalName
  23. ports:
  24. - port: 80

Kind: TLSOption

TLSOption is the CRD implementation of a Traefik “TLS Option”.

Register the TLSOption kind in the Kubernetes cluster before creating TLSOption objects or referencing TLS options in the IngressRoute / IngressRouteTCP objects.

TLSOption Attributes

TLSOption

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: TLSOption
  3. metadata:
  4. name: mytlsoption # [1]
  5. namespace: default
  6. spec:
  7. minVersion: VersionTLS12 # [2]
  8. maxVersion: VersionTLS13 # [3]
  9. curvePreferences: # [4]
  10. - CurveP521
  11. - CurveP384
  12. cipherSuites: # [5]
  13. - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
  14. - TLS_RSA_WITH_AES_256_GCM_SHA384
  15. clientAuth: # [6]
  16. secretNames: # [7]
  17. - secret-ca1
  18. - secret-ca2
  19. clientAuthType: VerifyClientCertIfGiven # [8]
  20. sniStrict: true # [9]
  21. alpnProtocols: # [10]
  22. - foobar
RefAttributePurpose
[1]nameDefines the name of the TLSOption resource. One can use default as name to redefine the default TLSOption.
[2]minVersionDefines the minimum TLS version that is acceptable.
[3]maxVersionDefines the maximum TLS version that is acceptable.
[4]cipherSuiteslist of supported cipher suites for TLS versions up to TLS 1.2.
[5]curvePreferencesList of the elliptic curves references that will be used in an ECDHE handshake, in preference order.
[6]clientAuthdetermines the server’s policy for TLS Client Authentication.
[7]clientAuth.secretNameslist of names of the referenced Kubernetes Secrets (in TLSOption namespace). The secret must contain a certificate under either a tls.ca or a ca.crt key.
[8]clientAuth.clientAuthTypedefines the client authentication type to apply. The available values are: NoClientCert, RequestClientCert, VerifyClientCertIfGiven and RequireAndVerifyClientCert.
[9]sniStrictif true, Traefik won’t allow connections from clients connections that do not specify a server_name extension.
[10]alpnProtocolsList of supported application level protocols for the TLS handshake, in order of preference.

CA Secret

The CA secret must contain a base64 encoded certificate under either a tls.ca or a ca.crt key.

Declaring and referencing a TLSOption

TLSOption

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: TLSOption
  3. metadata:
  4. name: mytlsoption
  5. namespace: default
  6. spec:
  7. minVersion: VersionTLS12
  8. sniStrict: true
  9. cipherSuites:
  10. - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
  11. - TLS_RSA_WITH_AES_256_GCM_SHA384
  12. clientAuth:
  13. secretNames:
  14. - secret-ca1
  15. - secret-ca2
  16. clientAuthType: VerifyClientCertIfGiven

IngressRoute

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: ingressroutebar
  5. spec:
  6. entryPoints:
  7. - web
  8. routes:
  9. - match: Host(`example.com`) && PathPrefix(`/stripit`)
  10. kind: Rule
  11. services:
  12. - name: whoami
  13. port: 80
  14. tls:
  15. options:
  16. name: mytlsoption
  17. namespace: default

Secrets

  1. apiVersion: v1
  2. kind: Secret
  3. metadata:
  4. name: secret-ca1
  5. namespace: default
  6. data:
  7. # Must contain a certificate under either a `tls.ca` or a `ca.crt` key.
  8. tls.ca: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=
  9. ---
  10. apiVersion: v1
  11. kind: Secret
  12. metadata:
  13. name: secret-ca2
  14. namespace: default
  15. data:
  16. # Must contain a certificate under either a `tls.ca` or a `ca.crt` key.
  17. tls.ca: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=

References and namespaces

If the optional namespace attribute is not set, the configuration will be applied with the namespace of the IngressRoute.

Additionally, when the definition of the TLS option is from another provider, the cross-provider syntax (middlewarename@provider) should be used to refer to the TLS option. Specifying a namespace attribute in this case would not make any sense, and will be ignored.

Kind: TLSStore

TLSStore is the CRD implementation of a Traefik “TLS Store”.

Register the TLSStore kind in the Kubernetes cluster before creating TLSStore objects or referencing TLS stores in the IngressRoute / IngressRouteTCP objects.

Default TLS Store

Traefik currently only uses the TLS Store named “default”. This means that if you have two stores that are named default in different kubernetes namespaces, they may be randomly chosen. For the time being, please only configure one TLSSTore named default.

TLSStore Attributes

TLSStore

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: TLSStore
  3. metadata:
  4. name: default
  5. namespace: default
  6. spec:
  7. defaultCertificate:
  8. secretName: my-secret # [1]
RefAttributePurpose
[1]secretNameThe name of the referenced Kubernetes Secret that holds the default certificate for the store.

Declaring and referencing a TLSStore

TLSStore

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: TLSStore
  3. metadata:
  4. name: default
  5. namespace: default
  6. spec:
  7. defaultCertificate:
  8. secretName: supersecret

IngressRoute

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: ingressroutebar
  5. spec:
  6. entryPoints:
  7. - web
  8. routes:
  9. - match: Host(`example.com`) && PathPrefix(`/stripit`)
  10. kind: Rule
  11. services:
  12. - name: whoami
  13. port: 80
  14. tls:
  15. store:
  16. name: default

Secret

  1. apiVersion: v1
  2. kind: Secret
  3. metadata:
  4. name: supersecret
  5. data:
  6. tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=
  7. tls.key: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0=

Kind: ServersTransport

ServersTransport is the CRD implementation of a ServersTransport.

Default serversTransport

If no serversTransport is specified, the default@internal will be used. The default@internal serversTransport is created from the static configuration.

ServersTransport Attributes

ServersTransport

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: ServersTransport
  3. metadata:
  4. name: mytransport
  5. namespace: default
  6. spec:
  7. serverName: foobar # [1]
  8. insecureSkipVerify: true # [2]
  9. rootCAsSecrets: # [3]
  10. - foobar
  11. - foobar
  12. certificatesSecrets: # [4]
  13. - foobar
  14. - foobar
  15. maxIdleConnsPerHost: 1 # [5]
  16. forwardingTimeouts: # [6]
  17. dialTimeout: 42s # [7]
  18. responseHeaderTimeout: 42s # [8]
  19. idleConnTimeout: 42s # [9]
  20. peerCertURI: foobar # [10]
  21. disableHTTP2: true # [11]
RefAttributePurpose
[1]serverNameServerName used to contact the server.
[2]insecureSkipVerifyControls whether the server’s certificate chain and host name is verified.
[3]rootCAsSecretsDefines the set of root certificate authorities to use when verifying server certificates. The secret must contain a certificate under either a tls.ca or a ca.crt key.
[4]certificatesSecretsCertificates to present to the server for mTLS.
[5]maxIdleConnsPerHostControls the maximum idle (keep-alive) connections to keep per-host. If zero, defaultMaxIdleConnsPerHost is used.
[6]forwardingTimeoutsTimeouts for requests forwarded to the servers.
[7]dialTimeoutThe amount of time to wait until a connection to a server can be established. If zero, no timeout exists.
[8]responseHeaderTimeoutThe amount of time to wait for a server’s response headers after fully writing the request (including its body, if any). If zero, no timeout exists.
[9]idleConnTimeoutThe maximum amount of time an idle (keep-alive) connection will remain idle before closing itself. If zero, no timeout exists.
[10]peerCertURIURI used to match against SAN URIs during the server’s certificate verification.
[11]disableHTTP2Disables HTTP/2 for connections with servers.

CA Secret

The CA secret must contain a base64 encoded certificate under either a tls.ca or a ca.crt key.

Declaring and referencing a ServersTransport

ServersTransport

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: ServersTransport
  3. metadata:
  4. name: mytransport
  5. namespace: default
  6. spec:
  7. serverName: example.org
  8. insecureSkipVerify: true

IngressRoute

  1. apiVersion: traefik.containo.us/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: testroute
  5. namespace: default
  6. spec:
  7. entryPoints:
  8. - web
  9. routes:
  10. - match: Host(`example.com`)
  11. kind: Rule
  12. services:
  13. - name: whoami
  14. port: 80
  15. serversTransport: mytransport

ServersTransport reference

By default, the referenced ServersTransport CRD must be defined in the same Kubernetes service namespace.

To reference a ServersTransport CRD from another namespace, the value must be of form namespace-name@kubernetescrd, and the cross-namespace option must be enabled.

If the ServersTransport CRD is defined in another provider the cross-provider format name@provider should be used.

Further

Also see the full example with Let’s Encrypt.