This is an automated email from the ASF dual-hosted git repository.
karan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new d40cf148dad Add check to see if druid is running in kubernetes (#17697)
d40cf148dad is described below
commit d40cf148dadd44d58bd8223daad82ff71a7a65f2
Author: Adarsh Sanjeev <[email protected]>
AuthorDate: Fri Feb 14 14:06:40 2025 +0530
Add check to see if druid is running in kubernetes (#17697)
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.
---
distribution/docker/druid.sh | 12 ++++++++++--
distribution/docker/peon.sh | 12 ++++++++++--
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/distribution/docker/druid.sh b/distribution/docker/druid.sh
index 35f04c93566..bb5c1362ac1 100755
--- a/distribution/docker/druid.sh
+++ b/distribution/docker/druid.sh
@@ -138,8 +138,16 @@ then
setKey _common druid.zk.service.host "${ZOOKEEPER}"
fi
-DRUID_SET_HOST=${DRUID_SET_HOST:-1}
-if [ "${DRUID_SET_HOST}" = "1" ]
+if [ -z "${KUBERNETES_SERVICE_HOST}" ]
+then
+ # Running outside kubernetes, use IP addresses
+ DRUID_SET_HOST_IP=${DRUID_SET_HOST_IP:-1}
+else
+ # Running in kubernetes, so use canonical names
+ DRUID_SET_HOST_IP=${DRUID_SET_HOST_IP:-0}
+fi
+
+if [ "${DRUID_SET_HOST_IP}" = "1" ]
then
setKey $SERVICE druid.host $(ip r get 1 | awk '{print $7;exit}')
fi
diff --git a/distribution/docker/peon.sh b/distribution/docker/peon.sh
index c98c3d30a30..8103f475ccb 100755
--- a/distribution/docker/peon.sh
+++ b/distribution/docker/peon.sh
@@ -97,8 +97,16 @@ then
setKey _common druid.zk.service.host "${ZOOKEEPER}"
fi
-DRUID_SET_HOST=${DRUID_SET_HOST:-1}
-if [ "${DRUID_SET_HOST}" = "1" ]
+if [ -z "${KUBERNETES_SERVICE_HOST}" ]
+then
+ # Running outside kubernetes, use IP addresses
+ DRUID_SET_HOST_IP=${DRUID_SET_HOST_IP:-1}
+else
+ # Running in kubernetes, so use canonical names
+ DRUID_SET_HOST_IP=${DRUID_SET_HOST_IP:-0}
+fi
+
+if [ "${DRUID_SET_HOST_IP}" = "1" ]
then
setKey $SERVICE druid.host $(ip r get 1 | awk '{print $7;exit}')
fi
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]