I would like to have a command that gets the name of a pod and then uses it to log in to the pod. The command to list the pods to get the pod name:
kubectl get pods | Select-String -Pattern "mypodname"
The output is:
mypodname 1/1 Running 0 4d3h
I need to only get the value mypodname here. I have tried with Select-Object NAME with no luck. The podname changes over time. For example it can be mypodname-3467gogsfg one day and mypodname-043086dndn the next day because of new deployment.
This value I will use in this command:
kubectl --server=https://myservername.com --insecure-skip-tls-verify exec -it <name of pod goes here> /bin/sh
The second question is how these two can be combined in a windows powershell script so I can run something like this to log in to the pod:
podlogin mypodname