020-deployment.yaml 6.1 KB

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