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

Error in "Using Source IP" tutorial #48828

Open
habib-source opened this issue Nov 24, 2024 · 6 comments
Open

Error in "Using Source IP" tutorial #48828

habib-source opened this issue Nov 24, 2024 · 6 comments
Labels
language/en Issues or PRs related to English language needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.

Comments

@habib-source
Copy link

habib-source commented Nov 24, 2024

https://kubernetes.io/docs/tutorials/services/source-ip/
in the Source IP for Services with Type=NodePort section

NODES=$(kubectl get nodes -o jsonpath='{ $.items[*].status.addresses[?(@.type=="InternalIP")].address }')

This will return a single string of a list of IP address.
The right form is :

NODES=($(kubectl get nodes -o jsonpath='{ $.items[*].status.addresses[?(@.type=="InternalIP")].address }'))

Wish will return an array of strings of IP address.
So this function work correctly :

for node in $NODES; do curl -s $node:$NODEPORT | grep -i client_address; done

Here, NODES are expected to be an array, not a single string.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Nov 24, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG Docs takes a lead on issue triage for this website, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@dipesh-rawat
Copy link
Member

Page reported in issue: https://kubernetes.io/docs/tutorials/services/source-ip/
/language en

@k8s-ci-robot k8s-ci-robot added the language/en Issues or PRs related to English language label Nov 25, 2024
@iheartNathan
Copy link
Contributor

image
The current command works.

@habib-source
Copy link
Author

pic-selected-241125-0553-36

@sftim
Copy link
Contributor

sftim commented Nov 25, 2024

/retitle Error in "Using Source IP" tutorial

/priority awaiting-more-evidence

We've assumed a POSIX shell. Can you show that the current command doesn't work with a POSIX shell @habib-source?

@k8s-ci-robot k8s-ci-robot changed the title Using Source IP Error in "Using Source IP" tutorial Nov 25, 2024
@k8s-ci-robot k8s-ci-robot added the priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. label Nov 25, 2024
@habib-source
Copy link
Author

In the previous comment I used zsh that's why it didn't work I've just uses bash and it works :
ZSH:
Does not work:

NODES=$(kubectl get nodes -o jsonpath='{ $.items[*].status.addresses[?(@.type=="InternalIP")].address }')

Work:

NODES=($(kubectl get nodes -o jsonpath='{ $.items[*].status.addresses[?(@.type=="InternalIP")].address }'))

Bash:
Work:

NODES=$(kubectl get nodes -o jsonpath='{ $.items[*].status.addresses[?(@.type=="InternalIP")].address }')

Does not work:

NODES=($(kubectl get nodes -o jsonpath='{ $.items[*].status.addresses[?(@.type=="InternalIP")].address }'))

I did not think that there was a difference between zsh and bash when it comes to syntax, I will consider this next time.
Thanks sftim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/en Issues or PRs related to English language needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.
Projects
None yet
Development

No branches or pull requests

5 participants