Advertisement
Guest User

Untitled

a guest
Dec 25th, 2024
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.40 KB | None | 0 0
  1. apiVersion: networking.k8s.io/v1
  2. kind: Ingress
  3. metadata:
  4. name: bootstrap-ingress
  5. namespace: kube-system
  6. annotations:
  7. # Use the Kube-VIP ingress class
  8. #kubernetes.io/ingress.class: "traefik"
  9. cert-manager.io/cluster-issuer: cloudflare-issuer
  10. # Optional: Specify Traefik-specific configurations if needed
  11. # traefik.ingress.kubernetes.io/router.entrypoints: websecure
  12. # traefik.ingress.kubernetes.io/router.tls: "true"
  13. spec:
  14. ingressClassName: traefik
  15. tls:
  16. - hosts:
  17. - "bootstrap.example.com"
  18. secretName: bootstrap-wildcard-tls-secret #from the kind certificate field secretName
  19. rules:
  20. - host: bootstrap.example.com
  21. #Ensure there is a DNS override for *.example.com
  22. http:
  23. paths:
  24. - path: /
  25. pathType: Prefix
  26. backend:
  27. service:
  28. name: bootstrap-service
  29. port:
  30. number: 80
  31. ---
  32. apiVersion: v1
  33. kind: Service
  34. metadata:
  35. namespace: kube-system
  36. name: bootstrap-service
  37. spec:
  38. type: ClusterIP
  39. selector:
  40. app: bootstrap
  41. ports:
  42. - protocol: TCP
  43. port: 80
  44. targetPort: 80
  45. name: web
  46. ---
  47. apiVersion: apps/v1
  48. kind: Deployment
  49. metadata:
  50. name: bootstrap-deployment
  51. namespace: kube-system
  52. spec:
  53. selector:
  54. matchLabels:
  55. app: bootstrap
  56. replicas: 1
  57. template:
  58. metadata:
  59. labels:
  60. app: bootstrap
  61. spec:
  62. nodeSelector:
  63. node.longhorn.io/type: agent #match label
  64. containers:
  65. - name: nginx
  66. image: nginx
  67. ports:
  68. - containerPort: 80
  69. volumeMounts:
  70. - name: bootstrap-volume
  71. mountPath: /usr/share/nginx/html
  72. volumes:
  73. - name: bootstrap-volume
  74. configMap:
  75. name: bootstrap-configmap
  76. ---
  77. apiVersion: v1
  78. kind: ConfigMap
  79. metadata:
  80. name: bootstrap-configmap
  81. namespace: kube-system
  82. data:
  83. index.html: |
  84. <html>
  85. <head>
  86. <title>Hello World via HTTPS bootstrap!</title>
  87. </head>
  88. <body>Hello World via HTTPS bootstrap!</body>
  89. </html>
  90.  
  91.  
  92.  
  93.  
  94. #Putting the wildcard into a shared namespace. The individual ingress will need a role and rolebinding to access it
  95. #kubectl describe certificaterequest -A
  96. #kubectl get certificaterequests -A
  97. ---
  98. apiVersion: traefik.io/v1alpha1
  99. kind: TLSStore
  100. metadata:
  101. name: tls-store
  102. namespace: kube-system # Use the namespace where Traefik is installed (kube-system under k3s)
  103. spec:
  104. defaultCertificate:
  105. secretName: bootstrap-wildcard-tls-secret
  106.  
  107. ---
  108. apiVersion: cert-manager.io/v1
  109. kind: Certificate
  110. metadata:
  111. name: bootstrap-cert
  112. namespace: kube-system
  113. spec:
  114. # Secret names are always required.
  115. secretName: bootstrap-wildcard-tls-secret
  116.  
  117. # secretTemplate is optional. If set, these annotations and labels will be
  118. # copied to the Secret named example-com-tls. These labels and annotations will
  119. # be re-reconciled if the Certificate's secretTemplate changes. secretTemplate
  120. # is also enforced, so relevant label and annotation changes on the Secret by a
  121. # third party will be overwriten by cert-manager to match the secretTemplate.
  122. # secretTemplate:
  123. # annotations:
  124. # my-secret-annotation-1: "foo"
  125. # my-secret-annotation-2: "bar"
  126. # labels:
  127. # my-secret-label: foo
  128.  
  129. privateKey:
  130. algorithm: RSA
  131. encoding: PKCS1
  132. size: 2048
  133.  
  134. # keystores allows adding additional output formats. This is an example for reference only.
  135. # keystores:
  136. # pkcs12:
  137. # create: true
  138. # passwordSecretRef:
  139. # name: example-com-tls-keystore
  140. # key: password
  141. # profile: Modern2023
  142.  
  143. duration: 2160h # 90d
  144. renewBefore: 360h # 15d
  145.  
  146. isCA: false
  147. usages:
  148. - server auth
  149. - client auth
  150.  
  151. subject:
  152. organizations:
  153. - cert-manager
  154.  
  155. # Avoid using commonName for DNS names in end-entity (leaf) certificates. Unless you have a specific
  156. # need for it in your environment, use dnsNames exclusively to avoid issues with commonName.
  157. # Usually, commonName is used to give human-readable names to CA certificates and can be avoided for
  158. # other certificates.
  159. commonName: "*.example.com"
  160.  
  161. # The literalSubject field is exclusive with subject and commonName. It allows
  162. # specifying the subject directly as a string. This is useful for when the order
  163. # of the subject fields is important or when the subject contains special types
  164. # which can be specified by their OID.
  165. #
  166. # literalSubject: "O=jetstack, CN=example.com, 2.5.4.42=John, 2.5.4.4=Doe"
  167.  
  168. # At least one of commonName (possibly through literalSubject), dnsNames, uris, emailAddresses, ipAddresses or otherNames is required.
  169. dnsNames:
  170. - "*.example.com"
  171. # - example.com
  172. # - www.example.com
  173. # uris:
  174. # - spiffe://cluster.local/ns/sandbox/sa/example
  175. # emailAddresses:
  176. # ipAddresses:
  177. # - 192.168.0.5
  178. # # Needs cert-manager 1.14+ and "OtherNames" feature flag
  179. # otherNames:
  180. # # Should only supply oid of ut8 valued types
  181. # - oid: 1.3.6.1.4.1.311.20.2.3 # User Principal Name "OID"
  182. # utf8Value: [email protected]
  183.  
  184. # Issuer references are always required.
  185. issuerRef:
  186. name: cloudflare-issuer
  187. # We can reference ClusterIssuers by changing the kind here.
  188. # The default value is Issuer (i.e. a locally namespaced Issuer)
  189. kind: ClusterIssuer
  190. # This is optional since cert-manager will default to this value however
  191. # if you are using an external issuer, change this to that issuer group.
  192. group: cert-manager.io
  193. ---
  194. #ClusterIssuer needs to live in a specific namespace - cert-manager
  195.  
  196. apiVersion: v1
  197. kind: Secret
  198. metadata:
  199. name: cloudflare-api-token-secret
  200. namespace: cert-manager
  201. type: Opaque
  202. stringData:
  203. api-token:
  204. ---
  205. apiVersion: cert-manager.io/v1
  206. kind: ClusterIssuer #Has to be cluster type so as to not be namespaced
  207. metadata:
  208. name: cloudflare-issuer
  209. namespace: cert-manager
  210. spec:
  211. acme:
  212. email: xx
  213. #server: https://acme-staging-v02.api.letsencrypt.org/directory
  214. server: https://acme-v02.api.letsencrypt.org/directory
  215. privateKeySecretRef:
  216. name: ca-key-pair # Secret resource that will be used to store the account's private key.
  217. solvers:
  218. - dns01:
  219. cloudflare:
  220. apiTokenSecretRef:
  221. name: cloudflare-api-token-secret #CF api token from secret
  222. key: api-token
  223.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement