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. 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

  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.6
  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].priorityDisambiguate 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. middlewares:
  11. - name: middleware1 # [4]
  12. namespace: default # [5]
  13. services: # [6]
  14. - name: foo # [7]
  15. port: 8080 # [8]
  16. weight: 10 # [9]
  17. terminationDelay: 400 # [10]
  18. proxyProtocol: # [11]
  19. version: 1 # [12]
  20. tls: # [13]
  21. secretName: supersecret # [14]
  22. options: # [15]
  23. name: opt # [16]
  24. namespace: default # [17]
  25. certResolver: foo # [18]
  26. domains: # [19]
  27. - main: example.net # [20]
  28. sans: # [21]
  29. - a.example.net
  30. - b.example.net
  31. passthrough: false # [22]
RefAttributePurpose
[1]entryPointsList of entrypoints names
[2]routesList of routes
[3]routes[n].matchDefines the rule corresponding to an underlying router
[4]middlewares[n].nameDefines the MiddlewareTCP name
[5]middlewares[n].namespaceDefines the MiddlewareTCP namespace
[6]routes[n].servicesList of Kubernetes service definitions (See below for ExternalName Service setup)
[7]services[n].nameDefines the name of a Kubernetes service
[8]services[n].portDefines the port of a Kubernetes service. This can be a reference to a named port.
[9]services[n].weightDefines the weight to apply to the server load balancing
[10]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).
[11]proxyProtocolDefines the PROXY protocol configuration
[12]versionDefines the PROXY protocol version
[13]tlsDefines TLS certificate configuration
[14]tls.secretNameDefines the secret name used to store the certificate (in the IngressRoute namespace)
[15]tls.optionsDefines the reference to a TLSOption
[16]options.nameDefines the TLSOption name
[17]options.namespaceDefines the TLSOption namespace
[18]tls.certResolverDefines the reference to a CertResolver
[19]tls.domainsList of domains
[20]domains[n].mainDefines the main domain name
[21]domains[n].sansList of SANs (alternative domains)
[22]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. services:
  12. - name: foo
  13. port: 8080
  14. terminationDelay: 400
  15. weight: 10
  16. - name: bar
  17. port: 8081
  18. terminationDelay: 500
  19. weight: 10
  20. tls:
  21. certResolver: foo
  22. domains:
  23. - main: example.net
  24. sans:
  25. - a.example.net
  26. - b.example.net
  27. options:
  28. name: opt
  29. namespace: default
  30. secretName: supersecret
  31. 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
  5. namespace: default
  6. spec:
  7. minVersion: VersionTLS12 # [1]
  8. maxVersion: VersionTLS13 # [1]
  9. curvePreferences: # [3]
  10. - CurveP521
  11. - CurveP384
  12. cipherSuites: # [4]
  13. - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
  14. - TLS_RSA_WITH_AES_256_GCM_SHA384
  15. clientAuth: # [5]
  16. secretNames: # [6]
  17. - secret-ca1
  18. - secret-ca2
  19. clientAuthType: VerifyClientCertIfGiven # [7]
  20. sniStrict: true # [8]
  21. alpnProtocols: # [9]
  22. - foobar
RefAttributePurpose
[1]minVersionDefines the minimum TLS version that is acceptable
[2]maxVersionDefines the maximum TLS version that is acceptable
[3]cipherSuiteslist of supported cipher suites for TLS versions up to TLS 1.2
[4]curvePreferencesList of the elliptic curves references that will be used in an ECDHE handshake, in preference order
[5]clientAuthdetermines the server’s policy for TLS Client Authentication
[6]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.
[7]clientAuth.clientAuthTypedefines the client authentication type to apply. The available values are: NoClientCert, RequestClientCert, VerifyClientCertIfGiven and RequireAndVerifyClientCert
[8]sniStrictif true, Traefik won’t allow connections from clients connections that do not specify a server_name extension
[9]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.