|
| 1 | +--- |
| 2 | +# Create a selfsigned Issuer, in order to create a root CA certificate for |
| 3 | +# signing webhook serving certificates |
| 4 | +apiVersion: cert-manager.io/v1 |
| 5 | +kind: Issuer |
| 6 | +metadata: |
| 7 | + name: {{ include "dnspod-webhook.selfSignedIssuer" . }} |
| 8 | + namespace: {{ include "dnspod-webhook.namespace" . }} |
| 9 | + labels: |
| 10 | + app: {{ include "dnspod-webhook.name" . }} |
| 11 | + chart: {{ include "dnspod-webhook.chart" . }} |
| 12 | + release: {{ .Release.Name }} |
| 13 | + heritage: {{ .Release.Service }} |
| 14 | +spec: |
| 15 | + selfSigned: {} |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +# Generate a CA Certificate used to sign certificates for the webhook |
| 20 | +apiVersion: cert-manager.io/v1 |
| 21 | +kind: Certificate |
| 22 | +metadata: |
| 23 | + name: {{ include "dnspod-webhook.rootCACertificate" . }} |
| 24 | + namespace: {{ include "dnspod-webhook.namespace" . }} |
| 25 | + labels: |
| 26 | + app: {{ include "dnspod-webhook.name" . }} |
| 27 | + chart: {{ include "dnspod-webhook.chart" . }} |
| 28 | + release: {{ .Release.Name }} |
| 29 | + heritage: {{ .Release.Service }} |
| 30 | +spec: |
| 31 | + secretName: {{ include "dnspod-webhook.rootCACertificate" . }} |
| 32 | + duration: 43800h0m0s # 5y |
| 33 | + issuerRef: |
| 34 | + name: {{ include "dnspod-webhook.selfSignedIssuer" . }} |
| 35 | + commonName: "ca.dnspod-webhook.cert-manager" |
| 36 | + isCA: true |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +# Create an Issuer that uses the above generated CA certificate to issue certs |
| 41 | +apiVersion: cert-manager.io/v1 |
| 42 | +kind: Issuer |
| 43 | +metadata: |
| 44 | + name: {{ include "dnspod-webhook.rootCAIssuer" . }} |
| 45 | + namespace: {{ include "dnspod-webhook.namespace" . }} |
| 46 | + labels: |
| 47 | + app: {{ include "dnspod-webhook.name" . }} |
| 48 | + chart: {{ include "dnspod-webhook.chart" . }} |
| 49 | + release: {{ .Release.Name }} |
| 50 | + heritage: {{ .Release.Service }} |
| 51 | +spec: |
| 52 | + ca: |
| 53 | + secretName: {{ include "dnspod-webhook.rootCACertificate" . }} |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +# Finally, generate a serving certificate for the webhook to use |
| 58 | +apiVersion: cert-manager.io/v1 |
| 59 | +kind: Certificate |
| 60 | +metadata: |
| 61 | + name: {{ include "dnspod-webhook.servingCertificate" . }} |
| 62 | + namespace: {{ include "dnspod-webhook.namespace" . }} |
| 63 | + labels: |
| 64 | + app: {{ include "dnspod-webhook.name" . }} |
| 65 | + chart: {{ include "dnspod-webhook.chart" . }} |
| 66 | + release: {{ .Release.Name }} |
| 67 | + heritage: {{ .Release.Service }} |
| 68 | +spec: |
| 69 | + secretName: {{ include "dnspod-webhook.servingCertificate" . }} |
| 70 | + duration: 8760h0m0s # 1y |
| 71 | + issuerRef: |
| 72 | + name: {{ include "dnspod-webhook.rootCAIssuer" . }} |
| 73 | + dnsNames: |
| 74 | + - {{ include "dnspod-webhook.fullname" . }} |
| 75 | + - {{ include "dnspod-webhook.fullname" . }}.{{ include "dnspod-webhook.namespace" . }} |
| 76 | + - {{ include "dnspod-webhook.fullname" . }}.{{ include "dnspod-webhook.namespace" . }}.svc |
| 77 | + |
| 78 | +{{- if .Values.clusterIssuer.enabled }} |
| 79 | +--- |
| 80 | + |
| 81 | +apiVersion: cert-manager.io/v1 |
| 82 | +kind: ClusterIssuer |
| 83 | +metadata: |
| 84 | + name: {{ include "dnspod-webhook.clusterIssuer" . }} |
| 85 | + labels: |
| 86 | + app: {{ include "dnspod-webhook.name" . }} |
| 87 | + chart: {{ include "dnspod-webhook.chart" . }} |
| 88 | + release: {{ .Release.Name }} |
| 89 | + heritage: {{ .Release.Service }} |
| 90 | +spec: |
| 91 | + acme: |
| 92 | + {{- if .Values.clusterIssuer.staging }} |
| 93 | + server: https://acme-staging-v02.api.letsencrypt.org/directory |
| 94 | + {{- else }} |
| 95 | + server: https://acme-v02.api.letsencrypt.org/directory |
| 96 | + {{- end }} |
| 97 | + email: {{ .Values.clusterIssuer.email }} |
| 98 | + privateKeySecretRef: |
| 99 | + name: {{ include "dnspod-webhook.fullname" . }}-letsencrypt |
| 100 | + solvers: |
| 101 | + - dns01: |
| 102 | + webhook: |
| 103 | + groupName: {{ .Values.groupName }} |
| 104 | + solverName: dnspod |
| 105 | + config: |
| 106 | + ttl: {{ .Values.clusterIssuer.ttl }} |
| 107 | + secretId: {{ required ".Values.clusterIssuer.secretId is required" .Values.clusterIssuer.secretId }} |
| 108 | + secretKeyRef: |
| 109 | + key: secret-key |
| 110 | + name: {{ include "dnspod-webhook.fullname" . }}-secret |
| 111 | + {{- if .Values.clusterIssuer.selector }} |
| 112 | + selector: {{ toYaml .Values.clusterIssuer.selector | nindent 8 }} |
| 113 | + {{- end }} |
| 114 | +{{- end }} |
| 115 | + |
0 commit comments