Anyone have tips for getting a reference to a Kube...
# python
c
Anyone have tips for getting a reference to a Kubernetes Pod created by a deployment? The Pod's name isn't known, so core.v1.Pod.get doesn't seem like it will work.
Neither the Deployment nor its ReplicaSet seem to contain refernences to the names.
g
Can you give some more details about what you’re trying to accomplish?
c
I have a fiddly deploy step where I need to create a Deployment, then port-forward into one of the Pods it creates to finish configuring the software.
g
What are you using to do the port-forwarding? kubectl?
c
Yes, since the Python kubernetes client doesn't support it yet.
g
Ok, then I’d suggest using the selector to find the Pod(s) rather than using the name directly
c
kubectl port-forward
doesn't support
-l
.
g
You can do something like
Copy code
kubectl get pods --selector=app=cassandra
to list all matching pods, and could further filter that down as needed
c
Yes, definitely an option. I was wondering if there was a Pulumi-native way to do it.
g
Well, if you figure out the correct kubectl incantation, you should be able to shell out to it from within a pulumi program and then use that output
Or use a k8s client for python
That scenario is currently a bit outside of our main workflow, but feel free to open an issue on https://github.com/pulumi/pulumi-kubernetes/issues if you want to provide more details on your use case.
kubectl get pods --selector=tier=frontend -o jsonpath='{.items[0].metadata.name}'
will get you just the pod name