Kubernetes Configuration Reference

Dynamic configuration with Kubernetes Custom Resource

  1. apiVersion: apiextensions.k8s.io/v1beta1
  2. kind: CustomResourceDefinition
  3. metadata:
  4. name: ingressroutes.traefik.containo.us
  5. spec:
  6. group: traefik.containo.us
  7. version: v1alpha1
  8. names:
  9. kind: IngressRoute
  10. plural: ingressroutes
  11. singular: ingressroute
  12. scope: Namespaced
  13. ---
  14. apiVersion: apiextensions.k8s.io/v1beta1
  15. kind: CustomResourceDefinition
  16. metadata:
  17. name: middlewares.traefik.containo.us
  18. spec:
  19. group: traefik.containo.us
  20. version: v1alpha1
  21. names:
  22. kind: Middleware
  23. plural: middlewares
  24. singular: middleware
  25. scope: Namespaced
  26. ---
  27. apiVersion: apiextensions.k8s.io/v1beta1
  28. kind: CustomResourceDefinition
  29. metadata:
  30. name: tlsoptions.traefik.containo.us
  31. spec:
  32. group: traefik.containo.us
  33. version: v1alpha1
  34. names:
  35. kind: TLSOption
  36. plural: tlsoptions
  37. singular: tlsoption
  38. scope: Namespaced
  39. ---
  40. apiVersion: apiextensions.k8s.io/v1beta1
  41. kind: CustomResourceDefinition
  42. metadata:
  43. name: ingressroutetcps.traefik.containo.us
  44. spec:
  45. group: traefik.containo.us
  46. version: v1alpha1
  47. names:
  48. kind: IngressRouteTCP
  49. plural: ingressroutetcps
  50. singular: ingressroutetcp
  51. scope: Namespaced
  52. ---
  53. apiVersion: apiextensions.k8s.io/v1beta1
  54. kind: CustomResourceDefinition
  55. metadata:
  56. name: traefikservices.traefik.containo.us
  57. spec:
  58. group: traefik.containo.us
  59. version: v1alpha1
  60. names:
  61. kind: TraefikService
  62. plural: traefikservices
  63. singular: traefikservice
  64. scope: Namespaced
  65. ---
  66. apiVersion: traefik.containo.us/v1alpha1
  67. kind: TraefikService
  68. metadata:
  69. name: wrr2
  70. namespace: default
  71. spec:
  72. weighted:
  73. services:
  74. - name: s1
  75. weight: 1
  76. port: 80
  77. # Optional, as it is the default value
  78. kind: Service
  79. - name: s3
  80. weight: 1
  81. port: 80
  82. ---
  83. apiVersion: traefik.containo.us/v1alpha1
  84. kind: TraefikService
  85. metadata:
  86. name: wrr1
  87. namespace: default
  88. spec:
  89. weighted:
  90. services:
  91. - name: wrr2
  92. kind: TraefikService
  93. weight: 1
  94. - name: s3
  95. weight: 1
  96. port: 80
  97. ---
  98. apiVersion: traefik.containo.us/v1alpha1
  99. kind: TraefikService
  100. metadata:
  101. name: mirror1
  102. namespace: default
  103. spec:
  104. mirroring:
  105. name: s1
  106. port: 80
  107. mirrors:
  108. - name: s3
  109. percent: 20
  110. port: 80
  111. - name: mirror2
  112. kind: TraefikService
  113. percent: 20
  114. ---
  115. apiVersion: traefik.containo.us/v1alpha1
  116. kind: TraefikService
  117. metadata:
  118. name: mirror2
  119. namespace: default
  120. spec:
  121. mirroring:
  122. name: wrr2
  123. kind: TraefikService
  124. mirrors:
  125. - name: s2
  126. # Optional, as it is the default value
  127. kind: Service
  128. percent: 20
  129. port: 80
  130. ---
  131. apiVersion: traefik.containo.us/v1alpha1
  132. kind: IngressRoute
  133. metadata:
  134. name: ingressroute
  135. spec:
  136. entryPoints:
  137. - web
  138. - web-secure
  139. routes:
  140. - match: Host(`foo.com`) && PathPrefix(`/bar`)
  141. kind: Rule
  142. priority: 12
  143. # defining several services is possible and allowed, but for now the servers of
  144. # all the services (for a given route) get merged altogether under the same
  145. # load-balancing strategy.
  146. services:
  147. - name: s1
  148. port: 80
  149. healthCheck:
  150. path: /health
  151. host: baz.com
  152. intervalSeconds: 7
  153. timeoutSeconds: 60
  154. # strategy defines the load balancing strategy between the servers. It defaults
  155. # to Round Robin, and for now only Round Robin is supported anyway.
  156. strategy: RoundRobin
  157. - name: s2
  158. port: 433
  159. healthCheck:
  160. path: /health
  161. host: baz.com
  162. intervalSeconds: 7
  163. timeoutSeconds: 60
  164. - match: PathPrefix(`/misc`)
  165. services:
  166. - name: s3
  167. port: 80
  168. middlewares:
  169. - name: stripprefix
  170. - name: addprefix
  171. - match: PathPrefix(`/misc`)
  172. services:
  173. - name: s3
  174. # Optional, as it is the default value
  175. kind: Service
  176. port: 8443
  177. # scheme allow to override the scheme for the service. (ex: https or h2c)
  178. scheme: https
  179. - match: PathPrefix(`/lb`)
  180. services:
  181. - name: wrr1
  182. kind: TraefikService
  183. - match: PathPrefix(`/mirrored`)
  184. services:
  185. - name: mirror1
  186. kind: TraefikService
  187. # use an empty tls object for TLS with Let's Encrypt
  188. tls:
  189. secretName: supersecret
  190. options:
  191. name: myTLSOption
  192. namespace: default
  193. ---
  194. apiVersion: traefik.containo.us/v1alpha1
  195. kind: IngressRouteTCP
  196. metadata:
  197. name: ingressroutetcp.crd
  198. namespace: default
  199. spec:
  200. entryPoints:
  201. - footcp
  202. routes:
  203. - match: HostSNI(`bar.com`)
  204. services:
  205. - name: whoamitcp
  206. port: 8080
  207. tls:
  208. secretName: foosecret
  209. passthrough: false
  210. options:
  211. name: myTLSOption
  212. namespace: default