-
Notifications
You must be signed in to change notification settings - Fork 1k
Interpret KUBERNETES_SERVICE_HOST as hostname if not parsed as IP address #2285
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
Conversation
…ress This allows correctly connecting to the Kubernetes API when the service host is set as a hostname. This is at least the case on gardener.cloud . I'm running the patched version in production. Related to zalando#2047 which describes the same problem I had.
else | ||
echo "Unrecognized IP format '$KUBERNETES_SERVICE_HOST'" | ||
echo "KUBERNETES_SERVICE_HOST was not set" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you align the indentation? If I look at the rest of the file it seems 4 spaces are used more :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll reindent the entire file, because it's 2, 4 or 6 spaces, and that bothers me now that you mentioned it ;).
if [ "$KUBERNETES_SERVICE_HOST" != "${KUBERNETES_SERVICE_HOST#*[0-9].[0-9]}" ]; then | ||
echo "IPv4" | ||
K8S_API_URL=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT/api/v1 | ||
elif [ "$KUBERNETES_SERVICE_HOST" != "${KUBERNETES_SERVICE_HOST#*:[0-9a-fA-F]}" ]; then | ||
echo "IPv6" | ||
K8S_API_URL=https://[$KUBERNETES_SERVICE_HOST]:$KUBERNETES_SERVICE_PORT/api/v1 | ||
elif [ -n "$KUBERNETES_SERVICE_HOST" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-n is null check, right? Isn't -z better because it's checks null and not set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because that arm checks if there is any value in KUBERNETES_SERVICE_HOST, and uses it as a hostname. I wanted to print a message when KUBERNETES_SERVICE_HOST was not set, for instance when someone want to set K8S_API_URL directly.
👍 |
1 similar comment
👍 |
This allows correctly connecting to the Kubernetes API when the service host is set as a hostname. This is at least the case on gardener.cloud . I'm running the patched version in production.
Related to #2047 which describes the same problem I had.