https://pulumi.com logo
#kubernetes
Title
# kubernetes
m

many-psychiatrist-74327

08/26/2020, 11:33 PM
👋 hello! New pulumi user here. Quick question on
ConfigFile
. I’m trying to deploy some existing k8s yaml objects with Pulumi/Python. I’m creating a
k8s.yaml.ConfigFile
from my file as shown in this tutorial. However, the tutorial then suggests querying the resources inside the ConfigFile by calling `get_resource(type, name)`[0]. but that function doesn’t exist. Is there a way to “query” the resources inside the ConfigFile in Python? [0] Code snippet:
Copy code
guestbook = k8s.yaml.ConfigFile('guestbook', 'guestbook-all-in-one.yaml')
# Export the private cluster IP address of the frontend.
frontend = guestbook.get_resource('v1/Service', 'frontend')  # <- fails
g

gorgeous-egg-16927

08/27/2020, 7:02 PM
The
get_resource
method should be the way to go. Perhaps you’re using the wrong name for the Service? You can also directly access the
resources
property on that
ConfigFile
class. You can see the implementation of that method here: https://github.com/pulumi/pulumi-kubernetes/blob/d9e686f4f9d6996e3eee3fece902d29a226bcf49/sdk/python/pulumi_kubernetes/yaml.py#L344-L363
m

many-psychiatrist-74327

08/27/2020, 7:10 PM
huh, that’s really weird.. the error I get is that the method
get_resource
doesn’t exist on the ConfigFile, not that it’s not finding the resource I’m querying for… Let me paste my entire code snippet, maybe I’m doing something stupid
Very odd.. it just worked this time 😕
well, thank you very much for the help, @gorgeous-egg-16927! I don’t really know what I was doing wrong before, but I’m glad it works now, and now I know to look at the source code when in doubt
👍 1
3 Views