Skip to content

Instantly share code, notes, and snippets.

@megastef
Last active April 14, 2016 18:27
Show Gist options
  • Save megastef/66cd71cfb0038c0cef1c to your computer and use it in GitHub Desktop.
Save megastef/66cd71cfb0038c0cef1c to your computer and use it in GitHub Desktop.
Deploy Sematext Docker Agent each node in Docker-Swarm (TLS / docker-machine)
export SPM_TOKEN=TOUR_SPM_TOKEN
export LOGSENE_TOKEN=YOUR_LOGSENE_TOKEN
export NODES=$(docker-machine ls | grep Running | grep -v error | awk '{printf $1 "\t"}')
echo Swarm nodes: "$NODES"
for node in $NODES; do
echo "get docker-machine env $node"
eval "$(docker-machine env $node)"
echo "Using docker host: $DOCKER_HOST"
echo "deploy sematext-agent-docker to $node"
docker rm -f sematext-agent 2>1 /dev/null
docker pull sematext/sematext-agent-docker > /dev/null
docker run -d --name sematext-agent --restart=always \
-e SPM_TOKEN \
-e LOGSENE_TOKEN \
-e HOSTNAME=$node \
-e DOCKER_TLS_VERIFY -e DOCKER_CERT_PATH -e DOCKER_HOST \
-v $DOCKER_CERT_PATH:$DOCKER_CERT_PATH sematext/sematext-agent-docker
sleep 2
docker logs sematext-agent | grep -e "error|fail|exception"
done
@megastef
Copy link
Author

@megastef
Copy link
Author

@Richard-Mathie
Copy link

So I dont think this works on a real cluster (aws not virtualbox) as DOCKER_CERT_PATH won't be local to the host machine. If you fired up the hosts with docker-machine on aws the certs for that machine will be in /etc/docker. However cert.pem will not reside on those machines and It appears sematext-agent needs that for some reason.

Only way i got it running was through the unix socket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment