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

RBAC

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

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.5
  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. kind: Rule
  27. services:
  28. - name: whoamitcp
  29. port: 8080
  30. ---
  31. apiVersion: traefik.containo.us/v1alpha1
  32. kind: IngressRouteUDP
  33. metadata:
  34. name: ingressroute.udp
  35. namespace: default
  36. spec:
  37. entryPoints:
  38. - udpep
  39. routes:
  40. - kind: Rule
  41. services:
  42. - name: whoamiudp
  43. 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
  26. sticky:
  27. cookie:
  28. httpOnly: true
  29. name: cookie
  30. secure: true
  31. sameSite: none
  32. strategy: RoundRobin
  33. weight: 10
  34. tls: # [10]
  35. secretName: supersecret # [11]
  36. options: # [12]
  37. name: opt # [13]
  38. namespace: default # [14]
  39. certResolver: foo # [15]
  40. domains: # [16]
  41. - main: example.net # [17]
  42. sans: # [18]
  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]tlsDefines TLS certificate configuration
[11]tls.secretNameDefines the secret name used to store the certificate (in the IngressRoute namespace)
[12]tls.optionsDefines the reference to a TLSOption
[13]options.nameDefines the TLSOption name
[14]options.namespaceDefines the TLSOption namespace
[15]tls.certResolverDefines the reference to a CertResolver
[16]tls.domainsList of domains
[17]domains[n].mainDefines the main domain name
[18]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. 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

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

apiVersion: traefik.containo.us/v1alpha1
kind: TLSOption
metadata:
  name: mytlsoption
  namespace: default

spec:
  minVersion: VersionTLS12                      # [1]
  maxVersion: VersionTLS13                      # [1]
  curvePreferences:                             # [3]
    - CurveP521
    - CurveP384
  cipherSuites:                                 # [4]
    - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    - TLS_RSA_WITH_AES_256_GCM_SHA384
  clientAuth:                                   # [5]
    secretNames:                                # [6]
      - secret-ca1
      - secret-ca2
    clientAuthType: VerifyClientCertIfGiven     # [7]
  sniStrict: true                               # [8]
  alpnProtocols:                                # [9]
    - 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

apiVersion: traefik.containo.us/v1alpha1
kind: TLSOption
metadata:
  name: mytlsoption
  namespace: default

spec:
  minVersion: VersionTLS12
  sniStrict: true
  cipherSuites:
    - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    - TLS_RSA_WITH_AES_256_GCM_SHA384
  clientAuth:
    secretNames:
      - secret-ca1
      - secret-ca2
    clientAuthType: VerifyClientCertIfGiven

IngressRoute

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: ingressroutebar

spec:
  entryPoints:
    - web
  routes:
  - match: Host(`example.com`) && PathPrefix(`/stripit`)
    kind: Rule
    services:
    - name: whoami
      port: 80
  tls:
    options: 
      name: mytlsoption
      namespace: default

Secrets

apiVersion: v1
kind: Secret
metadata:
  name: secret-ca1
  namespace: default

data:
  # Must contain a certificate under either a `tls.ca` or a `ca.crt` key.
  tls.ca: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=

---
apiVersion: v1
kind: Secret
metadata:
  name: secret-ca2
  namespace: default

data:
  # Must contain a certificate under either a `tls.ca` or a `ca.crt` key. 
  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

apiVersion: traefik.containo.us/v1alpha1
kind: TLSStore
metadata:
  name: default
  namespace: default

spec:
  defaultCertificate:
    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

apiVersion: traefik.containo.us/v1alpha1
kind: TLSStore
metadata:
  name: default
  namespace: default

spec:
  defaultCertificate:
    secretName:  supersecret

IngressRoute

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: ingressroutebar

spec:
  entryPoints:
    - web
  routes:
  - match: Host(`example.com`) && PathPrefix(`/stripit`)
    kind: Rule
    services:
    - name: whoami
      port: 80
  tls:
    store: 
      name: default

Secret

apiVersion: v1
kind: Secret
metadata:
  name: supersecret

data:
  tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=
  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

TLSStore

apiVersion: traefik.containo.us/v1alpha1
kind: ServersTransport
metadata:
  name: mytransport
  namespace: default

spec:
  serverName: foobar               # [1]
  insecureSkipVerify: true         # [2]
  rootCAsSecrets:                  # [3]
    - foobar
    - foobar
  certificatesSecrets:             # [4]
    - foobar
    - foobar
  maxIdleConnsPerHost: 1           # [5]
  forwardingTimeouts:              # [6]
    dialTimeout: 42s               # [7]
    responseHeaderTimeout: 42s     # [8]
    idleConnTimeout: 42s           # [9]
  peerCertURI: foobar              # [10]
RefAttributePurpose
[1]serverNameServerName used to contact the server.
[2]insecureSkipVerifyDisable SSL certificate verification.
[3]rootCAsSecretsAdd cert file for self-signed certificate. The secret must contain a certificate under either a tls.ca or a ca.crt key.
[4]certificatesSecretsCertificates for mTLS.
[5]maxIdleConnsPerHostIf non-zero, controls the maximum idle (keep-alive) to keep per-host. If zero, defaultMaxIdleConnsPerHost is used.
[6]forwardingTimeoutsTimeouts for requests forwarded to the backend servers.
[7]dialTimeoutThe amount of time to wait until a connection to a backend 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 period for which an idle HTTP keep-alive connection will remain open before closing itself.
[10]peerCertURIURI used to match with service certificate.

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

apiVersion: traefik.containo.us/v1alpha1
kind: ServersTransport
metadata:
  name: mytransport
  namespace: default

spec:
  serverName: example.org
  insecureSkipVerify: true

IngressRoute

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: testroute
  namespace: default

spec:
  entryPoints:
    - web
  routes:
  - match: Host(`example.com`)
    kind: Rule
    services:
    - name: whoami
      port: 80
      serversTransport: mytransport

Further

Also see the full example with Let’s Encrypt.