Add minikube gate script as backlog
Change-Id: If018c30ed04d245e1a2170ad764f22307bdeebf3
This commit is contained in:
parent
4b06c280bb
commit
924d87dbf7
|
@ -0,0 +1,5 @@
|
||||||
|
# Minikube installation script for Qinling devstack gate
|
||||||
|
|
||||||
|
Those sciprts locate here just for backlog purpose. A known issue is the
|
||||||
|
application in the pod can not talk to Qinling service, failed with "No route
|
||||||
|
to host" error.
|
|
@ -0,0 +1,55 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
function base_install {
|
||||||
|
if [ "x$HOST_OS" == "xubuntu" ]; then
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y --no-install-recommends \
|
||||||
|
iproute2 \
|
||||||
|
iptables \
|
||||||
|
ipcalc \
|
||||||
|
nmap \
|
||||||
|
lshw \
|
||||||
|
screen
|
||||||
|
elif [ "x$HOST_OS" == "xcentos" ]; then
|
||||||
|
sudo yum install -y \
|
||||||
|
epel-release
|
||||||
|
# ipcalc is in the initscripts package
|
||||||
|
sudo yum install -y \
|
||||||
|
iproute \
|
||||||
|
iptables \
|
||||||
|
initscripts \
|
||||||
|
nmap \
|
||||||
|
lshw
|
||||||
|
elif [ "x$HOST_OS" == "xfedora" ]; then
|
||||||
|
sudo dnf install -y \
|
||||||
|
iproute \
|
||||||
|
iptables \
|
||||||
|
ipcalc \
|
||||||
|
nmap \
|
||||||
|
lshw
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function gate_base_setup {
|
||||||
|
# Install base requirements
|
||||||
|
base_install
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_k8s_screen {
|
||||||
|
# Starts a proxy to the Kubernetes API server in a screen session
|
||||||
|
sudo screen -S kube_proxy -X quit || true
|
||||||
|
sudo screen -dmS kube_proxy && sudo screen -S kube_proxy -X screen -t kube_proxy
|
||||||
|
sudo screen -S kube_proxy -p kube_proxy -X stuff 'kubectl proxy --accept-hosts=".*" --address="0.0.0.0"\n'
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
function net_default_iface {
|
||||||
|
sudo ip -4 route list 0/0 | awk '{ print $5; exit }'
|
||||||
|
}
|
||||||
|
|
||||||
|
function net_default_host_addr {
|
||||||
|
sudo ip addr | awk "/inet / && /$(net_default_iface)/{print \$2; exit }"
|
||||||
|
}
|
||||||
|
|
||||||
|
function net_default_host_ip {
|
||||||
|
echo $(net_default_host_addr) | awk -F '/' '{ print $1; exit }'
|
||||||
|
}
|
||||||
|
|
||||||
|
function net_resolv_pre_kube {
|
||||||
|
sudo cp -f /etc/resolv.conf /etc/resolv-pre-kube.conf
|
||||||
|
sudo rm -f /etc/resolv.conf
|
||||||
|
cat << EOF | sudo tee /etc/resolv.conf
|
||||||
|
nameserver ${UPSTREAM_DNS}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
function net_resolv_post_kube {
|
||||||
|
sudo cp -f /etc/resolv-pre-kube.conf /etc/resolv.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
function net_hosts_pre_kube {
|
||||||
|
sudo cp -f /etc/hosts /etc/hosts-pre-kube
|
||||||
|
sudo sed -i "/$(hostname)/d" /etc/hosts
|
||||||
|
sudo sed -i "/127.0.0.1/d" /etc/hosts
|
||||||
|
sudo sed -i "1 i 127.0.0.1 localhost" /etc/hosts
|
||||||
|
|
||||||
|
host_ip=$(net_default_host_ip)
|
||||||
|
echo "${host_ip} $(hostname)" | sudo tee -a /etc/hosts
|
||||||
|
}
|
||||||
|
|
||||||
|
function net_hosts_post_kube {
|
||||||
|
sudo cp -f /etc/hosts-pre-kube /etc/hosts
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
export WORK_DIR=$(pwd)
|
||||||
|
source ${WORK_DIR}/tools/gate/vars.sh
|
||||||
|
source ${WORK_DIR}/tools/gate/funcs/common.sh
|
||||||
|
source ${WORK_DIR}/tools/gate/funcs/network.sh
|
||||||
|
|
||||||
|
# Do the basic node setup for running the gate
|
||||||
|
gate_base_setup
|
||||||
|
net_resolv_pre_kube
|
||||||
|
net_hosts_pre_kube
|
||||||
|
|
||||||
|
# Setup the K8s Cluster
|
||||||
|
source ${WORK_DIR}/tools/gate/minikube/setup_minikube.sh
|
||||||
|
create_k8s_screen
|
||||||
|
|
||||||
|
#net_hosts_post_kube
|
||||||
|
#net_resolv_post_kube
|
|
@ -0,0 +1,47 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
sudo apt-get install -y --no-install-recommends -qq jq
|
||||||
|
|
||||||
|
TMP_DIR=$(mktemp -d)
|
||||||
|
|
||||||
|
curl -sSL https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/amd64/kubectl -o ${TMP_DIR}/kubectl
|
||||||
|
chmod +x ${TMP_DIR}/kubectl
|
||||||
|
sudo mv ${TMP_DIR}/kubectl /usr/local/bin/kubectl
|
||||||
|
|
||||||
|
curl -sSL https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -o ${TMP_DIR}/minikube
|
||||||
|
chmod +x ${TMP_DIR}/minikube
|
||||||
|
sudo mv ${TMP_DIR}/minikube /usr/local/bin/minikube
|
||||||
|
|
||||||
|
curl -fsSL get.docker.com -o ${TMP_DIR}/get-docker.sh
|
||||||
|
sudo sh ${TMP_DIR}/get-docker.sh
|
||||||
|
|
||||||
|
rm -rf ${TMP_DIR}
|
||||||
|
|
||||||
|
export MINIKUBE_WANTUPDATENOTIFICATION=false
|
||||||
|
export MINIKUBE_WANTREPORTERRORPROMPT=false
|
||||||
|
export MINIKUBE_HOME=$HOME
|
||||||
|
export CHANGE_MINIKUBE_NONE_USER=true
|
||||||
|
|
||||||
|
rm -rf $HOME/.kube
|
||||||
|
mkdir $HOME/.kube || true
|
||||||
|
touch $HOME/.kube/config
|
||||||
|
|
||||||
|
export KUBECONFIG=$HOME/.kube/config
|
||||||
|
sudo minikube delete || true
|
||||||
|
sudo -E minikube start --vm-driver=none --kubernetes-version ${KUBE_VERSION} --loglevel 0
|
||||||
|
|
||||||
|
# waits until kubectl can access the api server that Minikube has created
|
||||||
|
end=$(($(date +%s) + 600))
|
||||||
|
READY="False"
|
||||||
|
while true; do
|
||||||
|
kubectl get po &> /dev/null
|
||||||
|
if [ $? -ne 1 ]; then
|
||||||
|
READY="True"
|
||||||
|
echo "Kubernetes cluster is ready!"
|
||||||
|
fi
|
||||||
|
[ $READY == "True" ] && break || true
|
||||||
|
sleep 2
|
||||||
|
now=$(date +%s)
|
||||||
|
[ $now -gt $end ] && echo "Failed to setup kubernetes cluster in time" && exit -1
|
||||||
|
done
|
|
@ -0,0 +1,19 @@
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Set work dir if not already done
|
||||||
|
: ${WORK_DIR:="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"}
|
||||||
|
|
||||||
|
# Get Host OS
|
||||||
|
source /etc/os-release
|
||||||
|
export HOST_OS=${HOST_OS:="${ID}"}
|
||||||
|
|
||||||
|
# Set versions of K8s to use
|
||||||
|
export KUBE_VERSION=${KUBE_VERSION:-"v1.8.0"}
|
||||||
|
|
||||||
|
# Set Upstream DNS
|
||||||
|
export UPSTREAM_DNS=${UPSTREAM_DNS:-"8.8.8.8"}
|
Loading…
Reference in New Issue