Skip to content

Commit 3e9806d

Browse files
authored
Kubernetes: fix cert-manager first installation (#1246)
* Kubernetes: fix `cert-manager` first installation All resources that rely on `cert-manager` CRDs should be installed after 1) CRDs are installed (achieved via `helm.sh/hook: post-install,post-upgrade`) 2) webhook server is ready to accept connections (achieved via `helm.sh/hook-weight: "10"` which makes it wait until startupapicheck job is completed aka `cert-manager` is ready) Related issue/s * closes #1241 * Remove quotes around hook annotation
1 parent 00cef1b commit 3e9806d

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

charts/cert-manager/templates/certificates.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ apiVersion: cert-manager.io/v1
33
kind: Certificate
44
metadata:
55
name: {{ .certName }}
6+
annotations:
7+
helm.sh/hook: post-install,post-upgrade
8+
helm.sh/hook-weight: "10"
69
spec:
710
# https://github.com/emberstack/kubernetes-reflector?tab=readme-ov-file#cert-manager-support
811
secretTemplate:

charts/cert-manager/values.acme-dns.yaml.gotmpl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ cert-manager:
22
extraArgs:
33
- --dns01-recursive-nameservers="8.8.8.8:53"
44
- --dns01-recursive-nameservers-only
5-
startupapicheck:
6-
enabled: false
75
skipDNSResolutionCheck: true
86
maxConcurrentChallenges: 2
97
extraObjects:
@@ -24,6 +22,13 @@ cert-manager:
2422
metadata:
2523
name: cert-issuer
2624
namespace: {{ .Release.Namespace }}
25+
annotations:
26+
# ClusterIssuer depends on cert-manager CRDs. We need to wait for them to be installed before creating the ClusterIssuer
27+
helm.sh/hook: post-install,post-upgrade
28+
# Run after startupapicheck job. Thus we ensure webhook server is ready
29+
# See https://github.com/cert-manager/cert-manager/issues/4155
30+
# and https://cert-manager.io/docs/concepts/webhook/#webhook-connection-problems-shortly-after-cert-manager-installation
31+
helm.sh/hook-weight: "10"
2732
spec:
2833
acme:
2934
email: {{ requiredEnv "OSPARC_DEVOPS_MAIL_ADRESS" }}

charts/cert-manager/values.common.yaml.gotmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ cert-manager:
1919
replicaCount: 1
2020
webhook:
2121
replicaCount: 1
22+
23+
startupapicheck:
24+
enabled: true
25+
26+
jobAnnotations:
27+
# Explicitly set hook weight to have explicit reference.
28+
# Needed to properly install cert-manager resources first time
29+
helm.sh/hook-weight: "1"

charts/cert-manager/values.route53.yaml.gotmpl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ cert-manager:
1717
name: cert-issuer
1818
namespace: {{ .Release.Namespace }}
1919
annotations:
20-
# ClusterIssuer depends on cert-manager CRDs. We need to wait for them to be installed before creating the ClusterIssuer
21-
"helm.sh/hook": post-install,post-upgrade
22-
"helm.sh/hook-weight": "1"
20+
helm.sh/hook: post-install,post-upgrade
21+
helm.sh/hook-weight: "10"
2322
spec:
2423
acme:
2524
email: {{ requiredEnv "OSPARC_DEVOPS_MAIL_ADRESS" }}

charts/cert-manager/values.selfsigned.yaml.gotmpl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ cert-manager:
77
name: selfsigned-issuer
88
namespace: {{ .Release.Namespace }}
99
annotations:
10-
# It depends on cert-manager CRDs. We need to wait for CRDs to be installed
11-
"helm.sh/hook": post-install,post-upgrade
12-
"helm.sh/hook-weight": "1"
10+
helm.sh/hook: post-install,post-upgrade
11+
helm.sh/hook-weight: "10"
1312
spec:
1413
selfSigned: {}
1514
- |
@@ -19,9 +18,8 @@ cert-manager:
1918
name: local-ca
2019
namespace: {{ .Release.Namespace }}
2120
annotations:
22-
# It depends on cert-manager CRDs. We need to wait for CRDs to be installed
23-
"helm.sh/hook": post-install,post-upgrade
24-
"helm.sh/hook-weight": "1"
21+
helm.sh/hook: post-install,post-upgrade
22+
helm.sh/hook-weight: "10"
2523
spec:
2624
isCA: true
2725
commonName: local-ca
@@ -43,9 +41,8 @@ cert-manager:
4341
name: cert-issuer
4442
namespace: {{ .Release.Namespace }}
4543
annotations:
46-
# It depends on cert-manager CRDs. We need to wait for CRDs to be installed
47-
"helm.sh/hook": post-install,post-upgrade
48-
"helm.sh/hook-weight": "1"
44+
helm.sh/hook: post-install,post-upgrade
45+
helm.sh/hook-weight: "10"
4946
spec:
5047
ca:
5148
secretName: local-ca-secret

0 commit comments

Comments
 (0)