Skip to content

Instantly share code, notes, and snippets.

@errordeveloper
Created May 4, 2016 13:43
Show Gist options
  • Save errordeveloper/e46a67c819c92016225353cb7a17891e to your computer and use it in GitHub Desktop.
Save errordeveloper/e46a67c819c92016225353cb7a17891e to your computer and use it in GitHub Desktop.
#!/bin/bash -x
set -o errexit
set -o nounset
set -o pipefail
check_docker_for_mac() {
local -r docker_for_mac_version="${HOME}/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux/version"
[ "$(uname)" = "Darwin" ] \
&& [ -f "${docker_for_mac_version}" ]
}
check_docker_local() {
[ -S /var/run/docker.sock ] \
&& docker --host="unix:///var/run/docker.sock" info
## TODO: figure out if sudo is needed
}
if check_docker_local && check_docker_for_mac ; then
hostname="docker"
elif check_docker_local ; then
hostname="$(hostname)"
else
exit 1
fi
mode="$1"
version="${2:-v1.2}"
case "$mode" in
up)
weave status || weave luanch
## Currently Weave Net doesn't persist DNS records
weave expose -h "${hostname}.weave.local"
if ! check_docker_for_mac ; then
eval "$(weave env)"
fi
docker run \
--volume="/:/rootfs" \
--volume="/var/run/weave/weave.sock:/docker.sock" \
"weaveworks/kubernetes-anywhere:toolbox-${version}" \
setup-single-node
#
docker run \
--volume="/var/run/weave/weave.sock:/docker.sock" \
"weaveworks/kubernetes-anywhere:toolbox-${version}" \
compose -p kube up -d
;;
reset)
docker run \
--volume="/:/rootfs" \
--volume="/var/run/docker.sock:/docker.sock" \
"weaveworks/kubernetes-anywhere:toolbox-${version}" \
compose -p kube down
docker run \
--volume="/:/rootfs" \
--volume="/var/run/docker.sock:/docker.sock" \
"weaveworks/kubernetes-anywhere:toolbox-${version}" \
reset-single-node
;;
down)
docker run \
--volume="/:/rootfs" \
--volume="/var/run/docker.sock:/docker.sock" \
"weaveworks/kubernetes-anywhere:toolbox-${version}" \
compose -p kube down
;;
*)
echo "$0 [up|down|reset]"
;;
esac
@dkapanidis
Copy link

I don't have the ${HOME}/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux/version file on my Docker on Mac installation. Instead I have ${HOME}/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux/schema-version.

@dkapanidis
Copy link

Do you know https://github.com/vyshane/kid/blob/master/kid? Kubernetes-Anywhere script could also be derived as separate repo. I created https://github.com/harbur/k8s-anywhere and working on it. Added stop command also to avoid deleting data from k8s (so that we can keep the cluster information).

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