You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,11 @@ const cm = new certmanager.CertManager("cert-manager-deployment", {
54
54
// When both installCRDs and crds.enabled are specified, crds.enabled takes precedence
55
55
// installCRDs: true,
56
56
57
+
// Automatically handle CRD conflicts by importing existing CRDs
58
+
// This allows replacing a cert-manager installation without manual deletion
59
+
// When true, Helm will adopt existing CRDs by setting proper annotations and ownership
60
+
importExistingCRDs: true, // Default is true, set to false to disable
61
+
57
62
helmOptions: {
58
63
namespace: ns.metadata.name,
59
64
},
@@ -85,6 +90,11 @@ cm = certmanager.CertManager("cert-manager-deployment",
85
90
# When both install_crds and crds.enabled are specified, crds.enabled takes precedence
86
91
# install_crds=True,
87
92
93
+
# Automatically handle CRD conflicts by importing existing CRDs
94
+
# This allows replacing a cert-manager installation without manual deletion
95
+
# When True, Helm will adopt existing CRDs by setting proper annotations and ownership
96
+
import_existing_crds=True, # Default is True, set to False to disable
97
+
88
98
helm_options={
89
99
"namespace": ns.metadata["name"],
90
100
})
@@ -130,6 +140,11 @@ func main() {
130
140
// When both InstallCRDs and Crds.Enabled are specified, Crds.Enabled takes precedence
131
141
// InstallCRDs: pulumi.BoolPtr(enabled),
132
142
143
+
// Automatically handle CRD conflicts by importing existing CRDs
144
+
// This allows replacing a cert-manager installation without manual deletion
145
+
// When true, Helm will adopt existing CRDs by setting proper annotations and ownership
146
+
ImportExistingCRDs: pulumi.BoolPtr(true), // Default is true, set to false to disable
147
+
133
148
HelmOptions: &helmv3.ReleaseArgs{
134
149
Namespace: ns.Metadata.Name(),
135
150
},
@@ -151,4 +166,23 @@ if you need to override them, you may do so using the `helmOptions` parameter. R
151
166
[the API docs for the `kubernetes:helm/v3:Release` Pulumi type](
152
167
https://www.pulumi.com/docs/reference/pkg/kubernetes/helm/v3/release/#inputs) for a full set of choices.
153
168
169
+
### Handling CRD Ownership During Upgrades
170
+
171
+
A common issue when replacing cert-manager installations is conflicts with existing CRDs, which results in errors like:
172
+
173
+
```
174
+
Unable to continue with install: CustomResourceDefinition "certificaterequests.cert-manager.io" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata
175
+
```
176
+
177
+
To address this, the component provides the `importExistingCRDs` option (default: `true`), which:
178
+
179
+
1. Enables Helm's resource replacement functionality to take ownership of existing CRDs
180
+
2. Sets special annotations to help resolve ownership conflicts:
181
+
-`helm.sh/resource-policy: keep` to preserve CRDs on uninstall
182
+
-`meta.helm.sh/release-name` and `meta.helm.sh/release-namespace` for Helm ownership
183
+
-`kubectl.kubernetes.io/last-applied-configuration` for tracking changes
184
+
3. Configures `keep: true` for CRDs to ensure they persist between installations
185
+
186
+
This approach allows you to replace cert-manager installations without manually deleting the CRDs first, preserving any resources that depend on those CRDs (like Certificate, ClusterIssuer, etc.). To disable this behavior, set `importExistingCRDs: false`.
187
+
154
188
For complete details, refer to the Pulumi Package details within the Pulumi Registry.
0 commit comments