mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 22:30:23 +00:00
ci: detect available minikube executable
In case there is a minikube executable in the $PATH already, use that for all commands. If there is none, install_minikube() will place a newly downloaded executable in /usr/local/bin which will be used by the full pathname, so that commands as root without /usr/local/bin in the $PATH will work. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
fc378ac74b
commit
e774ebb7f9
@ -5,7 +5,7 @@
|
|||||||
function wait_for_ssh() {
|
function wait_for_ssh() {
|
||||||
local tries=100
|
local tries=100
|
||||||
while ((tries > 0)); do
|
while ((tries > 0)); do
|
||||||
if minikube ssh echo connected &>/dev/null; then
|
if ${minikube} ssh echo connected &>/dev/null; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
tries=$((tries - 1))
|
tries=$((tries - 1))
|
||||||
@ -25,7 +25,7 @@ function copy_image_to_cluster() {
|
|||||||
docker tag "${build_image}" "${final_image}"
|
docker tag "${build_image}" "${final_image}"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
docker save "${build_image}" | (eval "$(minikube docker-env --shell bash)" && docker load && docker tag "${build_image}" "${final_image}")
|
docker save "${build_image}" | (eval "$(${minikube} docker-env --shell bash)" && docker load && docker tag "${build_image}" "${final_image}")
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse the minikube version, return the digit passed as argument
|
# parse the minikube version, return the digit passed as argument
|
||||||
@ -36,11 +36,24 @@ minikube_version() {
|
|||||||
echo "${MINIKUBE_VERSION}" | sed 's/^v//' | cut -d'.' -f"${1}"
|
echo "${MINIKUBE_VERSION}" | sed 's/^v//' | cut -d'.' -f"${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# detect if there is a minikube executable available already. If there is none,
|
||||||
|
# fallback to using /usr/local/bin/minikube, as that is where
|
||||||
|
# install_minikube() will place it too.
|
||||||
|
function detect_minikube() {
|
||||||
|
if type minikube >/dev/null 2>&1; then
|
||||||
|
command -v minikube
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# default if minikube is not available
|
||||||
|
echo '/usr/local/bin/minikube'
|
||||||
|
}
|
||||||
|
minikube="$(detect_minikube)"
|
||||||
|
|
||||||
# install minikube
|
# install minikube
|
||||||
function install_minikube() {
|
function install_minikube() {
|
||||||
if type minikube >/dev/null 2>&1; then
|
if type "${minikube}" >/dev/null 2>&1; then
|
||||||
local mk_version version
|
local mk_version version
|
||||||
read -ra mk_version <<<"$(minikube version)"
|
read -ra mk_version <<<"$(${minikube} version)"
|
||||||
version=${mk_version[2]}
|
version=${mk_version[2]}
|
||||||
if [[ "${version}" != "${MINIKUBE_VERSION}" ]]; then
|
if [[ "${version}" != "${MINIKUBE_VERSION}" ]]; then
|
||||||
echo "installed minikube version ${version} is not matching requested version ${MINIKUBE_VERSION}"
|
echo "installed minikube version ${version} is not matching requested version ${MINIKUBE_VERSION}"
|
||||||
@ -71,8 +84,8 @@ function enable_psp() {
|
|||||||
# testing. In order to reduce resources and potential conflicts between storage
|
# testing. In order to reduce resources and potential conflicts between storage
|
||||||
# plugins, disable them.
|
# plugins, disable them.
|
||||||
function disable_storage_addons() {
|
function disable_storage_addons() {
|
||||||
minikube addons disable default-storageclass 2>/dev/null || true
|
${minikube} addons disable default-storageclass 2>/dev/null || true
|
||||||
minikube addons disable storage-provisioner 2>/dev/null || true
|
${minikube} addons disable storage-provisioner 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
# configure minikube
|
# configure minikube
|
||||||
@ -139,16 +152,16 @@ up)
|
|||||||
if minikube_supports_psp; then
|
if minikube_supports_psp; then
|
||||||
enable_psp
|
enable_psp
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
minikube start --force --memory="${MEMORY}" -b kubeadm --kubernetes-version="${KUBE_VERSION}" --vm-driver="${VM_DRIVER}" --feature-gates="${K8S_FEATURE_GATES}" ${EXTRA_CONFIG}
|
${minikube} start --force --memory="${MEMORY}" -b kubeadm --kubernetes-version="${KUBE_VERSION}" --vm-driver="${VM_DRIVER}" --feature-gates="${K8S_FEATURE_GATES}" ${EXTRA_CONFIG}
|
||||||
else
|
else
|
||||||
# This is a workaround to fix psp issues in minikube >1.6.2 and <1.11.0
|
# This is a workaround to fix psp issues in minikube >1.6.2 and <1.11.0
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
minikube start --force --memory="${MEMORY}" -b kubeadm --kubernetes-version="${KUBE_VERSION}" --vm-driver="${VM_DRIVER}" --feature-gates="${K8S_FEATURE_GATES}"
|
${minikube} start --force --memory="${MEMORY}" -b kubeadm --kubernetes-version="${KUBE_VERSION}" --vm-driver="${VM_DRIVER}" --feature-gates="${K8S_FEATURE_GATES}"
|
||||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
|
||||||
kubectl apply -f "$DIR"/psp.yaml
|
kubectl apply -f "$DIR"/psp.yaml
|
||||||
minikube stop
|
${minikube} stop
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
minikube start --force --memory="${MEMORY}" -b kubeadm --kubernetes-version="${KUBE_VERSION}" --vm-driver="${VM_DRIVER}" --feature-gates="${K8S_FEATURE_GATES}" ${EXTRA_CONFIG}
|
${minikube} start --force --memory="${MEMORY}" -b kubeadm --kubernetes-version="${KUBE_VERSION}" --vm-driver="${VM_DRIVER}" --feature-gates="${K8S_FEATURE_GATES}" ${EXTRA_CONFIG}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create a link so the default dataDirHostPath will work for this
|
# create a link so the default dataDirHostPath will work for this
|
||||||
@ -156,16 +169,16 @@ up)
|
|||||||
if [[ "${VM_DRIVER}" != "none" ]]; then
|
if [[ "${VM_DRIVER}" != "none" ]]; then
|
||||||
wait_for_ssh
|
wait_for_ssh
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
minikube ssh "sudo mkdir -p /mnt/${DISK}/var/lib/rook;sudo ln -s /mnt/${DISK}/var/lib/rook /var/lib/rook"
|
${minikube} ssh "sudo mkdir -p /mnt/${DISK}/var/lib/rook;sudo ln -s /mnt/${DISK}/var/lib/rook /var/lib/rook"
|
||||||
fi
|
fi
|
||||||
kubectl cluster-info
|
kubectl cluster-info
|
||||||
;;
|
;;
|
||||||
down)
|
down)
|
||||||
minikube stop
|
${minikube} stop
|
||||||
;;
|
;;
|
||||||
ssh)
|
ssh)
|
||||||
echo "connecting to minikube"
|
echo "connecting to minikube"
|
||||||
minikube ssh
|
${minikube} ssh
|
||||||
;;
|
;;
|
||||||
deploy-rook)
|
deploy-rook)
|
||||||
echo "deploy rook"
|
echo "deploy rook"
|
||||||
@ -188,8 +201,8 @@ teardown-rook)
|
|||||||
"$DIR"/rook.sh teardown
|
"$DIR"/rook.sh teardown
|
||||||
|
|
||||||
# delete rook data for minikube
|
# delete rook data for minikube
|
||||||
minikube ssh "sudo rm -rf /mnt/${DISK}/var/lib/rook; sudo rm -rf /var/lib/rook"
|
${minikube} ssh "sudo rm -rf /mnt/${DISK}/var/lib/rook; sudo rm -rf /var/lib/rook"
|
||||||
minikube ssh "sudo mkdir -p /mnt/${DISK}/var/lib/rook; sudo ln -s /mnt/${DISK}/var/lib/rook /var/lib/rook"
|
${minikube} ssh "sudo mkdir -p /mnt/${DISK}/var/lib/rook; sudo ln -s /mnt/${DISK}/var/lib/rook /var/lib/rook"
|
||||||
;;
|
;;
|
||||||
cephcsi)
|
cephcsi)
|
||||||
echo "copying the cephcsi image"
|
echo "copying the cephcsi image"
|
||||||
@ -204,7 +217,7 @@ k8s-sidecar)
|
|||||||
copy_image_to_cluster "${K8S_IMAGE_REPO}"/csi-resizer:v0.5.0 "${K8S_IMAGE_REPO}"/csi-resizer:v0.5.0
|
copy_image_to_cluster "${K8S_IMAGE_REPO}"/csi-resizer:v0.5.0 "${K8S_IMAGE_REPO}"/csi-resizer:v0.5.0
|
||||||
;;
|
;;
|
||||||
clean)
|
clean)
|
||||||
minikube delete
|
${minikube} delete
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo " $0 [command]
|
echo " $0 [command]
|
||||||
|
Loading…
Reference in New Issue
Block a user