https://pulumi.com logo
Title
r

ripe-oil-46657

06/17/2021, 3:15 PM
Hi Pulumi community! quick question: is there a way to implement the
helm3 --create-namespace
argument in the
helm.NewChart
function in Go? I would like to create a new namespace as part of the chart deployment.
b

billowy-army-68599

06/17/2021, 6:06 PM
in this case, you'd just create a namespace and pass it as a paramter to your helm chart, which language sdk are you using?
r

ripe-oil-46657

06/17/2021, 6:36 PM
Thanks, using Go. Using
corev1.NewNamespace
and then grabbing the autogenerated name of the new namespace in string format as input for the
helm.NewChart
doesn't appear to be trivial, so any guidance would be much appreciated.
b

bored-table-20691

06/17/2021, 6:43 PM
@ripe-oil-46657 to give a short example:
_, err = helmv3.NewChart(ctx, "superset", helmv3.ChartArgs{
		Repo:      pulumi.String("superset"),
		Chart:     pulumi.String("superset"),
		Namespace: ns.Metadata.Name().Elem().ToStringOutput(),
		FetchArgs: helmv3.FetchArgs{
			Repo: pulumi.String("<https://apache.github.io/superset>"),
		},
        ...
	}, pulumi.Provider(k8sProvider))
b

billowy-army-68599

06/17/2021, 6:48 PM
something like this:
ns, err := corev1.NewNamespace(ctx, "nginx-ingess", &corev1.NamespaceArgs{
			Metadata: &metav1.ObjectMetaArgs{
				Name: pulumi.String("nginx-ingress"),
			},
		})

		// Helm chart
		_, err = helm.NewChart(ctx, "test", helm.ChartArgs{
			Chart:   pulumi.String("stable/nginx-ingress"),
			Namespace: ns.Metadata.Name().Elem(),
			Version: pulumi.String("1.36.3"),
		}, pulumi.Provider(provider))
r

ripe-oil-46657

06/17/2021, 6:59 PM
@bored-table-20691, @billowy-army-68599 brilliant, it is trivial if your know what you are doing! 😉 Both examples work, many thanks for the help!