020-deployment.yaml 6.0 KB

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