mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 05:01:46 +00:00
Initial vagrant setup and e2e testing support
This commit is contained in:
@@ -23,150 +23,12 @@
|
||||
# exit on any error
|
||||
set -e
|
||||
|
||||
source $(dirname $0)/util.sh
|
||||
source $(dirname $0)/kube-env.sh
|
||||
source $(dirname $0)/$KUBERNETES_PROVIDER/util.sh
|
||||
|
||||
# Make sure that prerequisites are installed.
|
||||
for x in gcloud gcutil gsutil; do
|
||||
if [ "$(which $x)" == "" ]; then
|
||||
echo "Can't find $x in PATH, please fix and retry."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo "Starting cluster using provider: $KUBERNETES_PROVIDER"
|
||||
|
||||
# Find the release to use. Generally it will be passed when doing a 'prod'
|
||||
# install and will default to the release/config.sh version when doing a
|
||||
# developer up.
|
||||
find-release $1
|
||||
verify-prereqs
|
||||
kube-up
|
||||
|
||||
# Detect the project into $PROJECT if it isn't set
|
||||
detect-project
|
||||
|
||||
# Build up start up script for master
|
||||
KUBE_TEMP=$(mktemp -d -t kubernetes.XXXXXX)
|
||||
trap "rm -rf ${KUBE_TEMP}" EXIT
|
||||
|
||||
get-password
|
||||
echo "Using password: $user:$passwd"
|
||||
python $(dirname $0)/../third_party/htpasswd/htpasswd.py -b -c ${KUBE_TEMP}/htpasswd $user $passwd
|
||||
HTPASSWD=$(cat ${KUBE_TEMP}/htpasswd)
|
||||
|
||||
(
|
||||
echo "#! /bin/bash"
|
||||
echo "MASTER_NAME=${MASTER_NAME}"
|
||||
echo "MASTER_RELEASE_TAR=${RELEASE_NORMALIZED}/master-release.tgz"
|
||||
echo "MASTER_HTPASSWD='${HTPASSWD}'"
|
||||
grep -v "^#" $(dirname $0)/templates/download-release.sh
|
||||
grep -v "^#" $(dirname $0)/templates/salt-master.sh
|
||||
) > ${KUBE_TEMP}/master-start.sh
|
||||
|
||||
echo "Starting VMs and configuring firewalls"
|
||||
gcutil addfirewall ${MASTER_NAME}-https \
|
||||
--norespect_terminal_width \
|
||||
--project ${PROJECT} \
|
||||
--network ${NETWORK} \
|
||||
--target_tags ${MASTER_TAG} \
|
||||
--allowed tcp:443 &
|
||||
|
||||
gcutil addinstance ${MASTER_NAME}\
|
||||
--norespect_terminal_width \
|
||||
--project ${PROJECT} \
|
||||
--zone ${ZONE} \
|
||||
--machine_type ${MASTER_SIZE} \
|
||||
--image ${IMAGE} \
|
||||
--tags ${MASTER_TAG} \
|
||||
--network ${NETWORK} \
|
||||
--service_account_scopes="storage-ro,compute-rw" \
|
||||
--automatic_restart \
|
||||
--metadata_from_file startup-script:${KUBE_TEMP}/master-start.sh &
|
||||
|
||||
for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
|
||||
(
|
||||
echo "#! /bin/bash"
|
||||
echo "MASTER_NAME=${MASTER_NAME}"
|
||||
echo "MINION_IP_RANGE=${MINION_IP_RANGES[$i]}"
|
||||
grep -v "^#" $(dirname $0)/templates/salt-minion.sh
|
||||
) > ${KUBE_TEMP}/minion-start-${i}.sh
|
||||
|
||||
gcutil addinstance ${MINION_NAMES[$i]} \
|
||||
--norespect_terminal_width \
|
||||
--project ${PROJECT} \
|
||||
--zone ${ZONE} \
|
||||
--machine_type ${MINION_SIZE} \
|
||||
--image ${IMAGE} \
|
||||
--tags ${MINION_TAG} \
|
||||
--network ${NETWORK} \
|
||||
--service_account_scopes=${MINION_SCOPES} \
|
||||
--automatic_restart \
|
||||
--can_ip_forward \
|
||||
--metadata_from_file startup-script:${KUBE_TEMP}/minion-start-${i}.sh &
|
||||
|
||||
gcutil addroute ${MINION_NAMES[$i]} ${MINION_IP_RANGES[$i]} \
|
||||
--norespect_terminal_width \
|
||||
--project ${PROJECT} \
|
||||
--network ${NETWORK} \
|
||||
--next_hop_instance ${ZONE}/instances/${MINION_NAMES[$i]} &
|
||||
done
|
||||
|
||||
FAIL=0
|
||||
for job in `jobs -p`
|
||||
do
|
||||
wait $job || let "FAIL+=1"
|
||||
done
|
||||
if (( $FAIL != 0 )); then
|
||||
echo "${FAIL} commands failed. Exiting."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
detect-master > /dev/null
|
||||
|
||||
echo "Waiting for cluster initialization."
|
||||
echo
|
||||
echo " This will continually check to see if the API for kubernetes is reachable."
|
||||
echo " This might loop forever if there was some uncaught error during start"
|
||||
echo " up."
|
||||
echo
|
||||
|
||||
until $(curl --insecure --user ${user}:${passwd} --max-time 5 \
|
||||
--fail --output /dev/null --silent https://${KUBE_MASTER_IP}/api/v1beta1/pods); do
|
||||
printf "."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "Kubernetes cluster created."
|
||||
echo "Sanity checking cluster..."
|
||||
|
||||
sleep 5
|
||||
|
||||
# Don't bail on errors, we want to be able to print some info.
|
||||
set +e
|
||||
|
||||
# Basic sanity checking
|
||||
for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
|
||||
# Make sure docker is installed
|
||||
gcutil ssh ${MINION_NAMES[$i]} which docker > /dev/null
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Docker failed to install on ${MINION_NAMES[$i]} your cluster is unlikely to work correctly"
|
||||
echo "Please run ./cluster/kube-down.sh and re-create the cluster. (sorry!)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure the kubelet is healthy
|
||||
if [ "$(curl --insecure --user ${user}:${passwd} https://${KUBE_MASTER_IP}/proxy/minion/${MINION_NAMES[$i]}/healthz)" != "ok" ]; then
|
||||
echo "Kubelet failed to install on ${MINION_NAMES[$i]} your cluster is unlikely to work correctly"
|
||||
echo "Please run ./cluster/kube-down.sh and re-create the cluster. (sorry!)"
|
||||
exit 1
|
||||
else
|
||||
echo "Kubelet is successfully installed on ${MINION_NAMES[$i]}"
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
echo
|
||||
echo "Kubernetes cluster is running. Access the master at:"
|
||||
echo
|
||||
echo " https://${user}:${passwd}@${KUBE_MASTER_IP}"
|
||||
echo
|
||||
echo "Security note: The server above uses a self signed certificate. This is"
|
||||
echo " subject to \"Man in the middle\" type attacks."
|
||||
echo "Done"
|
||||
|
Reference in New Issue
Block a user