Kubernetes Configuration Reference

Dynamic configuration with Kubernetes Custom Resource

Definitions

  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: ingressroutetcps.traefik.containo.us
  31. spec:
  32. group: traefik.containo.us
  33. version: v1alpha1
  34. names:
  35. kind: IngressRouteTCP
  36. plural: ingressroutetcps
  37. singular: ingressroutetcp
  38. scope: Namespaced
  39. ---
  40. apiVersion: apiextensions.k8s.io/v1beta1
  41. kind: CustomResourceDefinition
  42. metadata:
  43. name: ingressrouteudps.traefik.containo.us
  44. spec:
  45. group: traefik.containo.us
  46. version: v1alpha1
  47. names:
  48. kind: IngressRouteUDP
  49. plural: ingressrouteudps
  50. singular: ingressrouteudp
  51. scope: Namespaced
  52. ---
  53. apiVersion: apiextensions.k8s.io/v1beta1
  54. kind: CustomResourceDefinition
  55. metadata:
  56. name: tlsoptions.traefik.containo.us
  57. spec:
  58. group: traefik.containo.us
  59. version: v1alpha1
  60. names:
  61. kind: TLSOption
  62. plural: tlsoptions
  63. singular: tlsoption
  64. scope: Namespaced
  65. ---
  66. apiVersion: apiextensions.k8s.io/v1beta1
  67. kind: CustomResourceDefinition
  68. metadata:
  69. name: tlsstores.traefik.containo.us
  70. spec:
  71. group: traefik.containo.us
  72. version: v1alpha1
  73. names:
  74. kind: TLSStore
  75. plural: tlsstores
  76. singular: tlsstore
  77. scope: Namespaced
  78. ---
  79. apiVersion: apiextensions.k8s.io/v1beta1
  80. kind: CustomResourceDefinition
  81. metadata:
  82. name: traefikservices.traefik.containo.us
  83. spec:
  84. group: traefik.containo.us
  85. version: v1alpha1
  86. names:
  87. kind: TraefikService
  88. plural: traefikservices
  89. singular: traefikservice
  90. scope: Namespaced
  91. ---
  92. apiVersion: apiextensions.k8s.io/v1beta1
  93. kind: CustomResourceDefinition
  94. metadata:
  95. name: serverstransports.traefik.containo.us
  96. spec:
  97. group: traefik.containo.us
  98. version: v1alpha1
  99. names:
  100. kind: ServersTransport
  101. plural: serverstransports
  102. singular: serverstransport
  103. scope: Namespaced

Resources

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

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. - ingressroutes
  37. - traefikservices
  38. - ingressroutetcps
  39. - ingressrouteudps
  40. - tlsoptions
  41. - tlsstores
  42. - serverstransports
  43. verbs:
  44. - get
  45. - list
  46. - watch
  47. ---
  48. kind: ClusterRoleBinding
  49. apiVersion: rbac.authorization.k8s.io/v1beta1
  50. metadata:
  51. name: traefik-ingress-controller
  52. roleRef:
  53. apiGroup: rbac.authorization.k8s.io
  54. kind: ClusterRole
  55. name: traefik-ingress-controller
  56. subjects:
  57. - kind: ServiceAccount
  58. name: traefik-ingress-controller
  59. namespace: default