Traefik & CRD & Let’s Encrypt

    This document is intended to be a fully working example demonstrating how to set up Traefik in Kubernetes, with the dynamic configuration coming from the , and TLS setup with Let’s Encrypt. However, for the sake of simplicity, we’re using docker image for the Kubernetes cluster setup.

    Please note that for this setup, given that we’re going to use ACME’s TLS-ALPN-01 challenge, the host you’ll be running it on must be able to receive connections from the outside on port 443. And of course its internet facing IP address must match the domain name you intend to use.

    In the following, the Kubernetes resources defined in YAML configuration files can be applied to the setup in two different ways:

    • the first, and usual way, is simply with the command.
    • the second, which can be used for this tutorial, is to directly place the files in the directory used by the k3s docker image for such inputs (/var/lib/rancher/k3s/server/manifests).

    Kubectl Version

    Our starting point is the docker-compose configuration file, to start the k3s cluster. You can start it with:

    1. server:
    2. image: rancher/k3s:v1.17.2-k3s1
    3. command: server --disable-agent --no-deploy traefik
    4. environment:
    5. - K3S_CLUSTER_SECRET=somethingtotallyrandom
    6. - K3S_KUBECONFIG_OUTPUT=/output/kubeconfig.yaml
    7. - K3S_KUBECONFIG_MODE=666
    8. volumes:
    9. # k3s will generate a kubeconfig.yaml in this directory. This volume is mounted
    10. # on your host, so you can then 'export KUBECONFIG=/somewhere/on/your/host/out/kubeconfig.yaml',
    11. # in order for your kubectl commands to work.
    12. - /somewhere/on/your/host/out:/output
    13. # This directory is where you put all the (yaml) configuration files of
    14. # the Kubernetes resources.
    15. - /somewhere/on/your/host/in:/var/lib/rancher/k3s/server/manifests
    16. ports:
    17. - 6443:6443
    18. node:
    19. image: rancher/k3s:v1.17.2-k3s1
    20. privileged: true
    21. links:
    22. - server
    23. environment:
    24. - K3S_URL=https://server:6443
    25. - K3S_CLUSTER_SECRET=somethingtotallyrandom
    26. volumes:
    27. # this is where you would place a alternative traefik image (saved as a .tar file with
    28. # 'docker save'), if you want to use it, instead of the traefik:v2.5 image.
    29. - /sowewhere/on/your/host/custom-image:/var/lib/rancher/k3s/agent/images

    Cluster Resources

    Let’s now have a look (in the order they should be applied, if using kubectl apply) at all the required resources for the full setup.

    First, the definition of the IngressRoute and the Middleware kinds. Also note the RBAC authorization resources; they’ll be referenced through the serviceAccountName of the deployment, later on.

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

    Then, the services. One for Traefik itself, and one for the app it routes for, i.e. in this case our demo HTTP server: .

    1. apiVersion: v1
    2. kind: ServiceAccount
    3. metadata:
    4. namespace: default
    5. name: traefik-ingress-controller
    6. ---
    7. kind: Deployment
    8. apiVersion: apps/v1
    9. metadata:
    10. namespace: default
    11. name: traefik
    12. labels:
    13. app: traefik
    14. spec:
    15. replicas: 1
    16. selector:
    17. matchLabels:
    18. app: traefik
    19. template:
    20. metadata:
    21. labels:
    22. app: traefik
    23. spec:
    24. serviceAccountName: traefik-ingress-controller
    25. containers:
    26. - name: traefik
    27. image: traefik:v2.5
    28. args:
    29. - --api.insecure
    30. - --accesslog
    31. - --entrypoints.web.Address=:8000
    32. - --entrypoints.websecure.Address=:4443
    33. - --providers.kubernetescrd
    34. - --certificatesresolvers.myresolver.acme.tlschallenge
    35. - --certificatesresolvers.myresolver.acme.email=foo@you.com
    36. - --certificatesresolvers.myresolver.acme.storage=acme.json
    37. # Please note that this is the staging Let's Encrypt server.
    38. # Once you get things working, you should remove that whole line altogether.
    39. - --certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
    40. ports:
    41. - name: web
    42. containerPort: 8000
    43. - name: websecure
    44. containerPort: 4443
    45. - name: admin
    46. containerPort: 8080
    47. ---
    48. kind: Deployment
    49. apiVersion: apps/v1
    50. metadata:
    51. namespace: default
    52. name: whoami
    53. labels:
    54. app: whoami
    55. spec:
    56. replicas: 2
    57. selector:
    58. matchLabels:
    59. app: whoami
    60. template:
    61. metadata:
    62. labels:
    63. app: whoami
    64. spec:
    65. containers:
    66. - name: whoami
    67. image: traefik/whoami
    68. ports:
    69. - name: web
    70. containerPort: 80

    Now, as an exception to what we said above, please note that you should not let the ingressRoute resources below be applied automatically to your cluster. The reason is, as soon as the ACME provider of Traefik detects we have TLS routers, it will try to generate the certificates for the corresponding domains. And this will not work, because as it is, our Traefik pod is not reachable from the outside, which will make the ACME TLS challenge fail. Therefore, for the whole thing to work, we must delay applying the ingressRoute resources until we have port-forwarding set up properly, which is the next step.

    1. kubectl port-forward --address 0.0.0.0 service/traefik 8000:8000 8080:8080 443:4443 -n default

    Also, and this is out of the scope if this guide, please note that because of the privileged ports limitation on Linux, the above command might fail to listen on port 443. In which case you can use tricks such as elevating caps of kubectl with setcaps, or using authbind, or setting up a NAT between your host and the WAN. Look it up.

    We can now finally apply the actual ingressRoutes, with:

    1. apiVersion: traefik.containo.us/v1alpha1
    2. kind: IngressRoute
    3. metadata:
    4. name: simpleingressroute
    5. namespace: default
    6. spec:
    7. entryPoints:
    8. - web
    9. routes:
    10. - match: Host(`your.example.com`) && PathPrefix(`/notls`)
    11. kind: Rule
    12. services:
    13. - name: whoami
    14. port: 80
    15. ---
    16. apiVersion: traefik.containo.us/v1alpha1
    17. kind: IngressRoute
    18. metadata:
    19. name: ingressroutetls
    20. namespace: default
    21. spec:
    22. entryPoints:
    23. - websecure
    24. routes:
    25. - match: Host(`your.example.com`) && PathPrefix(`/tls`)
    26. kind: Rule
    27. services:
    28. - name: whoami
    29. port: 80
    30. tls:
    31. certResolver: myresolver

    Give it a few seconds for the ACME TLS challenge to complete, and you should then be able to access your whoami pod (routed through Traefik), from the outside. Both with or (just for fun, do not do that in production) without TLS: