Hi. Is Pulumi capable of querying k8s resources, a...
# kubernetes
d
Hi. Is Pulumi capable of querying k8s resources, and not just declare new ones? More specifically, is there a way to query the list of EndpointSlices in a namespace? https://github.com/pulumi/pulumi-kubernetes/issues/3303
m
I think the solution you mention in the issue (using the Kubernetes SDK for your programming language of choice) is the way to go here. Fetch the information you need and pass it to the Pulumi resource.
Do you see any downsides with this approach?
d
No, I guess not. It's just that it isn't obvious to new users and it sounds like it would result in a bit of duplication of queries. What I had to do is query the resource name, then retrieve the
EndpointSlice
a second time using
EndpointSlice.get()
(this time using Pulumi) because otherwise the fields have different types in k8s's API and pulumi.
m
Based on my current understanding I think it makes sense that Pulumi does not provide a general-purpose query functionality but can only "get" a uniquely identified resource. I'd also claim that being able to use the standard k8s SDK within a Pulumi program is an advantage of writing IaC in general-purpose programming languages, rather than a hurdle one has to overcome.
That said, i agree that it's not super obvious when first starting out that this is "allowed" and desired.
d
That's fine. Just not obvious to new users. This isn't the first time I dive into using Pulumi and every time I get caught by this (looking for ways to do something in Pulumi that simply does not exist, requiring the use of an external API). I wish there was an easier way to determine if something requires the use of an external API or not. And the documentation should really explicitly state this somehow (that you are meant to use external APIs alongside Pulumi even when accessing the same resources from both libraries).
Pulumi's biggest problem, as you probably well know, is the ghost town of a community. It's very very hard to find any sort of help online.
m
In my mental model Pulumi exclusively deals with identifiable resources. Everything else has to come from somewhere else.
d
Makes sense..