Commit 9a1c6076 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #38713 from alejandroEsc/ae/localup1

Automatic merge from submit-queue (batch tested with PRs 37468, 36546, 38713, 38902, 38614) local-up-cluster additions **What this PR does / why we need it**: Changes to local-cluster-up: These include: 1) a simple additional help option. 2) additional error message to not being able to run `docker ps`. 3) fail faster when etcd is not found in path. Hopefully these make developing a bit more pleasant. **Release note**: ```NONE ```
parents ff3d4a55 7d9c06f8
...@@ -163,7 +163,7 @@ function kube::build::verify_prereqs() { ...@@ -163,7 +163,7 @@ function kube::build::verify_prereqs() {
if kube::build::is_osx; then if kube::build::is_osx; then
kube::build::docker_available_on_osx || return 1 kube::build::docker_available_on_osx || return 1
fi fi
kube::build::ensure_docker_daemon_connectivity || return 1 kube::util::ensure_docker_daemon_connectivity || return 1
if (( ${KUBE_VERBOSE} > 6 )); then if (( ${KUBE_VERBOSE} > 6 )); then
kube::log::status "Docker Version:" kube::log::status "Docker Version:"
...@@ -272,29 +272,6 @@ function kube::build::ensure_docker_in_path() { ...@@ -272,29 +272,6 @@ function kube::build::ensure_docker_in_path() {
fi 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() { function kube::build::ensure_tar() {
if [[ -n "${TAR:-}" ]]; then if [[ -n "${TAR:-}" ]]; then
return return
......
...@@ -20,18 +20,21 @@ ETCD_VERSION=${ETCD_VERSION:-3.0.14} ...@@ -20,18 +20,21 @@ ETCD_VERSION=${ETCD_VERSION:-3.0.14}
ETCD_HOST=${ETCD_HOST:-127.0.0.1} ETCD_HOST=${ETCD_HOST:-127.0.0.1}
ETCD_PORT=${ETCD_PORT:-2379} ETCD_PORT=${ETCD_PORT:-2379}
kube::etcd::start() { kube::etcd::validate() {
# validate if in path
which etcd >/dev/null || { which etcd >/dev/null || {
kube::log::usage "etcd must be in your PATH" kube::log::usage "etcd must be in your PATH"
exit 1 exit 1
} }
# validate it is not running
if pgrep etcd >/dev/null 2>&1; then 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 "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." kube::log::usage "retry after you resolve this etcd error."
exit 1 exit 1
fi fi
# validate installed version is at least equal to minimum
version=$(etcd --version | tail -n +1 | head -n 1 | cut -d " " -f 3) version=$(etcd --version | tail -n +1 | head -n 1 | cut -d " " -f 3)
if [[ "${version}" < "${ETCD_VERSION}" ]]; then if [[ "${version}" < "${ETCD_VERSION}" ]]; then
export PATH=$KUBE_ROOT/third_party/etcd:$PATH export PATH=$KUBE_ROOT/third_party/etcd:$PATH
...@@ -45,6 +48,11 @@ kube::etcd::start() { ...@@ -45,6 +48,11 @@ kube::etcd::start() {
exit 1 exit 1
fi fi
fi fi
}
kube::etcd::start() {
# validate before running
kube::etcd::validate
# Start etcd # Start etcd
ETCD_DIR=${ETCD_DIR:-$(mktemp -d 2>/dev/null || mktemp -d -t test-etcd.XXXXXX)} ETCD_DIR=${ETCD_DIR:-$(mktemp -d 2>/dev/null || mktemp -d -t test-etcd.XXXXXX)}
......
...@@ -156,3 +156,4 @@ kube::realpath() { ...@@ -156,3 +156,4 @@ kube::realpath() {
fi fi
kube::readlinkdashf "$1" kube::readlinkdashf "$1"
} }
...@@ -575,5 +575,31 @@ EOF ...@@ -575,5 +575,31 @@ EOF
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 # ex: ts=2 sw=2 et filetype=sh
...@@ -94,6 +94,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh" ...@@ -94,6 +94,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
function usage { function usage {
echo "This script starts a local kube cluster. " 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 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 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)" echo "Example 3: hack/local-up-cluster.sh (build a local copy of the source)"
...@@ -111,7 +112,7 @@ function guess_built_binary_path { ...@@ -111,7 +112,7 @@ function guess_built_binary_path {
### Allow user to supply the source directory. ### Allow user to supply the source directory.
GO_OUT=${GO_OUT:-} GO_OUT=${GO_OUT:-}
while getopts "o:O" OPTION while getopts "ho:O" OPTION
do do
case $OPTION in case $OPTION in
o) o)
...@@ -126,6 +127,10 @@ do ...@@ -126,6 +127,10 @@ do
exit 1 exit 1
fi fi
;; ;;
h)
usage
exit
;;
?) ?)
usage usage
exit exit
...@@ -139,14 +144,6 @@ else ...@@ -139,14 +144,6 @@ else
echo "skipped the build." echo "skipped the build."
fi 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 { function test_rkt {
if [[ -n "${RKT_PATH}" ]]; then if [[ -n "${RKT_PATH}" ]]; then
${RKT_PATH} list 2> /dev/null 1> /dev/null ${RKT_PATH} list 2> /dev/null 1> /dev/null
...@@ -680,8 +677,11 @@ EOF ...@@ -680,8 +677,11 @@ EOF
fi fi
} }
if [[ "${CONTAINER_RUNTIME}" == "docker" ]]; then # validate that etcd is: not running, in path, and has minimum required version.
test_docker kube::etcd::validate
if [ "${CONTAINER_RUNTIME}" == "docker" ] && ! kube::util::ensure_docker_daemon_connectivity; then
exit 1
fi fi
if [[ "${CONTAINER_RUNTIME}" == "rkt" ]]; then if [[ "${CONTAINER_RUNTIME}" == "rkt" ]]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment