-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add check to see if druid is running in kubernetes #17697
base: master
Are you sure you want to change the base?
Conversation
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.
Hmm, why change the name of the variable?
I see that #16386 changed it from DRUID_SET_HOST
to DRUID_SET_HOST_IP
. I don't see discussion in that PR about why, but changing it back and forth makes it tougher for users to understand what version uses what variable name. IMO better to stick with DRUID_SET_HOST_IP
given it was already released that way in Druid 31.
distribution/docker/druid.sh
Outdated
DRUID_SET_HOST=${DRUID_SET_HOST:-1} | ||
else | ||
# Running in kubernetes | ||
DRUID_SET_HOST=${DRUID_SET_HOST:-0} |
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.
Please include a comment about why the default is different inside and outside of k8s.
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.
Added
distribution/docker/druid.sh
Outdated
@@ -138,8 +138,15 @@ then | |||
setKey _common druid.zk.service.host "${ZOOKEEPER}" | |||
fi | |||
|
|||
DRUID_SET_HOST_IP=${DRUID_SET_HOST_IP:-0} | |||
if [ "${DRUID_SET_HOST_IP}" = "1" ] | |||
if [ -z ${KUBERNETES_SERVICE_HOST} ] |
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.
Use [ -z "${KUBERNETES_SERVICE_HOST}" ]
instead, it will work better if the variable has whitespace in it. Unlikely but still a good practice with shell scripting.
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.
Changed!
The PR #16386 changed the docker file to use the canonical hostname instead of ip by default. This was an attempt to fix
druid.indexer.task.restoreTasksOnRestart
, as it does not work on kubernetes without the canonical hostname.This change is not backward compatible, as switching to canonical names would not work with docker. This PR attempts to fix this by adding a check to see if the deployment is in a kubernetes environment by checking
${KUBERNETES_SERVICE_HOST}
and using canonical hostnames instead of IP addresses only in that case.This PR has: