Skip to content

Commit

Permalink
Wait for istio to be ready (#288)
Browse files Browse the repository at this point in the history
* Wait for istio to be ready

* Update README.md

Co-authored-by: ioolkos <[email protected]>
  • Loading branch information
rtrive and ioolkos authored Aug 22, 2021
1 parent c8ee70e commit 5b2f21c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ This allows a newly started container to automatically join a VerneMQ cluster. A

(Note, you can find the IP of a docker container using `docker inspect <containername/cid> | grep \"IPAddress\"`).


### 4. Automated clustering on Kubernetes without helm

When running VerneMQ inside Kubernetes, it is possible to cause pods matching a specific label to cluster altogether automatically.
Expand Down Expand Up @@ -93,6 +94,8 @@ When enabling Kubernetes autoclustering, don't set ```DOCKER_VERNEMQ_DISCOVERY_N
> ```
If using an vernemq.conf.local file, you can insert a placeholder (`###IPADDRESS###`) in your config to be replaced (at POD creation time) with the actual IP address of the POD vernemq is running on, making VMQ clustering possible.

If istio is enabled you, set `DOCKER_VERNEMQ_KUBERNETES_ISTIO_ENABLED=1` so the init script will check if istio is ready.

### 5. Using [Docker Swarm](https://docs.docker.com/engine/swarm/)

Please follow the official Docker guide to properly setup Swarm cluster with one or more nodes.
Expand Down
16 changes: 16 additions & 0 deletions bin/vernemq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ if env | grep "DOCKER_VERNEMQ_KUBERNETES_INSECURE" -q; then
insecure="--insecure"
fi

if env | grep "DOCKER_VERNEMQ_KUBERNETES_ISTIO_ENABLED" -q; then
istio_health
while [ $status != 0 ]; do
istio_health
sleep 1
done
echo "Istio ready"
fi

if env | grep "DOCKER_VERNEMQ_DISCOVERY_KUBERNETES" -q; then
DOCKER_VERNEMQ_KUBERNETES_CLUSTER_NAME=${DOCKER_VERNEMQ_KUBERNETES_CLUSTER_NAME:-cluster.local}
# Let's get the namespace if it isn't set
Expand Down Expand Up @@ -143,6 +152,13 @@ fi

pid=0

# Check istio readiness
istio_health () {
cmd=$(curl -s http://localhost:15021/healtz/ready > /dev/null)
status=$?
return $status
}

# SIGUSR1-handler
siguser1_handler() {
echo "stopped"
Expand Down

0 comments on commit 5b2f21c

Please sign in to comment.