mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
automatically setup etcd when running verify/update openapi-spec.sh
1. automatically add etcd to current PATH when calling kube::etcd::install 2. call kube::etcd::install from update-openapi-spec 3. don't call kube::golang::setup_env twice
This commit is contained in:
parent
03ba7efb85
commit
3c530eea2d
@ -144,38 +144,42 @@ kube::etcd::cleanup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kube::etcd::install() {
|
kube::etcd::install() {
|
||||||
(
|
local os
|
||||||
local os
|
local arch
|
||||||
local arch
|
|
||||||
|
|
||||||
os=$(kube::util::host_os)
|
os=$(kube::util::host_os)
|
||||||
arch=$(kube::util::host_arch)
|
arch=$(kube::util::host_arch)
|
||||||
|
|
||||||
cd "${KUBE_ROOT}/third_party" || return 1
|
cd "${KUBE_ROOT}/third_party" || return 1
|
||||||
if [[ $(readlink etcd) == etcd-v${ETCD_VERSION}-${os}-* ]]; then
|
if [[ $(readlink etcd) == etcd-v${ETCD_VERSION}-${os}-* ]]; then
|
||||||
kube::log::info "etcd v${ETCD_VERSION} already installed. To use:"
|
kube::log::info "etcd v${ETCD_VERSION} already installed. To use:"
|
||||||
kube::log::info "export PATH=\"$(pwd)/etcd:\${PATH}\""
|
|
||||||
return #already installed
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${os} == "darwin" ]]; then
|
|
||||||
download_file="etcd-v${ETCD_VERSION}-${os}-${arch}.zip"
|
|
||||||
url="https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/${download_file}"
|
|
||||||
kube::util::download_file "${url}" "${download_file}"
|
|
||||||
unzip -o "${download_file}"
|
|
||||||
ln -fns "etcd-v${ETCD_VERSION}-${os}-${arch}" etcd
|
|
||||||
rm "${download_file}"
|
|
||||||
elif [[ ${os} == "linux" ]]; then
|
|
||||||
url="https://github.com/coreos/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz"
|
|
||||||
download_file="etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz"
|
|
||||||
kube::util::download_file "${url}" "${download_file}"
|
|
||||||
tar xzf "${download_file}"
|
|
||||||
ln -fns "etcd-v${ETCD_VERSION}-${os}-${arch}" etcd
|
|
||||||
rm "${download_file}"
|
|
||||||
else
|
|
||||||
kube::log::info "${os} is NOT supported."
|
|
||||||
fi
|
|
||||||
kube::log::info "etcd v${ETCD_VERSION} installed. To use:"
|
|
||||||
kube::log::info "export PATH=\"$(pwd)/etcd:\${PATH}\""
|
kube::log::info "export PATH=\"$(pwd)/etcd:\${PATH}\""
|
||||||
)
|
# export into current process
|
||||||
|
PATH="$(pwd)/etcd:${PATH}"
|
||||||
|
export PATH
|
||||||
|
return #already installed
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${os} == "darwin" ]]; then
|
||||||
|
download_file="etcd-v${ETCD_VERSION}-${os}-${arch}.zip"
|
||||||
|
url="https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/${download_file}"
|
||||||
|
kube::util::download_file "${url}" "${download_file}"
|
||||||
|
unzip -o "${download_file}"
|
||||||
|
ln -fns "etcd-v${ETCD_VERSION}-${os}-${arch}" etcd
|
||||||
|
rm "${download_file}"
|
||||||
|
elif [[ ${os} == "linux" ]]; then
|
||||||
|
url="https://github.com/coreos/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz"
|
||||||
|
download_file="etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz"
|
||||||
|
kube::util::download_file "${url}" "${download_file}"
|
||||||
|
tar xzf "${download_file}"
|
||||||
|
ln -fns "etcd-v${ETCD_VERSION}-${os}-${arch}" etcd
|
||||||
|
rm "${download_file}"
|
||||||
|
else
|
||||||
|
kube::log::info "${os} is NOT supported."
|
||||||
|
fi
|
||||||
|
kube::log::info "etcd v${ETCD_VERSION} installed. To use:"
|
||||||
|
kube::log::info "export PATH=\"$(pwd)/etcd:\${PATH}\""
|
||||||
|
# export into current process
|
||||||
|
PATH="$(pwd)/etcd:${PATH}"
|
||||||
|
export PATH
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
|
|||||||
|
|
||||||
kube::util::require-jq
|
kube::util::require-jq
|
||||||
kube::golang::setup_env
|
kube::golang::setup_env
|
||||||
|
kube::etcd::install
|
||||||
|
|
||||||
make -C "${KUBE_ROOT}" WHAT=cmd/kube-apiserver
|
make -C "${KUBE_ROOT}" WHAT=cmd/kube-apiserver
|
||||||
|
|
||||||
@ -46,8 +47,6 @@ function cleanup()
|
|||||||
|
|
||||||
trap cleanup EXIT SIGINT
|
trap cleanup EXIT SIGINT
|
||||||
|
|
||||||
kube::golang::setup_env
|
|
||||||
|
|
||||||
TMP_DIR=${TMP_DIR:-$(kube::realpath "$(mktemp -d -t "$(basename "$0").XXXXXX")")}
|
TMP_DIR=${TMP_DIR:-$(kube::realpath "$(mktemp -d -t "$(basename "$0").XXXXXX")")}
|
||||||
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}
|
||||||
|
Loading…
Reference in New Issue
Block a user