mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
Examples/rethinkdb fixes - namespaces, api update, curl params
This commit is contained in:
@@ -11,4 +11,4 @@ RUN apt-get update && \
|
||||
COPY ./run.sh /usr/bin/run.sh
|
||||
RUN chmod u+x /usr/bin/run.sh
|
||||
|
||||
CMD ["/usr/bin/run.sh"]
|
||||
CMD "/usr/bin/run.sh"
|
||||
|
@@ -16,14 +16,21 @@
|
||||
|
||||
set -o pipefail
|
||||
|
||||
echo Checking for other nodes
|
||||
IP=""
|
||||
if [[ -n "${KUBERNETES_RO_SERVICE_HOST}" ]]; then
|
||||
if [[ -n "${KUBERNETES_SERVICE_HOST}" ]]; then
|
||||
|
||||
: ${NAMESPACE:=rethinkdb}
|
||||
# try to pick up first different ip from endpoints
|
||||
POD_NAMESPACE=${POD_NAMESPACE:-default}
|
||||
MYHOST=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||
URL="${KUBERNETES_RO_SERVICE_HOST}/api/v1/namespaces/${NAMESPACE}/endpoints/rethinkdb-driver"
|
||||
IP=$(curl -s ${URL} | jq -s -r --arg h "${MYHOST}" '.[0].subsets | .[].addresses | [ .[].IP ] | map(select(. != $h)) | .[0]') || exit 1
|
||||
echo My host: ${MYHOST}
|
||||
|
||||
URL="https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}/api/v1/namespaces/${POD_NAMESPACE}/endpoints/rethinkdb-driver"
|
||||
echo "Endpont url: ${URL}"
|
||||
echo "Looking for IPs..."
|
||||
token=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
||||
# try to pick up first different ip from endpoints
|
||||
IP=$(curl -s ${URL} --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt --header "Authorization: Bearer ${token}" \
|
||||
| jq -s -r --arg h "${MYHOST}" '.[0].subsets | .[].addresses | [ .[].ip ] | map(select(. != $h)) | .[0]') || exit 1
|
||||
[[ "${IP}" == null ]] && IP=""
|
||||
fi
|
||||
|
||||
|
Reference in New Issue
Block a user