Skip to content

Commit 5a20c25

Browse files
committed
feat: Updating chart to support CRD struct, Fixes #419
1. Added support for crds.enabled and crds.keep options in the schema.json 2. Created a new type CertManagerCrds to handle these options 3. Updated the provider to use the new type 4. Generated the SDK code for all languages
1 parent 5bf1615 commit 5a20c25

File tree

13 files changed

+640
-14
lines changed

13 files changed

+640
-14
lines changed

README.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,125 @@ or refer to [the examples](/examples) in this repo.
1515

1616
To use this component, first install the Pulumi Package:
1717

18+
```bash
19+
# Node.js (JavaScript/TypeScript)
20+
npm install @pulumi/kubernetes-cert-manager
21+
22+
# Python
23+
pip install pulumi_kubernetes_cert_manager
24+
25+
# Go
26+
go get github.com/pulumi/pulumi-kubernetes-cert-manager/sdk/go/kubernetes-cert-manager
27+
```
28+
1829
Afterwards, import the library and instantiate it within your Pulumi program:
1930

31+
### TypeScript
32+
```typescript
33+
import * as pulumi from "@pulumi/pulumi";
34+
import * as k8s from "@pulumi/kubernetes";
35+
import * as certmanager from "@pulumi/kubernetes-cert-manager";
36+
37+
// Create a namespace for cert-manager
38+
const ns = new k8s.core.v1.Namespace("cert-manager-namespace", {
39+
metadata: {
40+
name: "cert-system",
41+
}
42+
});
43+
44+
// Install cert-manager with CRDs
45+
const cm = new certmanager.CertManager("cert-manager-deployment", {
46+
// Option 1: Using the new recommended approach
47+
crds: {
48+
enabled: true,
49+
keep: true, // Set to true to keep CRDs after uninstall
50+
},
51+
52+
// Option 2: Using deprecated option (not recommended)
53+
// installCRDs: true,
54+
55+
helmOptions: {
56+
namespace: ns.metadata.name,
57+
},
58+
}, { parent: ns });
59+
```
60+
61+
### Python
62+
```python
63+
import pulumi
64+
import pulumi_kubernetes as k8s
65+
import pulumi_kubernetes_cert_manager as certmanager
66+
67+
# Create a namespace for cert-manager
68+
ns = k8s.core.v1.Namespace("cert-manager-namespace",
69+
metadata={
70+
"name": "cert-system",
71+
})
72+
73+
# Install cert-manager with CRDs
74+
cm = certmanager.CertManager("cert-manager-deployment",
75+
# Option 1: Using the new recommended approach
76+
crds={
77+
"enabled": True,
78+
"keep": True, # Set to true to keep CRDs after uninstall
79+
},
80+
81+
# Option 2: Using deprecated option (not recommended)
82+
# install_crds=True,
83+
84+
helm_options={
85+
"namespace": ns.metadata["name"],
86+
})
87+
```
88+
89+
### Go
90+
```go
91+
package main
92+
93+
import (
94+
kubernetes_cert_manager "github.com/pulumi/pulumi-kubernetes-cert-manager/sdk/go/kubernetes-cert-manager"
95+
corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/core/v1"
96+
metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/meta/v1"
97+
helmv3 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/helm/v3"
98+
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
99+
)
100+
101+
func main() {
102+
pulumi.Run(func(ctx *pulumi.Context) error {
103+
// Create a namespace for cert-manager
104+
ns, err := corev1.NewNamespace(ctx, "cert-manager-namespace", &corev1.NamespaceArgs{
105+
Metadata: &metav1.ObjectMetaArgs{
106+
Name: pulumi.String("cert-system"),
107+
},
108+
})
109+
if err != nil {
110+
return err
111+
}
112+
113+
// Option 1: Using the new recommended approach
114+
enabled := true
115+
keep := true
116+
117+
// Install cert-manager with CRDs
118+
_, err = kubernetes_cert_manager.NewCertManager(ctx, "cert-manager-deployment", &kubernetes_cert_manager.CertManagerArgs{
119+
Crds: &kubernetes_cert_manager.CertManagerCrdsArgs{
120+
Enabled: pulumi.BoolPtr(enabled),
121+
Keep: pulumi.BoolPtr(keep), // Set to true to keep CRDs after uninstall
122+
},
123+
124+
// Option 2: Using deprecated option (not recommended)
125+
// InstallCRDs: pulumi.BoolPtr(enabled),
126+
127+
HelmOptions: &helmv3.ReleaseArgs{
128+
Namespace: ns.Metadata.Name(),
129+
},
130+
})
131+
132+
return err
133+
})
134+
}
135+
```
136+
20137
## Configuration
21138

