From 0ce4caa05d6e8c3f1def2ced60610c839bb3478a Mon Sep 17 00:00:00 2001 From: Vivek Lakshmanan Date: Wed, 26 Jan 2022 21:46:50 -0800 Subject: [PATCH] [Helm/Release] Add examples to API reference docs sdks --- .../pulumi-resource-kubernetes/schema.json | 2 +- .../pkg/gen/examples/overlays/helmRelease.md | 748 +++++++++++++++++- sdk/dotnet/Helm/V3/Release.cs | 233 +++++- sdk/go/kubernetes/helm/v3/release.go | 254 +++++- sdk/nodejs/helm/v3/release.ts | 143 +++- .../pulumi_kubernetes/helm/v3/Release.py | 310 +++++++- 6 files changed, 1677 insertions(+), 13 deletions(-) diff --git a/provider/cmd/pulumi-resource-kubernetes/schema.json b/provider/cmd/pulumi-resource-kubernetes/schema.json index 3dfe36009c..c413b25f4e 100644 --- a/provider/cmd/pulumi-resource-kubernetes/schema.json +++ b/provider/cmd/pulumi-resource-kubernetes/schema.json @@ -41595,7 +41595,7 @@ "isComponent": true }, "kubernetes:helm.sh/v3:Release": { - "description": "A Release is an instance of a chart running in a Kubernetes cluster.\nA Chart is a Helm package. It contains all the resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster.\n", + "description": "A `Release` is an instance of a chart running in a Kubernetes cluster. A `Chart` is a Helm package. It contains all the\nresource definitions necessary to run an application, tool, or service inside a Kubernetes cluster.\n\nThis resource models a Helm Release as if it were created by the Helm CLI. The underlying implementation embeds Helm as\na library to perform the orchestration of the resources. As a result, the full spectrum of Helm features are supported\nnatively.\n\n{{% examples %}}\n## Example Usage\n{{% example %}}\n### Local Chart Directory\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v3.Release(\"nginx-ingress\", {\n chart: \"./nginx-ingress\",\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v3 import Release, ReleaseArgs\n\nnginx_ingress = Release(\n \"nginx-ingress\",\n ReleaseArgs(\n chart=\"./nginx-ingress\",\n ),\n)\n```\n```csharp\nusing Pulumi;\nusing Pulumi.Kubernetes.Types.Inputs.Helm.V3;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Release(\"nginx-ingress\", new ReleaseArgs\n {\n Chart = \"./nginx-ingress\",\n });\n\n }\n}\n```\n```go\npackage main\n\n\"fmt\"\n\n\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewRelease(ctx, \"nginx-ingress\", helm.ReleaseArgs{\n\t\t\tChart: pulumi.String(\"./nginx-ingress\"),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% example %}}\n### Remote Chart\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v3.Release(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n repositoryOpts: {\n repo: \"https://charts.helm.sh/stable\",\n },\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs\n\nnginx_ingress = Release(\n \"nginx-ingress\",\n ReleaseArgs(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n repository_opts=RepositoryOptsArgs(\n repo=\"https://charts.helm.sh/stable\",\n ),\n ),\n)\n```\n```csharp\nusing Pulumi;\nusing Pulumi.Kubernetes.Types.Inputs.Helm.V3;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Release(\"nginx-ingress\", new ReleaseArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n RepositoryOpts = new RepositoryOptsArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n }\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewRelease(ctx, \"nginx-ingress\", helm.ReleaseArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tRepositoryOpts: helm.RepositoryOptsArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% example %}}\n### Set Chart Values\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v3.Release(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n repositoryOpts: {\n repo: \"https://charts.helm.sh/stable\",\n },\n values: {\n controller: {\n metrics: {\n enabled: true,\n }\n }\n },\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs\n\nnginx_ingress = Release(\n \"nginx-ingress\",\n ReleaseArgs(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n repository_opts=RepositoryOptsArgs(\n repo=\"https://charts.helm.sh/stable\",\n ),\n values={\n \"controller\": {\n \"metrics\": {\n \"enabled\": True,\n },\n },\n },\n ),\n)\n```\n```csharp\nusing System.Collections.Generic;\nusing Pulumi;\nusing Pulumi.Kubernetes.Types.Inputs.Helm.V3;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var values = new Dictionary\n {\n [\"controller\"] = new Dictionary\n {\n [\"metrics\"] = new Dictionary\n {\n [\"enabled\"] = true\n }\n },\n };\n\n var nginx = new Release(\"nginx-ingress\", new ReleaseArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n RepositoryOpts = new RepositoryOptsArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n },\n Values = values,\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewRelease(ctx, \"nginx-ingress\", helm.ReleaseArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tRepositoryOpts: helm.RepositoryOptsArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t\tValues: pulumi.Map{\n\t\t\t\t\"controller\": pulumi.Map{\n\t\t\t\t\t\"metrics\": pulumi.Map{\n\t\t\t\t\t\t\"enabled\": pulumi.Bool(true),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% example %}}\n### Deploy Chart into Namespace\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v3.Release(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n namespace: \"test-namespace\",\n repositoryOpts: {\n repo: \"https://charts.helm.sh/stable\",\n },\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs\n\nnginx_ingress = Release(\n \"nginx-ingress\",\n ReleaseArgs(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n namespace=\"test-namespace\",\n repository_opts=RepositoryOptsArgs(\n repo=\"https://charts.helm.sh/stable\",\n ),\n ),\n)\n```\n```csharp\nusing Pulumi;\nusing Pulumi.Kubernetes.Types.Inputs.Helm.V3;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Release(\"nginx-ingress\", new ReleaseArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n Namespace = \"test-namespace\",\n RepositoryOpts = new RepositoryOptsArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n },\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewRelease(ctx, \"nginx-ingress\", helm.ReleaseArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tNamespace: pulumi.String(\"test-namespace\"),\n\t\t\tRepositoryOpts: helm.RepositoryOptsArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n {{% example %}}\n\n### Depend on a Chart resource\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v3.Release(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n namespace: \"test-namespace\",\n repositoryOpts: {\n repo: \"https://charts.helm.sh/stable\",\n },\n skipAwait: false,\n});\n\n// Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart\n// resources are ready. Notice skipAwait is set to false above. This is the default and will cause Helm\n// to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away.\nnew k8s.core.v1.ConfigMap(\"foo\", {\n metadata: {namespace: namespaceName},\n data: {foo: \"bar\"}\n}, {dependsOn: nginxIngress})\n```\n```python\nimport pulumi\nfrom pulumi_kubernetes.core.v1 import ConfigMap, ConfigMapInitArgs\nfrom pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs\n\nnginx_ingress = Release(\n \"nginx-ingress\",\n ReleaseArgs(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n namespace=\"test-namespace\",\n repository_opts=RepositoryOptsArgs(\n repo=\"https://charts.helm.sh/stable\",\n ),\n skip_await=False,\n ),\n)\n\n# Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart\n# resources are ready. Notice skip_await is set to false above. This is the default and will cause Helm\n# to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away.\nConfigMap(\"foo\", ConfigMapInitArgs(data={\"foo\": \"bar\"}), opts=pulumi.ResourceOptions(depends_on=nginx_ingress))\n```\n```csharp\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Core.V1;\nusing Pulumi.Kubernetes.Types.Inputs.Helm.V3;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Release(\"nginx-ingress\", new ReleaseArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n Namespace = \"test-namespace\",\n RepositoryOpts = new RepositoryOptsArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n },\n SkipAwait = false,\n });\n\n // Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart\n // resources are ready. Notice SkipAwait is set to false above. This is the default and will cause Helm\n // to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away.\n new ConfigMap(\"foo\", new Pulumi.Kubernetes.Types.Inputs.Core.V1.ConfigMapArgs\n {\n Data = new InputMap\n {\n {\"foo\", \"bar\"}\n },\n }, new CustomResourceOptions\n {\n DependsOn = nginx,\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\tcorev1 \"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1\"\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\trelease, err := helm.NewRelease(ctx, \"nginx-ingress\", helm.ReleaseArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tNamespace: pulumi.String(\"test-namespace\"),\n\t\t\tRepositoryOpts: helm.RepositoryOptsArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t\tSkipAwait: pulumi.Bool(false),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart\n\t\t// resources are ready. Notice SkipAwait is set to false above. This is the default and will cause Helm\n\t\t// to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away.\n\t\t_, err = corev1.NewConfigMap(ctx, \"cm\", &corev1.ConfigMapArgs{\n\t\t\tData: pulumi.StringMap{\n\t\t\t\t\"foo\": pulumi.String(\"bar\"),\n\t\t\t},\n\t\t}, pulumi.DependsOnInputs(release))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% example %}}\n### Specify Helm Chart Values in File and Code\n\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as k8s from \"@pulumi/kubernetes\";\nimport {FileAsset} from \"@pulumi/pulumi/asset\";\n\nconst release = new k8s.helm.v3.Release(\"redis\", {\n chart: \"redis\",\n repositoryOpts: {\n repo: \"https://charts.bitnami.com/bitnami\",\n },\n valueYamlFiles: [new FileAsset(\"./metrics.yml\")],\n values: {\n cluster: {\n enabled: true,\n },\n rbac: {\n create: true,\n }\n },\n});\n\n// -- Contents of metrics.yml --\n// metrics:\n// enabled: true\n```\n```python\nimport pulumi\nfrom pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs\n\nnginx_ingress = Release(\n \"redis\",\n ReleaseArgs(\n chart=\"redis\",\n repository_opts=RepositoryOptsArgs(\n repo=\"https://charts.bitnami.com/bitnami\",\n ),\n value_yaml_files=pulumi.FileAsset(\"./metrics.yml\"),\n values={\n cluster: {\n enabled: true,\n },\n rbac: {\n create: true,\n }\n },\n ),\n)\n\n# -- Contents of metrics.yml --\n# metrics:\n# enabled: true\n```\n```csharp\nusing System.Collections.Generic;\nusing Pulumi;\nusing Pulumi.Kubernetes.Types.Inputs.Helm.V3;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Release(\"redis\", new ReleaseArgs\n {\n Chart = \"redis\",\n RepositoryOpts = new RepositoryOptsArgs\n {\n Repo = \"https://charts.bitnami.com/bitnami\"\n },\n ValueYamlFiles = new FileAsset(\"./metrics.yml\");\n Values = new InputMap\n {\n [\"cluster\"] = new Dictionary\n {\n [\"enabled\"] = true,\n },\n [\"rbac\"] = new Dictionary\n {\n [\"create\"] = true,\n }\n },\n });\n }\n}\n\n// -- Contents of metrics.yml --\n// metrics:\n// enabled: true\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/yaml\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewRelease(ctx, \"redis\", helm.ReleaseArgs{\n\t\t\tChart: pulumi.String(\"redis\"),\n\t\t\tRepositoryOpts: helm.RepositoryOptsArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t\tValueYamlFiles: pulumi.NewFileAsset(\"./metrics.yml\"),\n\t\t\tValue: pulumi.Map{\n\t\t\t\t\"cluster\": pulumi.Map{\n \"enabled\": pulumi.Bool(true),\n },\n \"rbac\": pulumi.Map{\n \"create\": pulumi.Bool(true),\n },\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n\n// -- Contents of metrics.yml --\n// metrics:\n// enabled: true\n```\n{{% /example %}}\n{{% example %}}\n### Query Kubernetes Resource Installed By Helm Chart\n\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as k8s from \"@pulumi/kubernetes\";\nimport {FileAsset} from \"@pulumi/pulumi/asset\";\n\nconst redis = new k8s.helm.v3.Release(\"redis\", {\n chart: \"redis\",\n repositoryOpts: {\n repo: \"https://charts.bitnami.com/bitnami\",\n },\n values: {\n cluster: {\n enabled: true,\n },\n rbac: {\n create: true,\n }\n },\n});\n\n// srv will only resolve after the redis chart is installed.\nconst srv = k8s.core.v1.Service.get(\"redis-master-svc\", pulumi.interpolate`${redis.status.namespace}/${redis.status.name}-master`);\nexport const redisMasterClusterIP = srv.spec.clusterIP;\n```\n```python\nfrom pulumi import Output\nfrom pulumi_kubernetes.core.v1 import Service\nfrom pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs\n\nredis = Release(\n \"redis\",\n ReleaseArgs(\n chart=\"redis\",\n repository_opts=RepositoryOptsArgs(\n repo=\"https://charts.bitnami.com/bitnami\",\n ),\n values={\n \"cluster\": {\n \"enabled\": True,\n },\n \"rbac\": {\n \"create\": True,\n }\n },\n ),\n)\n\n# srv will only resolve after the redis chart is installed.\nsrv = Service.get(\"redis-master-svc\", Output.concat(redis.status.namespace, \"/\", redis.status.name, \"-master\"))\npulumi.export(\"redisMasterClusterIP\", srv.spec.cluster_ip)\n```\n```csharp\nusing System.Collections.Generic;\nusing Pulumi;\nusing Pulumi.Kubernetes.Types.Inputs.Helm.V3;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var redis = new Release(\"redis\", new ReleaseArgs\n {\n Chart = \"redis\",\n RepositoryOpts = new RepositoryOptsArgs\n {\n Repo = \"https://charts.bitnami.com/bitnami\"\n },\n Values = new InputMap\n {\n [\"cluster\"] = new Dictionary\n {\n [\"enabled\"] = true,\n },\n [\"rbac\"] = new Dictionary\n {\n [\"create\"] = true,\n }\n },\n });\n\n var status = redis.Status;\n // srv will only resolve after the redis chart is installed.\n var srv = Service.Get(\"redist-master-svc\", Output.All(status).Apply(\n s => $\"{s[0].Namespace}/{s[0].Name}-master\"));\n this.RedisMasterClusterIP = srv.Spec.Apply(spec => spec.ClusterIP);\n }\n\n [Output]\n public Output RedisMasterClusterIP { get; set; }\n}\n```\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\tcorev1 \"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1\"\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi-random/sdk/v4/go/random\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\trel, err := helm.NewRelease(ctx, \"redis\", &helm.ReleaseArgs{\n\t\t\tChart: pulumi.String(\"redis\"),\n\t\t\tRepositoryOpts: helm.RepositoryOptsArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.bitnami.com/bitnami\"),\n\t\t\t},\n\t\t\tValues: pulumi.Map{\n\t\t\t\t\"cluster\": pulumi.Map{\n\t\t\t\t\t\"enabled\": pulumi.Bool(true),\n\t\t\t\t},\n\t\t\t\t\"rbac\": pulumi.BoolMap{\n\t\t\t\t\t\"create\": pulumi.Bool(true),\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// srv will only resolve after the redis chart is installed.\n\t\tsrv := pulumi.All(rel.Status.Namespace(), rel.Status.Name()).\n\t\t\tApplyT(func(r interface{}) (interface{}, error) {\n\t\t\t\tarr := r.([]interface{})\n\t\t\t\tnamespace := arr[0].(*string)\n\t\t\t\tname := arr[1].(*string)\n\t\t\t\tsvc, err := corev1.GetService(ctx,\n\t\t\t\t\t\"redis-master-svc\",\n\t\t\t\t\tpulumi.ID(fmt.Sprintf(\"%s/%s-master\", *namespace, *name)),\n\t\t\t\t\tnil,\n\t\t\t\t)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn \"\", nil\n\t\t\t\t}\n\t\t\t\treturn svc.Spec.ClusterIP(), nil\n\t\t\t})\n\t\tctx.Export(\"redisMasterClusterIP\", srv)\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% /examples %}}\n\n", "properties": { "atomic": { "type": "boolean", diff --git a/provider/pkg/gen/examples/overlays/helmRelease.md b/provider/pkg/gen/examples/overlays/helmRelease.md index 8fd8cae5df..b77da6080c 100644 --- a/provider/pkg/gen/examples/overlays/helmRelease.md +++ b/provider/pkg/gen/examples/overlays/helmRelease.md @@ -1,2 +1,746 @@ -A Release is an instance of a chart running in a Kubernetes cluster. -A Chart is a Helm package. It contains all the resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. +A `Release` is an instance of a chart running in a Kubernetes cluster. A `Chart` is a Helm package. It contains all the +resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. + +This resource models a Helm Release as if it were created by the Helm CLI. The underlying implementation embeds Helm as +a library to perform the orchestration of the resources. As a result, the full spectrum of Helm features are supported +natively. + +{{% examples %}} +## Example Usage +{{% example %}} +### Local Chart Directory + +```typescript +import * as k8s from "@pulumi/kubernetes"; + +const nginxIngress = new k8s.helm.v3.Release("nginx-ingress", { + chart: "./nginx-ingress", +}); +``` +```python +from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs + +nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="./nginx-ingress", + ), +) +``` +```csharp +using Pulumi; +using Pulumi.Kubernetes.Types.Inputs.Helm.V3; +using Pulumi.Kubernetes.Helm.V3; + +class HelmStack : Stack +{ + public HelmStack() + { + var nginx = new Release("nginx-ingress", new ReleaseArgs + { + Chart = "./nginx-ingress", + }); + + } +} +``` +```go +package main + +"fmt" + +"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" +"github.com/pulumi/pulumi/sdk/v3/go/pulumi" + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + _, err := helm.NewRelease(ctx, "nginx-ingress", helm.ReleaseArgs{ + Chart: pulumi.String("./nginx-ingress"), + }) + if err != nil { + return err + } + + return nil + }) +} +``` +{{% /example %}} +{{% example %}} +### Remote Chart + +```typescript +import * as k8s from "@pulumi/kubernetes"; + +const nginxIngress = new k8s.helm.v3.Release("nginx-ingress", { + chart: "nginx-ingress", + version: "1.24.4", + repositoryOpts: { + repo: "https://charts.helm.sh/stable", + }, +}); +``` +```python +from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + +nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + ), +) +``` +```csharp +using Pulumi; +using Pulumi.Kubernetes.Types.Inputs.Helm.V3; +using Pulumi.Kubernetes.Helm.V3; + +class HelmStack : Stack +{ + public HelmStack() + { + var nginx = new Release("nginx-ingress", new ReleaseArgs + { + Chart = "nginx-ingress", + Version = "1.24.4", + RepositoryOpts = new RepositoryOptsArgs + { + Repo = "https://charts.helm.sh/stable" + } + }); + + } +} +``` +```go +package main + +import ( + "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + _, err := helm.NewRelease(ctx, "nginx-ingress", helm.ReleaseArgs{ + Chart: pulumi.String("nginx-ingress"), + Version: pulumi.String("1.24.4"), + RepositoryOpts: helm.RepositoryOptsArgs{ + Repo: pulumi.String("https://charts.helm.sh/stable"), + }, + }) + if err != nil { + return err + } + + return nil + }) +} +``` +{{% /example %}} +{{% example %}} +### Set Chart Values + +```typescript +import * as k8s from "@pulumi/kubernetes"; + +const nginxIngress = new k8s.helm.v3.Release("nginx-ingress", { + chart: "nginx-ingress", + version: "1.24.4", + repositoryOpts: { + repo: "https://charts.helm.sh/stable", + }, + values: { + controller: { + metrics: { + enabled: true, + } + } + }, +}); +``` +```python +from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + +nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + values={ + "controller": { + "metrics": { + "enabled": True, + }, + }, + }, + ), +) +``` +```csharp +using System.Collections.Generic; +using Pulumi; +using Pulumi.Kubernetes.Types.Inputs.Helm.V3; +using Pulumi.Kubernetes.Helm.V3; + +class HelmStack : Stack +{ + public HelmStack() + { + var values = new Dictionary + { + ["controller"] = new Dictionary + { + ["metrics"] = new Dictionary + { + ["enabled"] = true + } + }, + }; + + var nginx = new Release("nginx-ingress", new ReleaseArgs + { + Chart = "nginx-ingress", + Version = "1.24.4", + RepositoryOpts = new RepositoryOptsArgs + { + Repo = "https://charts.helm.sh/stable" + }, + Values = values, + }); + + } +} +``` +```go +package main + +import ( + "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + _, err := helm.NewRelease(ctx, "nginx-ingress", helm.ReleaseArgs{ + Chart: pulumi.String("nginx-ingress"), + Version: pulumi.String("1.24.4"), + RepositoryOpts: helm.RepositoryOptsArgs{ + Repo: pulumi.String("https://charts.helm.sh/stable"), + }, + Values: pulumi.Map{ + "controller": pulumi.Map{ + "metrics": pulumi.Map{ + "enabled": pulumi.Bool(true), + }, + }, + }, + }) + if err != nil { + return err + } + + return nil + }) +} +``` +{{% /example %}} +{{% example %}} +### Deploy Chart into Namespace + +```typescript +import * as k8s from "@pulumi/kubernetes"; + +const nginxIngress = new k8s.helm.v3.Release("nginx-ingress", { + chart: "nginx-ingress", + version: "1.24.4", + namespace: "test-namespace", + repositoryOpts: { + repo: "https://charts.helm.sh/stable", + }, +}); +``` +```python +from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + +nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + namespace="test-namespace", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + ), +) +``` +```csharp +using Pulumi; +using Pulumi.Kubernetes.Types.Inputs.Helm.V3; +using Pulumi.Kubernetes.Helm.V3; + +class HelmStack : Stack +{ + public HelmStack() + { + var nginx = new Release("nginx-ingress", new ReleaseArgs + { + Chart = "nginx-ingress", + Version = "1.24.4", + Namespace = "test-namespace", + RepositoryOpts = new RepositoryOptsArgs + { + Repo = "https://charts.helm.sh/stable" + }, + }); + + } +} +``` +```go +package main + +import ( + "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + _, err := helm.NewRelease(ctx, "nginx-ingress", helm.ReleaseArgs{ + Chart: pulumi.String("nginx-ingress"), + Version: pulumi.String("1.24.4"), + Namespace: pulumi.String("test-namespace"), + RepositoryOpts: helm.RepositoryOptsArgs{ + Repo: pulumi.String("https://charts.helm.sh/stable"), + }, + }) + if err != nil { + return err + } + + return nil + }) +} +``` +{{% /example %}} + {{% example %}} + +### Depend on a Chart resource + +```typescript +import * as k8s from "@pulumi/kubernetes"; + +const nginxIngress = new k8s.helm.v3.Release("nginx-ingress", { + chart: "nginx-ingress", + version: "1.24.4", + namespace: "test-namespace", + repositoryOpts: { + repo: "https://charts.helm.sh/stable", + }, + skipAwait: false, +}); + +// Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart +// resources are ready. Notice skipAwait is set to false above. This is the default and will cause Helm +// to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away. +new k8s.core.v1.ConfigMap("foo", { + metadata: {namespace: namespaceName}, + data: {foo: "bar"} +}, {dependsOn: nginxIngress}) +``` +```python +import pulumi +from pulumi_kubernetes.core.v1 import ConfigMap, ConfigMapInitArgs +from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + +nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + namespace="test-namespace", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + skip_await=False, + ), +) + +# Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart +# resources are ready. Notice skip_await is set to false above. This is the default and will cause Helm +# to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away. +ConfigMap("foo", ConfigMapInitArgs(data={"foo": "bar"}), opts=pulumi.ResourceOptions(depends_on=nginx_ingress)) +``` +```csharp +using System.Threading.Tasks; +using Pulumi; +using Pulumi.Kubernetes.Core.V1; +using Pulumi.Kubernetes.Types.Inputs.Helm.V3; +using Pulumi.Kubernetes.Helm.V3; + +class HelmStack : Stack +{ + public HelmStack() + { + var nginx = new Release("nginx-ingress", new ReleaseArgs + { + Chart = "nginx-ingress", + Version = "1.24.4", + Namespace = "test-namespace", + RepositoryOpts = new RepositoryOptsArgs + { + Repo = "https://charts.helm.sh/stable" + }, + SkipAwait = false, + }); + + // Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart + // resources are ready. Notice SkipAwait is set to false above. This is the default and will cause Helm + // to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away. + new ConfigMap("foo", new Pulumi.Kubernetes.Types.Inputs.Core.V1.ConfigMapArgs + { + Data = new InputMap + { + {"foo", "bar"} + }, + }, new CustomResourceOptions + { + DependsOn = nginx, + }); + + } +} +``` +```go +package main + +import ( + corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" + "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + release, err := helm.NewRelease(ctx, "nginx-ingress", helm.ReleaseArgs{ + Chart: pulumi.String("nginx-ingress"), + Version: pulumi.String("1.24.4"), + Namespace: pulumi.String("test-namespace"), + RepositoryOpts: helm.RepositoryOptsArgs{ + Repo: pulumi.String("https://charts.helm.sh/stable"), + }, + SkipAwait: pulumi.Bool(false), + }) + if err != nil { + return err + } + + // Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart + // resources are ready. Notice SkipAwait is set to false above. This is the default and will cause Helm + // to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away. + _, err = corev1.NewConfigMap(ctx, "cm", &corev1.ConfigMapArgs{ + Data: pulumi.StringMap{ + "foo": pulumi.String("bar"), + }, + }, pulumi.DependsOnInputs(release)) + if err != nil { + return err + } + + return nil + }) +} +``` +{{% /example %}} +{{% example %}} +### Specify Helm Chart Values in File and Code + +```typescript +import * as pulumi from "@pulumi/pulumi"; +import * as k8s from "@pulumi/kubernetes"; +import {FileAsset} from "@pulumi/pulumi/asset"; + +const release = new k8s.helm.v3.Release("redis", { + chart: "redis", + repositoryOpts: { + repo: "https://charts.bitnami.com/bitnami", + }, + valueYamlFiles: [new FileAsset("./metrics.yml")], + values: { + cluster: { + enabled: true, + }, + rbac: { + create: true, + } + }, +}); + +// -- Contents of metrics.yml -- +// metrics: +// enabled: true +``` +```python +import pulumi +from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + +nginx_ingress = Release( + "redis", + ReleaseArgs( + chart="redis", + repository_opts=RepositoryOptsArgs( + repo="https://charts.bitnami.com/bitnami", + ), + value_yaml_files=pulumi.FileAsset("./metrics.yml"), + values={ + cluster: { + enabled: true, + }, + rbac: { + create: true, + } + }, + ), +) + +# -- Contents of metrics.yml -- +# metrics: +# enabled: true +``` +```csharp +using System.Collections.Generic; +using Pulumi; +using Pulumi.Kubernetes.Types.Inputs.Helm.V3; +using Pulumi.Kubernetes.Helm.V3; + +class HelmStack : Stack +{ + public HelmStack() + { + var nginx = new Release("redis", new ReleaseArgs + { + Chart = "redis", + RepositoryOpts = new RepositoryOptsArgs + { + Repo = "https://charts.bitnami.com/bitnami" + }, + ValueYamlFiles = new FileAsset("./metrics.yml"); + Values = new InputMap + { + ["cluster"] = new Dictionary + { + ["enabled"] = true, + }, + ["rbac"] = new Dictionary + { + ["create"] = true, + } + }, + }); + } +} + +// -- Contents of metrics.yml -- +// metrics: +// enabled: true +``` +```go +package main + +import ( + "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" + "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/yaml" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + _, err := helm.NewRelease(ctx, "redis", helm.ReleaseArgs{ + Chart: pulumi.String("redis"), + RepositoryOpts: helm.RepositoryOptsArgs{ + Repo: pulumi.String("https://charts.helm.sh/stable"), + }, + ValueYamlFiles: pulumi.NewFileAsset("./metrics.yml"), + Value: pulumi.Map{ + "cluster": pulumi.Map{ + "enabled": pulumi.Bool(true), + }, + "rbac": pulumi.Map{ + "create": pulumi.Bool(true), + }, + }, + }) + if err != nil { + return err + } + + return nil + }) +} + +// -- Contents of metrics.yml -- +// metrics: +// enabled: true +``` +{{% /example %}} +{{% example %}} +### Query Kubernetes Resource Installed By Helm Chart + +```typescript +import * as pulumi from "@pulumi/pulumi"; +import * as k8s from "@pulumi/kubernetes"; +import {FileAsset} from "@pulumi/pulumi/asset"; + +const redis = new k8s.helm.v3.Release("redis", { + chart: "redis", + repositoryOpts: { + repo: "https://charts.bitnami.com/bitnami", + }, + values: { + cluster: { + enabled: true, + }, + rbac: { + create: true, + } + }, +}); + +// srv will only resolve after the redis chart is installed. +const srv = k8s.core.v1.Service.get("redis-master-svc", pulumi.interpolate`${redis.status.namespace}/${redis.status.name}-master`); +export const redisMasterClusterIP = srv.spec.clusterIP; +``` +```python +from pulumi import Output +from pulumi_kubernetes.core.v1 import Service +from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + +redis = Release( + "redis", + ReleaseArgs( + chart="redis", + repository_opts=RepositoryOptsArgs( + repo="https://charts.bitnami.com/bitnami", + ), + values={ + "cluster": { + "enabled": True, + }, + "rbac": { + "create": True, + } + }, + ), +) + +# srv will only resolve after the redis chart is installed. +srv = Service.get("redis-master-svc", Output.concat(redis.status.namespace, "/", redis.status.name, "-master")) +pulumi.export("redisMasterClusterIP", srv.spec.cluster_ip) +``` +```csharp +using System.Collections.Generic; +using Pulumi; +using Pulumi.Kubernetes.Types.Inputs.Helm.V3; +using Pulumi.Kubernetes.Helm.V3; + +class HelmStack : Stack +{ + public HelmStack() + { + var redis = new Release("redis", new ReleaseArgs + { + Chart = "redis", + RepositoryOpts = new RepositoryOptsArgs + { + Repo = "https://charts.bitnami.com/bitnami" + }, + Values = new InputMap + { + ["cluster"] = new Dictionary + { + ["enabled"] = true, + }, + ["rbac"] = new Dictionary + { + ["create"] = true, + } + }, + }); + + var status = redis.Status; + // srv will only resolve after the redis chart is installed. + var srv = Service.Get("redist-master-svc", Output.All(status).Apply( + s => $"{s[0].Namespace}/{s[0].Name}-master")); + this.RedisMasterClusterIP = srv.Spec.Apply(spec => spec.ClusterIP); + } + + [Output] + public Output RedisMasterClusterIP { get; set; } +} +``` +```go +package main + +import ( + "fmt" + + corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" + "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" + "github.com/pulumi/pulumi-random/sdk/v4/go/random" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + rel, err := helm.NewRelease(ctx, "redis", &helm.ReleaseArgs{ + Chart: pulumi.String("redis"), + RepositoryOpts: helm.RepositoryOptsArgs{ + Repo: pulumi.String("https://charts.bitnami.com/bitnami"), + }, + Values: pulumi.Map{ + "cluster": pulumi.Map{ + "enabled": pulumi.Bool(true), + }, + "rbac": pulumi.BoolMap{ + "create": pulumi.Bool(true), + }, + }, + }) + if err != nil { + return err + } + + // srv will only resolve after the redis chart is installed. + srv := pulumi.All(rel.Status.Namespace(), rel.Status.Name()). + ApplyT(func(r interface{}) (interface{}, error) { + arr := r.([]interface{}) + namespace := arr[0].(*string) + name := arr[1].(*string) + svc, err := corev1.GetService(ctx, + "redis-master-svc", + pulumi.ID(fmt.Sprintf("%s/%s-master", *namespace, *name)), + nil, + ) + if err != nil { + return "", nil + } + return svc.Spec.ClusterIP(), nil + }) + ctx.Export("redisMasterClusterIP", srv) + + return nil + }) +} +``` +{{% /example %}} +{{% /examples %}} + diff --git a/sdk/dotnet/Helm/V3/Release.cs b/sdk/dotnet/Helm/V3/Release.cs index 4a89c6395f..9b4cdec152 100644 --- a/sdk/dotnet/Helm/V3/Release.cs +++ b/sdk/dotnet/Helm/V3/Release.cs @@ -10,8 +10,237 @@ namespace Pulumi.Kubernetes.Helm.V3 { /// - /// A Release is an instance of a chart running in a Kubernetes cluster. - /// A Chart is a Helm package. It contains all the resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. + /// A `Release` is an instance of a chart running in a Kubernetes cluster. A `Chart` is a Helm package. It contains all the + /// resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. + /// + /// This resource models a Helm Release as if it were created by the Helm CLI. The underlying implementation embeds Helm as + /// a library to perform the orchestration of the resources. As a result, the full spectrum of Helm features are supported + /// natively. + /// + /// ## Example Usage + /// ### Local Chart Directory + /// ```csharp + /// using Pulumi; + /// using Pulumi.Kubernetes.Types.Inputs.Helm.V3; + /// using Pulumi.Kubernetes.Helm.V3; + /// + /// class HelmStack : Stack + /// { + /// public HelmStack() + /// { + /// var nginx = new Release("nginx-ingress", new ReleaseArgs + /// { + /// Chart = "./nginx-ingress", + /// }); + /// + /// } + /// } + /// ``` + /// ### Remote Chart + /// ```csharp + /// using Pulumi; + /// using Pulumi.Kubernetes.Types.Inputs.Helm.V3; + /// using Pulumi.Kubernetes.Helm.V3; + /// + /// class HelmStack : Stack + /// { + /// public HelmStack() + /// { + /// var nginx = new Release("nginx-ingress", new ReleaseArgs + /// { + /// Chart = "nginx-ingress", + /// Version = "1.24.4", + /// RepositoryOpts = new RepositoryOptsArgs + /// { + /// Repo = "https://charts.helm.sh/stable" + /// } + /// }); + /// + /// } + /// } + /// ``` + /// ### Set Chart Values + /// ```csharp + /// using System.Collections.Generic; + /// using Pulumi; + /// using Pulumi.Kubernetes.Types.Inputs.Helm.V3; + /// using Pulumi.Kubernetes.Helm.V3; + /// + /// class HelmStack : Stack + /// { + /// public HelmStack() + /// { + /// var values = new Dictionary<string, object> + /// { + /// ["controller"] = new Dictionary<string, object> + /// { + /// ["metrics"] = new Dictionary<string, object> + /// { + /// ["enabled"] = true + /// } + /// }, + /// }; + /// + /// var nginx = new Release("nginx-ingress", new ReleaseArgs + /// { + /// Chart = "nginx-ingress", + /// Version = "1.24.4", + /// RepositoryOpts = new RepositoryOptsArgs + /// { + /// Repo = "https://charts.helm.sh/stable" + /// }, + /// Values = values, + /// }); + /// + /// } + /// } + /// ``` + /// ### Deploy Chart into Namespace + /// ```csharp + /// using Pulumi; + /// using Pulumi.Kubernetes.Types.Inputs.Helm.V3; + /// using Pulumi.Kubernetes.Helm.V3; + /// + /// class HelmStack : Stack + /// { + /// public HelmStack() + /// { + /// var nginx = new Release("nginx-ingress", new ReleaseArgs + /// { + /// Chart = "nginx-ingress", + /// Version = "1.24.4", + /// Namespace = "test-namespace", + /// RepositoryOpts = new RepositoryOptsArgs + /// { + /// Repo = "https://charts.helm.sh/stable" + /// }, + /// }); + /// + /// } + /// } + /// ``` + /// + /// ### Depend on a Chart resource + /// ```csharp + /// using System.Threading.Tasks; + /// using Pulumi; + /// using Pulumi.Kubernetes.Core.V1; + /// using Pulumi.Kubernetes.Types.Inputs.Helm.V3; + /// using Pulumi.Kubernetes.Helm.V3; + /// + /// class HelmStack : Stack + /// { + /// public HelmStack() + /// { + /// var nginx = new Release("nginx-ingress", new ReleaseArgs + /// { + /// Chart = "nginx-ingress", + /// Version = "1.24.4", + /// Namespace = "test-namespace", + /// RepositoryOpts = new RepositoryOptsArgs + /// { + /// Repo = "https://charts.helm.sh/stable" + /// }, + /// SkipAwait = false, + /// }); + /// + /// // Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart + /// // resources are ready. Notice SkipAwait is set to false above. This is the default and will cause Helm + /// // to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away. + /// new ConfigMap("foo", new Pulumi.Kubernetes.Types.Inputs.Core.V1.ConfigMapArgs + /// { + /// Data = new InputMap<string> + /// { + /// {"foo", "bar"} + /// }, + /// }, new CustomResourceOptions + /// { + /// DependsOn = nginx, + /// }); + /// + /// } + /// } + /// ``` + /// ### Specify Helm Chart Values in File and Code + /// ```csharp + /// using System.Collections.Generic; + /// using Pulumi; + /// using Pulumi.Kubernetes.Types.Inputs.Helm.V3; + /// using Pulumi.Kubernetes.Helm.V3; + /// + /// class HelmStack : Stack + /// { + /// public HelmStack() + /// { + /// var nginx = new Release("redis", new ReleaseArgs + /// { + /// Chart = "redis", + /// RepositoryOpts = new RepositoryOptsArgs + /// { + /// Repo = "https://charts.bitnami.com/bitnami" + /// }, + /// ValueYamlFiles = new FileAsset("./metrics.yml"); + /// Values = new InputMap<object> + /// { + /// ["cluster"] = new Dictionary<string,object> + /// { + /// ["enabled"] = true, + /// }, + /// ["rbac"] = new Dictionary<string,object> + /// { + /// ["create"] = true, + /// } + /// }, + /// }); + /// } + /// } + /// + /// // -- Contents of metrics.yml -- + /// // metrics: + /// // enabled: true + /// ``` + /// ### Query Kubernetes Resource Installed By Helm Chart + /// ```csharp + /// using System.Collections.Generic; + /// using Pulumi; + /// using Pulumi.Kubernetes.Types.Inputs.Helm.V3; + /// using Pulumi.Kubernetes.Helm.V3; + /// + /// class HelmStack : Stack + /// { + /// public HelmStack() + /// { + /// var redis = new Release("redis", new ReleaseArgs + /// { + /// Chart = "redis", + /// RepositoryOpts = new RepositoryOptsArgs + /// { + /// Repo = "https://charts.bitnami.com/bitnami" + /// }, + /// Values = new InputMap<object> + /// { + /// ["cluster"] = new Dictionary<string,object> + /// { + /// ["enabled"] = true, + /// }, + /// ["rbac"] = new Dictionary<string,object> + /// { + /// ["create"] = true, + /// } + /// }, + /// }); + /// + /// var status = redis.Status; + /// // srv will only resolve after the redis chart is installed. + /// var srv = Service.Get("redist-master-svc", Output.All(status).Apply( + /// s => $"{s[0].Namespace}/{s[0].Name}-master")); + /// this.RedisMasterClusterIP = srv.Spec.Apply(spec => spec.ClusterIP); + /// } + /// + /// [Output] + /// public Output<string> RedisMasterClusterIP { get; set; } + /// } + /// ``` /// [KubernetesResourceType("kubernetes:helm.sh/v3:Release")] public partial class Release : KubernetesResource diff --git a/sdk/go/kubernetes/helm/v3/release.go b/sdk/go/kubernetes/helm/v3/release.go index b5846336ca..834999b2aa 100644 --- a/sdk/go/kubernetes/helm/v3/release.go +++ b/sdk/go/kubernetes/helm/v3/release.go @@ -11,8 +11,258 @@ import ( "github.com/pulumi/pulumi/sdk/v3/go/pulumi" ) -// A Release is an instance of a chart running in a Kubernetes cluster. -// A Chart is a Helm package. It contains all the resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. +// A `Release` is an instance of a chart running in a Kubernetes cluster. A `Chart` is a Helm package. It contains all the +// resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. +// +// This resource models a Helm Release as if it were created by the Helm CLI. The underlying implementation embeds Helm as +// a library to perform the orchestration of the resources. As a result, the full spectrum of Helm features are supported +// natively. +// +// ## Example Usage +// ### Local Chart Directory +// ```go +// package main +// +// "fmt" +// +// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" +// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +// +// func main() { +// pulumi.Run(func(ctx *pulumi.Context) error { +// _, err := helm.NewRelease(ctx, "nginx-ingress", helm.ReleaseArgs{ +// Chart: pulumi.String("./nginx-ingress"), +// }) +// if err != nil { +// return err +// } +// +// return nil +// }) +// } +// ``` +// ### Remote Chart +// ```go +// package main +// +// import ( +// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" +// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +// ) +// +// func main() { +// pulumi.Run(func(ctx *pulumi.Context) error { +// _, err := helm.NewRelease(ctx, "nginx-ingress", helm.ReleaseArgs{ +// Chart: pulumi.String("nginx-ingress"), +// Version: pulumi.String("1.24.4"), +// RepositoryOpts: helm.RepositoryOptsArgs{ +// Repo: pulumi.String("https://charts.helm.sh/stable"), +// }, +// }) +// if err != nil { +// return err +// } +// +// return nil +// }) +// } +// ``` +// ### Set Chart Values +// ```go +// package main +// +// import ( +// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" +// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +// ) +// +// func main() { +// pulumi.Run(func(ctx *pulumi.Context) error { +// _, err := helm.NewRelease(ctx, "nginx-ingress", helm.ReleaseArgs{ +// Chart: pulumi.String("nginx-ingress"), +// Version: pulumi.String("1.24.4"), +// RepositoryOpts: helm.RepositoryOptsArgs{ +// Repo: pulumi.String("https://charts.helm.sh/stable"), +// }, +// Values: pulumi.Map{ +// "controller": pulumi.Map{ +// "metrics": pulumi.Map{ +// "enabled": pulumi.Bool(true), +// }, +// }, +// }, +// }) +// if err != nil { +// return err +// } +// +// return nil +// }) +// } +// ``` +// ### Deploy Chart into Namespace +// ```go +// package main +// +// import ( +// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" +// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +// ) +// +// func main() { +// pulumi.Run(func(ctx *pulumi.Context) error { +// _, err := helm.NewRelease(ctx, "nginx-ingress", helm.ReleaseArgs{ +// Chart: pulumi.String("nginx-ingress"), +// Version: pulumi.String("1.24.4"), +// Namespace: pulumi.String("test-namespace"), +// RepositoryOpts: helm.RepositoryOptsArgs{ +// Repo: pulumi.String("https://charts.helm.sh/stable"), +// }, +// }) +// if err != nil { +// return err +// } +// +// return nil +// }) +// } +// ``` +// +// ### Depend on a Chart resource +// ```go +// package main +// +// import ( +// corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" +// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" +// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +// ) +// +// func main() { +// pulumi.Run(func(ctx *pulumi.Context) error { +// release, err := helm.NewRelease(ctx, "nginx-ingress", helm.ReleaseArgs{ +// Chart: pulumi.String("nginx-ingress"), +// Version: pulumi.String("1.24.4"), +// Namespace: pulumi.String("test-namespace"), +// RepositoryOpts: helm.RepositoryOptsArgs{ +// Repo: pulumi.String("https://charts.helm.sh/stable"), +// }, +// SkipAwait: pulumi.Bool(false), +// }) +// if err != nil { +// return err +// } +// +// // Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart +// // resources are ready. Notice SkipAwait is set to false above. This is the default and will cause Helm +// // to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away. +// _, err = corev1.NewConfigMap(ctx, "cm", &corev1.ConfigMapArgs{ +// Data: pulumi.StringMap{ +// "foo": pulumi.String("bar"), +// }, +// }, pulumi.DependsOnInputs(release)) +// if err != nil { +// return err +// } +// +// return nil +// }) +// } +// ``` +// ### Specify Helm Chart Values in File and Code +// ```go +// package main +// +// import ( +// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" +// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/yaml" +// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +// ) +// +// func main() { +// pulumi.Run(func(ctx *pulumi.Context) error { +// _, err := helm.NewRelease(ctx, "redis", helm.ReleaseArgs{ +// Chart: pulumi.String("redis"), +// RepositoryOpts: helm.RepositoryOptsArgs{ +// Repo: pulumi.String("https://charts.helm.sh/stable"), +// }, +// ValueYamlFiles: pulumi.NewFileAsset("./metrics.yml"), +// Value: pulumi.Map{ +// "cluster": pulumi.Map{ +// "enabled": pulumi.Bool(true), +// }, +// "rbac": pulumi.Map{ +// "create": pulumi.Bool(true), +// }, +// }, +// }) +// if err != nil { +// return err +// } +// +// return nil +// }) +// } +// +// // -- Contents of metrics.yml -- +// // metrics: +// // enabled: true +// ``` +// ### Query Kubernetes Resource Installed By Helm Chart +// ```go +// package main +// +// import ( +// "fmt" +// +// corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" +// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" +// "github.com/pulumi/pulumi-random/sdk/v4/go/random" +// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +// ) +// +// func main() { +// pulumi.Run(func(ctx *pulumi.Context) error { +// rel, err := helm.NewRelease(ctx, "redis", &helm.ReleaseArgs{ +// Chart: pulumi.String("redis"), +// RepositoryOpts: helm.RepositoryOptsArgs{ +// Repo: pulumi.String("https://charts.bitnami.com/bitnami"), +// }, +// Values: pulumi.Map{ +// "cluster": pulumi.Map{ +// "enabled": pulumi.Bool(true), +// }, +// "rbac": pulumi.BoolMap{ +// "create": pulumi.Bool(true), +// }, +// }, +// }) +// if err != nil { +// return err +// } +// +// // srv will only resolve after the redis chart is installed. +// srv := pulumi.All(rel.Status.Namespace(), rel.Status.Name()). +// ApplyT(func(r interface{}) (interface{}, error) { +// arr := r.([]interface{}) +// namespace := arr[0].(*string) +// name := arr[1].(*string) +// svc, err := corev1.GetService(ctx, +// "redis-master-svc", +// pulumi.ID(fmt.Sprintf("%s/%s-master", *namespace, *name)), +// nil, +// ) +// if err != nil { +// return "", nil +// } +// return svc.Spec.ClusterIP(), nil +// }) +// ctx.Export("redisMasterClusterIP", srv) +// +// return nil +// }) +// } +// ``` type Release struct { pulumi.CustomResourceState diff --git a/sdk/nodejs/helm/v3/release.ts b/sdk/nodejs/helm/v3/release.ts index d254aabadf..6dfdfb6494 100644 --- a/sdk/nodejs/helm/v3/release.ts +++ b/sdk/nodejs/helm/v3/release.ts @@ -6,8 +6,147 @@ import { input as inputs, output as outputs, enums } from "../../types"; import * as utilities from "../../utilities"; /** - * A Release is an instance of a chart running in a Kubernetes cluster. - * A Chart is a Helm package. It contains all the resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. + * A `Release` is an instance of a chart running in a Kubernetes cluster. A `Chart` is a Helm package. It contains all the + * resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. + * + * This resource models a Helm Release as if it were created by the Helm CLI. The underlying implementation embeds Helm as + * a library to perform the orchestration of the resources. As a result, the full spectrum of Helm features are supported + * natively. + * + * ## Example Usage + * ### Local Chart Directory + * + * ```typescript + * import * as k8s from "@pulumi/kubernetes"; + * + * const nginxIngress = new k8s.helm.v3.Release("nginx-ingress", { + * chart: "./nginx-ingress", + * }); + * ``` + * ### Remote Chart + * + * ```typescript + * import * as k8s from "@pulumi/kubernetes"; + * + * const nginxIngress = new k8s.helm.v3.Release("nginx-ingress", { + * chart: "nginx-ingress", + * version: "1.24.4", + * repositoryOpts: { + * repo: "https://charts.helm.sh/stable", + * }, + * }); + * ``` + * ### Set Chart Values + * + * ```typescript + * import * as k8s from "@pulumi/kubernetes"; + * + * const nginxIngress = new k8s.helm.v3.Release("nginx-ingress", { + * chart: "nginx-ingress", + * version: "1.24.4", + * repositoryOpts: { + * repo: "https://charts.helm.sh/stable", + * }, + * values: { + * controller: { + * metrics: { + * enabled: true, + * } + * } + * }, + * }); + * ``` + * ### Deploy Chart into Namespace + * + * ```typescript + * import * as k8s from "@pulumi/kubernetes"; + * + * const nginxIngress = new k8s.helm.v3.Release("nginx-ingress", { + * chart: "nginx-ingress", + * version: "1.24.4", + * namespace: "test-namespace", + * repositoryOpts: { + * repo: "https://charts.helm.sh/stable", + * }, + * }); + * ``` + * + * ### Depend on a Chart resource + * + * ```typescript + * import * as k8s from "@pulumi/kubernetes"; + * + * const nginxIngress = new k8s.helm.v3.Release("nginx-ingress", { + * chart: "nginx-ingress", + * version: "1.24.4", + * namespace: "test-namespace", + * repositoryOpts: { + * repo: "https://charts.helm.sh/stable", + * }, + * skipAwait: false, + * }); + * + * // Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart + * // resources are ready. Notice skipAwait is set to false above. This is the default and will cause Helm + * // to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away. + * new k8s.core.v1.ConfigMap("foo", { + * metadata: {namespace: namespaceName}, + * data: {foo: "bar"} + * }, {dependsOn: nginxIngress}) + * ``` + * ### Specify Helm Chart Values in File and Code + * + * ```typescript + * import * as pulumi from "@pulumi/pulumi"; + * import * as k8s from "@pulumi/kubernetes"; + * import {FileAsset} from "@pulumi/pulumi/asset"; + * + * const release = new k8s.helm.v3.Release("redis", { + * chart: "redis", + * repositoryOpts: { + * repo: "https://charts.bitnami.com/bitnami", + * }, + * valueYamlFiles: [new FileAsset("./metrics.yml")], + * values: { + * cluster: { + * enabled: true, + * }, + * rbac: { + * create: true, + * } + * }, + * }); + * + * // -- Contents of metrics.yml -- + * // metrics: + * // enabled: true + * ``` + * ### Query Kubernetes Resource Installed By Helm Chart + * + * ```typescript + * import * as pulumi from "@pulumi/pulumi"; + * import * as k8s from "@pulumi/kubernetes"; + * import {FileAsset} from "@pulumi/pulumi/asset"; + * + * const redis = new k8s.helm.v3.Release("redis", { + * chart: "redis", + * repositoryOpts: { + * repo: "https://charts.bitnami.com/bitnami", + * }, + * values: { + * cluster: { + * enabled: true, + * }, + * rbac: { + * create: true, + * } + * }, + * }); + * + * // srv will only resolve after the redis chart is installed. + * const srv = k8s.core.v1.Service.get("redis-master-svc", pulumi.interpolate`${redis.status.namespace}/${redis.status.name}-master`); + * export const redisMasterClusterIP = srv.spec.clusterIP; + * ``` */ export class Release extends pulumi.CustomResource { /** diff --git a/sdk/python/pulumi_kubernetes/helm/v3/Release.py b/sdk/python/pulumi_kubernetes/helm/v3/Release.py index 0190a4c9e7..efe1806228 100644 --- a/sdk/python/pulumi_kubernetes/helm/v3/Release.py +++ b/sdk/python/pulumi_kubernetes/helm/v3/Release.py @@ -600,8 +600,159 @@ def __init__(__self__, wait_for_jobs: Optional[pulumi.Input[bool]] = None, __props__=None): """ - A Release is an instance of a chart running in a Kubernetes cluster. - A Chart is a Helm package. It contains all the resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. + A `Release` is an instance of a chart running in a Kubernetes cluster. A `Chart` is a Helm package. It contains all the + resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. + + This resource models a Helm Release as if it were created by the Helm CLI. The underlying implementation embeds Helm as + a library to perform the orchestration of the resources. As a result, the full spectrum of Helm features are supported + natively. + + ## Example Usage + ### Local Chart Directory + ```python + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs + + nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="./nginx-ingress", + ), + ) + ``` + ### Remote Chart + ```python + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + ), + ) + ``` + ### Set Chart Values + ```python + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + values={ + "controller": { + "metrics": { + "enabled": True, + }, + }, + }, + ), + ) + ``` + ### Deploy Chart into Namespace + ```python + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + namespace="test-namespace", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + ), + ) + ``` + + ### Depend on a Chart resource + ```python + import pulumi + from pulumi_kubernetes.core.v1 import ConfigMap, ConfigMapInitArgs + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + namespace="test-namespace", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + skip_await=False, + ), + ) + + # Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart + # resources are ready. Notice skip_await is set to false above. This is the default and will cause Helm + # to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away. + ConfigMap("foo", ConfigMapInitArgs(data={"foo": "bar"}), opts=pulumi.ResourceOptions(depends_on=nginx_ingress)) + ``` + ### Specify Helm Chart Values in File and Code + ```python + import pulumi + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + nginx_ingress = Release( + "redis", + ReleaseArgs( + chart="redis", + repository_opts=RepositoryOptsArgs( + repo="https://charts.bitnami.com/bitnami", + ), + value_yaml_files=pulumi.FileAsset("./metrics.yml"), + values={ + cluster: { + enabled: true, + }, + rbac: { + create: true, + } + }, + ), + ) + + # -- Contents of metrics.yml -- + # metrics: + # enabled: true + ``` + ### Query Kubernetes Resource Installed By Helm Chart + ```python + from pulumi import Output + from pulumi_kubernetes.core.v1 import Service + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + redis = Release( + "redis", + ReleaseArgs( + chart="redis", + repository_opts=RepositoryOptsArgs( + repo="https://charts.bitnami.com/bitnami", + ), + values={ + "cluster": { + "enabled": True, + }, + "rbac": { + "create": True, + } + }, + ), + ) + + # srv will only resolve after the redis chart is installed. + srv = Service.get("redis-master-svc", Output.concat(redis.status.namespace, "/", redis.status.name, "-master")) + pulumi.export("redisMasterClusterIP", srv.spec.cluster_ip) + ``` :param str resource_name: The name of the resource. :param pulumi.ResourceOptions opts: Options for the resource. @@ -646,8 +797,159 @@ def __init__(__self__, args: ReleaseArgs, opts: Optional[pulumi.ResourceOptions] = None): """ - A Release is an instance of a chart running in a Kubernetes cluster. - A Chart is a Helm package. It contains all the resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. + A `Release` is an instance of a chart running in a Kubernetes cluster. A `Chart` is a Helm package. It contains all the + resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. + + This resource models a Helm Release as if it were created by the Helm CLI. The underlying implementation embeds Helm as + a library to perform the orchestration of the resources. As a result, the full spectrum of Helm features are supported + natively. + + ## Example Usage + ### Local Chart Directory + ```python + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs + + nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="./nginx-ingress", + ), + ) + ``` + ### Remote Chart + ```python + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + ), + ) + ``` + ### Set Chart Values + ```python + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + values={ + "controller": { + "metrics": { + "enabled": True, + }, + }, + }, + ), + ) + ``` + ### Deploy Chart into Namespace + ```python + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + namespace="test-namespace", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + ), + ) + ``` + + ### Depend on a Chart resource + ```python + import pulumi + from pulumi_kubernetes.core.v1 import ConfigMap, ConfigMapInitArgs + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + nginx_ingress = Release( + "nginx-ingress", + ReleaseArgs( + chart="nginx-ingress", + version="1.24.4", + namespace="test-namespace", + repository_opts=RepositoryOptsArgs( + repo="https://charts.helm.sh/stable", + ), + skip_await=False, + ), + ) + + # Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart + # resources are ready. Notice skip_await is set to false above. This is the default and will cause Helm + # to await the underlying resources to be available. Setting it to true will make the ConfigMap available right away. + ConfigMap("foo", ConfigMapInitArgs(data={"foo": "bar"}), opts=pulumi.ResourceOptions(depends_on=nginx_ingress)) + ``` + ### Specify Helm Chart Values in File and Code + ```python + import pulumi + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + nginx_ingress = Release( + "redis", + ReleaseArgs( + chart="redis", + repository_opts=RepositoryOptsArgs( + repo="https://charts.bitnami.com/bitnami", + ), + value_yaml_files=pulumi.FileAsset("./metrics.yml"), + values={ + cluster: { + enabled: true, + }, + rbac: { + create: true, + } + }, + ), + ) + + # -- Contents of metrics.yml -- + # metrics: + # enabled: true + ``` + ### Query Kubernetes Resource Installed By Helm Chart + ```python + from pulumi import Output + from pulumi_kubernetes.core.v1 import Service + from pulumi_kubernetes.helm.v3 import Release, ReleaseArgs, RepositoryOptsArgs + + redis = Release( + "redis", + ReleaseArgs( + chart="redis", + repository_opts=RepositoryOptsArgs( + repo="https://charts.bitnami.com/bitnami", + ), + values={ + "cluster": { + "enabled": True, + }, + "rbac": { + "create": True, + } + }, + ), + ) + + # srv will only resolve after the redis chart is installed. + srv = Service.get("redis-master-svc", Output.concat(redis.status.namespace, "/", redis.status.name, "-master")) + pulumi.export("redisMasterClusterIP", srv.spec.cluster_ip) + ``` :param str resource_name: The name of the resource. :param ReleaseArgs args: The arguments to use to populate this resource's properties.