Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: fix jsonpath for pod name #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dhij
Copy link

@dhij dhij commented May 12, 2023

-ojsonpath='{.items[0].metadata.name}' gave me a pod name for cilium so I was thinking we could use this approach or sort by .metadata.creationTimestamp before choosing items[0]

@dhij dhij requested a review from timoreimann May 12, 2023 12:13
@@ -29,7 +29,7 @@ If you know the specific node name that you're interested in, you can exec into

```bash
NODE_NAME="my-node-name"
POD_NAME=$(kubectl -n kube-system get pods --field-selector spec.nodeName=${NODE_NAME} -ojsonpath='{.items[0].metadata.name}')
POD_NAME=$(kubectl -n kube-system get pods --field-selector spec.nodeName=${NODE_NAME} -ojsonpath='{.items[?(@.metadata.labels.name=="doks-debug")].metadata.name}')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better approach is to use the label that should uniquely identify doks-debug.

Personally, I generally prefer using custom columns over dealing with JSON whenever I can, so this is how I'd go about it:

POD_NAME=$(kubectl get pod -l name=doks-debug --field-selector spec.nodeName=${NODE_NAME} --no-headers -o custom-columns=:.metadata.name)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhij could you check in on that? Take care to add -n kube-system still if you use Timo's command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants