https://pulumi.com logo
Title
c

cuddly-carpenter-20638

04/30/2021, 12:07 AM
"use strict";
const k8s = require("@pulumi/kubernetes");

const appLabels = { app: "nginx" };
const deployment = new k8s.apps.v1.Deployment("nginx", {
    spec: {
        selector: { matchLabels: appLabels },
        replicas: 1,
        template: {
            metadata: { labels: appLabels },
            spec: { containers: [{ name: "nginx", image: "nginx:alpine" }] }
        }
    }
});
exports.name = deployment.metadata.name;
c

colossal-australia-65039

04/30/2021, 12:09 AM
you need to specify the namespace in your deployment
const deployment = new k8s.apps.v1.Deployment("nginx", {
    metadata: {
      namespace: "pulumi-starter"
    },
    spec: {
        selector: { matchLabels: appLabels },
        replicas: 1,
        template: {
            metadata: { labels: appLabels },
            spec: { containers: [{ name: "nginx", image: "nginx:alpine" }] }
        }
    }
});
or if you created the namespace with pulumi you could use
namespaceVariableName.metadata.name
instead of a hardcoded string
c

cuddly-carpenter-20638

04/30/2021, 12:12 AM
Ah, I had tried adding the ns earlier in the code but it didn’t somehow work. It seems to have triggered now. Apologies for the lame question 🤦‍♂️
🙂 1