https://pulumi.com logo
Title
l

lively-needle-84406

10/05/2022, 3:02 PM
Hey all, I am having issues creating a namespace and referencing that namespace name while using the kubernetes.core.v1.Namespace (kubernetes provider). The namespace name I want is
istio-system
, but a randomly generated string gets appended to the name. Is there a way to specify a specific name for a namespace when using
new kubernetes.core.v1.Namespace
?
const istioNamespaceName = "istio-system"

const istioNamespace = new k8s.core.v1.Namespace(istioNamespaceName);

const istioVersion = "1.15.0";

const istioBase = new k8s.helm.v3.Chart("istio-base", {
    chart: "base",
    version: istioVersion,
    namespace: istioNamespaceName,
    fetchOpts: {
        repo: "<https://istio-release.storage.googleapis.com/charts>",
    },
}, {
    dependsOn: istioNamespace
});
b

billowy-army-68599

10/05/2022, 3:06 PM
const istioNamespace = new k8s.core.v1.Namespace(istioNamespaceName, {
  metadata: {
    name: "istio-system
  }
});
you need to explicitly define the namespace name
then
const istioBase = new k8s.helm.v3.Chart("istio-base", {
    chart: "base",
    version: istioVersion,
    namespace: istioNamespace.metadata.name,
    fetchOpts: {
        repo: "<https://istio-release.storage.googleapis.com/charts>",
    },
}, {
    dependsOn: istioNamespace
});
To reference it
l

lively-needle-84406

10/05/2022, 3:07 PM
Thank you @billowy-army-68599! This is exactly what I was looking for, but couldn't find it in the docs!
s

steep-toddler-94095

10/05/2022, 5:29 PM
in general, if any resource has a property that lets you assign it a name and it's left blank, pulumi will generate the name based on the pulumi resource name appended with some random characters.
🙌 1