I am new to Pulumi and working with k8s modules, ...
# kubernetes
n
I am new to Pulumi and working with k8s modules, ran into an issue with the kubernetescore/v1NamespaceList package. I am receiving the message: Type Name Plan Info + pulumipulumiStack kubernetes-namespace-list-dev create └─ kubernetescore/v1NamespaceList myNamespaceList 1 error Diagnostics: kubernetescore/v1NamespaceList (myNamespaceList): error: list resources exist for compatibility with YAML manifests and Helm charts, and cannot be created directly. Use the underlying resource type instead I have been trying to google the issue but no luck, has anybody seen this before ?
h
are you maybe trying to create a
kubernetes:core/v1:Namespace
?
n
I was trying to capture a list of existing namespaces, I tried to filter down to a single namespace as a test but no luck. I was able to use the namespace package to create a namespace and that seems to work. I have been pulling examples from pulumi AI
My latest try: import * as pulumi from "@pulumi/pulumi"; import * as kubernetes from "@pulumi/kubernetes"; const namespaceList = new kubernetes.core.v1.NamespaceList("myNamespaceList", { items: [ { metadata: { name: "namespace1", labels: { "env": "dev", }, }, }, { metadata: { name: "namespace2", labels: { "env": "prod", }, }, }, ], }); npm list k8stest ├── @pulumi/kubernetes@4.18.3 ├── @pulumi/pulumi@3.140.0 ├── @types/nodemailer@6.4.17 ├── ldapts@7.2.1 ├── nodemailer@6.9.16 └── punycode@2.3.1 Node version: 20.5.1 But still receive: error: list resources exist for compatibility with YAML manifests and Helm charts, and cannot be created directly. Use the underlying resource type instead
h
why are you trying to get a list of namespaces?
n
at times we will need apply setting(s) to namespaces, figure this is an easier means vs reading a file for a list of namespaces. I assumed the purpose of the NamespaceList package was to generate a list of namespaces ?
h
you can use a NamespacePatch object to modify existing namespaces. pulumi is declarative in the sense that it only knows about the resources you’ve defined (roughly speaking). if you need to query resources you can use a k8s client.
n
so to understand, when it comes to listing namespaces it has to related to ones that have been created via pulumi. So regarding using the k8s client I would use some type of "command" type package ?
h
i would recommend using a k8s client for whatever language you’re working in, but you’re free to generate the list any way you want