020-deployment.yaml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. ###############################
  2. # ServiceAccount
  3. ###############################
  4. ---
  5. apiVersion: v1
  6. kind: ServiceAccount
  7. metadata:
  8. name: traefik
  9. namespace: kube-system
  10. ###############################
  11. # Deployment
  12. ###############################
  13. ---
  14. apiVersion: apps/v1
  15. kind: Deployment
  16. metadata:
  17. labels:
  18. app: traefik
  19. release: traefik
  20. name: traefik
  21. namespace: kube-system
  22. spec:
  23. replicas: 1
  24. selector:
  25. matchLabels:
  26. app: traefik
  27. release: traefik
  28. template:
  29. metadata:
  30. labels:
  31. app: traefik
  32. release: traefik
  33. spec:
  34. containers:
  35. - args:
  36. - --api
  37. #- --api.insecure=true
  38. # Set insecure to fals to enable basic auth
  39. - --api.insecure=false
  40. - --api.dashboard=true
  41. - --accesslog
  42. - --global.checknewversion=true
  43. - --entryPoints.traefik.address=:8100
  44. - --entryPoints.web.address=:80
  45. - --entryPoints.websecure.address=:443
  46. # permanent redirecting of all requests on http (80) to https (443)
  47. - --entrypoints.web.http.redirections.entryPoint.to=websecure
  48. - --entrypoints.websecure.http.tls.certResolver=default
  49. - --entrypoints.websecure.http.tls.domains[0].main=k8s.eugeniocarvalho.dev
  50. - --entrypoints.websecure.http.tls.domains[0].sans=*.k8s.eugeniocarvalho.dev
  51. #- --entrypoints.websecure.http.tls.certResolver=letsencrypt
  52. # Let's Encrypt Configurtion:
  53. # Please note that this is the staging Let's Encrypt server configuration.
  54. # Once you get things working, you should remove that following line.
  55. - --certificatesresolvers.default.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
  56. - --certificatesresolvers.default.acme.email=eugeniucarvalho@gmail.com
  57. - --certificatesresolvers.default.acme.storage=acme.json
  58. - --certificatesresolvers.default.acme.tlschallenge=true
  59. - --certificatesresolvers.default.acme.httpchallenge=true
  60. - --certificatesresolvers.default.acme.httpchallenge.entryPoint=http
  61. - --ping=true
  62. - --providers.kubernetescrd=true
  63. - --providers.kubernetesingress=true
  64. # Use log level= INFO or DEBUG
  65. - --log.level=INFO
  66. image: traefik:2.2.1
  67. imagePullPolicy: IfNotPresent
  68. livenessProbe:
  69. failureThreshold: 3
  70. httpGet:
  71. path: /ping
  72. port: 8100
  73. scheme: HTTP
  74. initialDelaySeconds: 10
  75. periodSeconds: 10
  76. successThreshold: 1
  77. timeoutSeconds: 2
  78. name: traefik
  79. ports:
  80. - containerPort: 8100
  81. name: admin
  82. protocol: TCP
  83. - containerPort: 80
  84. name: web
  85. protocol: TCP
  86. - containerPort: 443
  87. name: websecure
  88. protocol: TCP
  89. # optional storage
  90. # enable this option only in case you have defined a persistence volume claim
  91. #volumeMounts:
  92. #- name: traefik-data
  93. # mountPath: /var/lib/traefik
  94. readinessProbe:
  95. failureThreshold: 1
  96. httpGet:
  97. path: /ping
  98. port: 8100
  99. scheme: HTTP
  100. initialDelaySeconds: 10
  101. periodSeconds: 10
  102. successThreshold: 1
  103. timeoutSeconds: 2
  104. resources: {}
  105. terminationMessagePath: /dev/termination-log
  106. terminationMessagePolicy: File
  107. dnsPolicy: ClusterFirst
  108. restartPolicy: Always
  109. schedulerName: default-scheduler
  110. securityContext: {}
  111. serviceAccount: traefik
  112. serviceAccountName: traefik
  113. terminationGracePeriodSeconds: 60
  114. # optional storage
  115. # enable this option only in case you have defined a persistence volume claim
  116. #volumes:
  117. # - name: traefik-data
  118. # persistentVolumeClaim:
  119. # claimName: traefik-data
  120. ###############################
  121. # Service
  122. ###############################
  123. ---
  124. apiVersion: v1
  125. kind: Service
  126. metadata:
  127. labels:
  128. app: traefik
  129. release: traefik
  130. name: traefik
  131. namespace: kube-system
  132. spec:
  133. externalIPs:
  134. - "10.128.0.8"
  135. externalTrafficPolicy: Cluster
  136. ports:
  137. - name: web
  138. port: 80
  139. protocol: TCP
  140. targetPort: 80
  141. - name: websecure
  142. port: 443
  143. protocol: TCP
  144. targetPort: 443
  145. - name: admin
  146. port: 8100
  147. protocol: TCP
  148. targetPort: 8100
  149. selector:
  150. app: traefik
  151. release: traefik
  152. sessionAffinity: None
  153. type: LoadBalancer
  154. status:
  155. loadBalancer: {}
  156. #########################################################
  157. # The Middleware configuration contains middleware componenst
  158. # for a HTTP->HTTS redirection and a BasicAuth example.
  159. #########################################################
  160. ###############################
  161. # Middleware for basicAuth
  162. ###############################
  163. ---
  164. apiVersion: traefik.containo.us/v1alpha1
  165. kind: Middleware
  166. metadata:
  167. name: basic-auth
  168. spec:
  169. basicAuth:
  170. secret: authsecret
  171. ---
  172. apiVersion: v1
  173. kind: Secret
  174. metadata:
  175. name: authsecret
  176. namespace: default
  177. #------------ Paste your own password file content here (default user/password=admin/adminadmin)--------------
  178. data:
  179. users: |2
  180. YWRtaW46JGFwcjEkWXdmLkF6Um0kc3owTkpQMi55cy56V2svek43aENtLwoKdXNl
  181. cjokYXByMSRaU2VKQW1pOSRVV1AvcDdsQy9KSzdrbXBIMXdGL28uCgo=
  182. ###############################
  183. # Middleware for HTTP->HTTPS
  184. # This middleware is not needed in case of:
  185. # entrypoints.web.http.redirections.entryPoint.to=websecure
  186. ###############################
  187. #---
  188. #apiVersion: traefik.containo.us/v1alpha1
  189. #kind: Middleware
  190. #metadata:
  191. # name: https-redirect
  192. #spec:
  193. # redirectScheme:
  194. # scheme: https
  195. # permanent: true
  196. # #port: 443
  197. ###############################
  198. # Middleware for CORS
  199. ###############################
  200. ---
  201. apiVersion: traefik.containo.us/v1alpha1
  202. kind: Middleware
  203. metadata:
  204. name: cors-all
  205. spec:
  206. headers:
  207. accessControlAllowMethods:
  208. - "GET"
  209. - "OPTIONS"
  210. - "PUT"
  211. - "POST"
  212. accessControlAllowOriginList:
  213. - "origin-list-or-null"
  214. accessControlMaxAge: 100
  215. accessControlAllowHeaders:
  216. - "Content-Type"
  217. addVaryHeader: true
  218. customRequestHeaders:
  219. X-Forwarded-Proto: "https"