Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local-up-cluster additions #38713

Merged
merged 1 commit into from
Dec 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 1 addition & 24 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function kube::build::verify_prereqs() {
if kube::build::is_osx; then
kube::build::docker_available_on_osx || return 1
fi
kube::build::ensure_docker_daemon_connectivity || return 1
kube::util::ensure_docker_daemon_connectivity || return 1

if (( ${KUBE_VERBOSE} > 6 )); then
kube::log::status "Docker Version:"
Expand Down Expand Up @@ -272,29 +272,6 @@ function kube::build::ensure_docker_in_path() {
fi
}

function kube::build::ensure_docker_daemon_connectivity {
if ! "${DOCKER[@]}" info > /dev/null 2>&1 ; then
cat <<'EOF' >&2
Can't connect to 'docker' daemon. please fix and retry.

Possible causes:
- Docker Daemon not started
- Linux: confirm via your init system
- macOS w/ docker-machine: run `docker-machine ls` and `docker-machine start <name>`
- macOS w/ Docker for Mac: Check the menu bar and start the Docker application
- DOCKER_HOST hasn't been set or is set incorrectly
- Linux: domain socket is used, DOCKER_* should be unset. In Bash run `unset ${!DOCKER_*}`
- macOS w/ docker-machine: run `eval "$(docker-machine env <name>)"`
- macOS w/ Docker for Mac: domain socket is used, DOCKER_* should be unset. In Bash run `unset ${!DOCKER_*}`
- Other things to check:
- Linux: User isn't in 'docker' group. Add and relogin.
- Something like 'sudo usermod -a -G docker ${USER}'
- RHEL7 bug and workaround: https://bugzilla.redhat.com/show_bug.cgi?id=1119282#c8
EOF
return 1
fi
}

function kube::build::ensure_tar() {
if [[ -n "${TAR:-}" ]]; then
return
Expand Down
10 changes: 9 additions & 1 deletion hack/lib/etcd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@ ETCD_VERSION=${ETCD_VERSION:-3.0.14}
ETCD_HOST=${ETCD_HOST:-127.0.0.1}
ETCD_PORT=${ETCD_PORT:-2379}

kube::etcd::start() {
kube::etcd::validate() {
# validate if in path
which etcd >/dev/null || {
kube::log::usage "etcd must be in your PATH"
exit 1
}

# validate it is not running
if pgrep etcd >/dev/null 2>&1; then
kube::log::usage "etcd appears to already be running on this machine (`pgrep -l etcd`) (or its a zombie and you need to kill its parent)."
kube::log::usage "retry after you resolve this etcd error."
exit 1
fi

# validate installed version is at least equal to minimum
version=$(etcd --version | tail -n +1 | head -n 1 | cut -d " " -f 3)
if [[ "${version}" < "${ETCD_VERSION}" ]]; then
export PATH=$KUBE_ROOT/third_party/etcd:$PATH
Expand All @@ -45,6 +48,11 @@ kube::etcd::start() {
exit 1
fi
fi
}

kube::etcd::start() {
# validate before running
kube::etcd::validate

# Start etcd
ETCD_DIR=${ETCD_DIR:-$(mktemp -d 2>/dev/null || mktemp -d -t test-etcd.XXXXXX)}
Expand Down
1 change: 1 addition & 0 deletions hack/lib/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,4 @@ kube::realpath() {
fi
kube::readlinkdashf "$1"
}

26 changes: 26 additions & 0 deletions hack/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -575,5 +575,31 @@ EOF
EOF
}

# Determines if docker can be run, failures may simply require that the user be added to the docker group.
function kube::util::ensure_docker_daemon_connectivity {
DOCKER=(docker ${DOCKER_OPTS})
if ! "${DOCKER[@]}" info > /dev/null 2>&1 ; then
cat <<'EOF' >&2
Can't connect to 'docker' daemon. please fix and retry.

Possible causes:
- Docker Daemon not started
- Linux: confirm via your init system
- macOS w/ docker-machine: run `docker-machine ls` and `docker-machine start <name>`
- macOS w/ Docker for Mac: Check the menu bar and start the Docker application
- DOCKER_HOST hasn't been set or is set incorrectly
- Linux: domain socket is used, DOCKER_* should be unset. In Bash run `unset ${!DOCKER_*}`
- macOS w/ docker-machine: run `eval "$(docker-machine env <name>)"`
- macOS w/ Docker for Mac: domain socket is used, DOCKER_* should be unset. In Bash run `unset ${!DOCKER_*}`
- Other things to check:
- Linux: User isn't in 'docker' group. Add and relogin.
- Something like 'sudo usermod -a -G docker ${USER}'
- RHEL7 bug and workaround: https://bugzilla.redhat.com/show_bug.cgi?id=1119282#c8
EOF
return 1
fi
}



# ex: ts=2 sw=2 et filetype=sh
22 changes: 11 additions & 11 deletions hack/local-up-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"

function usage {
echo "This script starts a local kube cluster. "
echo "Example 0: hack/local-up-cluster.sh -h (this 'help' usage description)"
echo "Example 1: hack/local-up-cluster.sh -o _output/dockerized/bin/linux/amd64/ (run from docker output)"
echo "Example 2: hack/local-up-cluster.sh -O (auto-guess the bin path for your platform)"
echo "Example 3: hack/local-up-cluster.sh (build a local copy of the source)"
Expand All @@ -111,7 +112,7 @@ function guess_built_binary_path {

### Allow user to supply the source directory.
GO_OUT=${GO_OUT:-}
while getopts "o:O" OPTION
while getopts "ho:O" OPTION
do
case $OPTION in
o)
Expand All @@ -126,6 +127,10 @@ do
exit 1
fi
;;
h)
usage
exit
;;
?)
usage
exit
Expand All @@ -139,14 +144,6 @@ else
echo "skipped the build."
fi

function test_docker {
${DOCKER[@]} ps 2> /dev/null 1> /dev/null
if [ "$?" != "0" ]; then
echo "Failed to successfully run 'docker ps', please verify that docker is installed and \$DOCKER_HOST is set correctly."
exit 1
fi
}

function test_rkt {
if [[ -n "${RKT_PATH}" ]]; then
${RKT_PATH} list 2> /dev/null 1> /dev/null
Expand Down Expand Up @@ -680,8 +677,11 @@ EOF
fi
}

if [[ "${CONTAINER_RUNTIME}" == "docker" ]]; then
test_docker
# validate that etcd is: not running, in path, and has minimum required version.
kube::etcd::validate

if [ "${CONTAINER_RUNTIME}" == "docker" ] && ! kube::util::ensure_docker_daemon_connectivity; then
exit 1
fi

if [[ "${CONTAINER_RUNTIME}" == "rkt" ]]; then
Expand Down