22139
This component supports all of the configuration options of the [official Helm chart](

provider/cmd/pulumi-resource-kubernetes-cert-manager/schema.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@
8989
"$ref": "#/types/kubernetes-cert-manager:index:CertManagerIngressShim"
9090
},
9191
"installCRDs": {
92-
"type": "boolean"
92+
"type": "boolean",
93+
"description": "⚠️ Deprecated: Use crds.enabled instead."
94+
},
95+
"crds": {
96+
"$ref": "#/types/kubernetes-cert-manager:index:CertManagerCrds",
97+
"description": "Control CRDs installation and lifecycle"
9398
},
9499
"no_proxy": {
95100
"items": {
@@ -880,6 +885,19 @@
880885
}
881886
},
882887
"type": "object"
888+
},
889+
"kubernetes-cert-manager:index:CertManagerCrds": {
890+
"properties": {
891+
"enabled": {
892+
"type": "boolean",
893+
"description": "Enable CRDs installation"
894+
},
895+
"keep": {
896+
"type": "boolean",
897+
"description": "Keep CRDs after chart uninstall"
898+
}
899+
},
900+
"type": "object"
883901
}
884902
},
885903
"language": {

provider/pkg/provider/chart.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func (c *CertManager) DefaultRepoURL() string { return "https
3838
type CertManagerArgs struct {
3939
Global kcm.CertManagerGlobalPtrInput `pulumi:"global"`
4040
InstallCRDs *bool `pulumi:"installCRDs"`
41+
Crds kcm.CertManagerCrdsPtrInput `pulumi:"crds"`
4142
ReplicaCount *int `pulumi:"replicaCount"`
4243
Strategy *appsv1.DeploymentStrategy `pulumi:"strategy" pschema:"ref=/kubernetes/v4.21.0/schema.json#/types/kubernetes:apps/v1:DeploymentStrategy"`
4344
// Comma separated list of feature gates that should be enabled on the controller pod.
@@ -302,3 +303,10 @@ type CertManagerStartupAPICheckRBAC struct {
302303
// annotations for the startup API Check job RBAC and PSP resources
303304
Annotations *map[string]string `pulumi:"annotations"`
304305
}
306+
307+
type CertManagerCrds struct {
308+
// Enable CRDs installation
309+
Enabled *bool `pulumi:"enabled"`
310+
// Keep CRDs after chart uninstall
311+
Keep *bool `pulumi:"keep"`
312+
}

sdk/dotnet/CertManager.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ public sealed class CertManagerArgs : global::Pulumi.ResourceArgs
6767
[Input("containerSecurityContext")]
6868
public Input<Pulumi.Kubernetes.Types.Inputs.Core.V1.SecurityContextArgs>? ContainerSecurityContext { get; set; }
6969

70+
/// <summary>
71+
/// Control CRDs installation and lifecycle
72+
/// </summary>
73+
[Input("crds")]
74+
public Input<Inputs.CertManagerCrdsArgs>? Crds { get; set; }
75+
7076
[Input("deploymentAnnotations")]
7177
private InputMap<string>? _deploymentAnnotations;
7278

@@ -142,6 +148,9 @@ public InputList<Pulumi.Kubernetes.Types.Inputs.Core.V1.VolumeArgs> ExtraVolumes
142148
[Input("ingressShim")]
143149
public Input<Inputs.CertManagerIngressShimArgs>? IngressShim { get; set; }
144150

151+
/// <summary>
152+
/// ⚠️ Deprecated: Use crds.enabled instead.
153+
/// </summary>
145154
[Input("installCRDs")]
146155
public Input<bool>? InstallCRDs { get; set; }
147156

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// *** WARNING: this file was generated by pulumi-language-dotnet. ***
2+
// *** Do not edit by hand unless you're certain you know what you are doing! ***
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Collections.Immutable;
7+
using System.Threading.Tasks;
8+
using Pulumi.Serialization;
9+
10+
namespace Pulumi.KubernetesCertManager.Inputs
11+
{
12+
13+
public sealed class CertManagerCrdsArgs : global::Pulumi.ResourceArgs
14+
{
15+
/// <summary>
16+
/// Enable CRDs installation
17+
/// </summary>
18+
[Input("enabled")]
19+
public Input<bool>? Enabled { get; set; }
20+
21+
/// <summary>
22+
/// Keep CRDs after chart uninstall
23+
/// </summary>
24+
[Input("keep")]
25+
public Input<bool>? Keep { get; set; }
26+
27+
public CertManagerCrdsArgs()
28+
{
29+
}
30+
public static new CertManagerCrdsArgs Empty => new CertManagerCrdsArgs();
31+
}
32+
}

sdk/go/kubernetes-cert-manager/certManager.go

Lines changed: 19 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)