Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combine prepare_env scripts into one #38

Merged
merged 8 commits into from
Dec 25, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 61 additions & 25 deletions scripts/prepare_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,60 @@ function install_dependencies() {
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/"${K8S_VERSION}"/bin/linux/amd64/kubectl && \
chmod +x kubectl && sudo mv kubectl /usr/local/bin/ && sudo ln /usr/local/bin/kubectl /usr/bin/kubectl || true

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && \
chmod +x minikube && sudo mv minikube /usr/local/bin/ && sudo ln /usr/local/bin/minikube /usr/bin/minikube || true
if [[ ! -z ${IS_WSL} && ! -z ${WSL_DISTRO_NAME} ]]; then
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && \
chmod +x minikube && sudo mv minikube /usr/local/bin/ && sudo ln /usr/local/bin/minikube /usr/bin/minikube || true
else
curl -Lo kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-linux-amd64 && \
chmod +x kind && sudo mv kind /usr/local/bin/ && sudo ln /usr/local/bin/kind /usr/bin/kind || true
fi
}

function start_docker() {
# start docker daemon if docker not running.
if ! sudo docker info >/dev/null 2>&1; then
if [[ ! -z ${IS_WSL} && ! -z ${WSL_DISTRO_NAME} ]]; then
sudo systemctl start docker
else
sudo dockerd > /dev/null& || true
fi
fi
}

function launch_k8s_cluster() {
if [[ ! -z ${IS_WSL} && ! -z ${WSL_DISTRO_NAME} ]]; then
acezen marked this conversation as resolved.
Show resolved Hide resolved
export CHANGE_MINIKUBE_NONE_USER=true
sudo sysctl fs.protected_regular=0 || true
sudo minikube start --vm-driver=none --kubernetes-version="${K8S_VERSION}"

sudo cp -r /root/.kube /root/.minikube "${HOME}" || true
sudo chown -R "$(id -u)":"$(id -g)" "${HOME}"/.minikube || true
sudo chown -R "$(id -u)":"$(id -g)" "${HOME}"/.kube || true
sed -i 's@/root@'"${HOME}"'@g' "${HOME}"/.kube/config || true
minikube update-context
else
curl -Lo config-with-mounts.yaml https://kind.sigs.k8s.io/examples/config-with-mounts.yaml
# mount $HOME dir to cluster container, which is kind-control-plane
sed -i 's@/path/to/my/files/@'"${HOME}"'@g; s@/files@'"${HOME}"'@g' ./config-with-mounts.yaml || true
sudo kind create cluster --config config-with-mounts.yaml
sudo cp -r /root/.kube ${HOME} || true
sudo chown -R "$(id -u)":"$(id -g)" "${HOME}"/.kube || true
fi
}

function pull_images() {
sudo docker pull registry.cn-hongkong.aliyuncs.com/graphscope/graphscope:latest || true
acezen marked this conversation as resolved.
Show resolved Hide resolved
sudo docker pull registry.cn-hongkong.aliyuncs.com/graphscope/maxgraph_standalone_manager:1.0 || true
sudo docker pull zookeeper:3.4.14 || true
sudo docker pull quay.io/coreos/etcd:v3.4.13 || true

if [[ -z ${IS_WSL} || -z ${WSL_DISTRO_NAME} ]]; then
echo "$(date '+%Y-%m-%d %H:%M:%S') load images into cluster"
sudo kind load registry.cn-hongkong.aliyuncs.com/graphscope/graphscope:latest || true
sudo kind load registry.cn-hongkong.aliyuncs.com/graphscope/maxgraph_standalone_manager:1.0 || true
sudo kind load zookeeper:3.4.14 || true
sudo kind load quay.io/coreos/etcd:v3.4.13 || true
fi
}

if [ -f "${HOME}/.kube/config" ];
Expand All @@ -58,33 +110,17 @@ then
exit 0
fi

echo "$(date '+%Y-%m-%d %H:%M:%S') install dependencies"
install_dependencies

# start docker daemon if docker not running.
if ! sudo docker info >/dev/null 2>&1; then
sudo systemctl start docker
fi

echo "$(date '+%Y-%m-%d %H:%M:%S') start doker daemon"
start_docker

# launch k8s cluster
export CHANGE_MINIKUBE_NONE_USER=true
echo "$(date '+%Y-%m-%d %H:%M:%S') launch k8s cluster"
sudo sysctl fs.protected_regular=0 || true
sudo minikube start --vm-driver=none --kubernetes-version="${K8S_VERSION}"

sudo cp -r /root/.kube /root/.minikube "${HOME}" || true
sudo chown -R "$(id -u)":"$(id -g)" "${HOME}"/.minikube || true
sudo chown -R "$(id -u)":"$(id -g)" "${HOME}"/.kube || true
sed -i 's@/root@'"${HOME}"'@g' "${HOME}"/.kube/config || true

minikube update-context

# pull images(graphscope, etcd, maxgraph_standalone_manager)
echo "$(date '+%Y-%m-%d %H:%M:%S') pull graphscope image and etcd image"
sudo docker pull registry.cn-hongkong.aliyuncs.com/graphscope/graphscope:latest || true
sudo docker pull registry.cn-hongkong.aliyuncs.com/graphscope/maxgraph_standalone_manager:1.0 || true
sudo docker pull zookeeper:3.4.14 || true
sudo docker pull quay.io/coreos/etcd:v3.4.13 || true
launch_k8s_cluster

echo "$(date '+%Y-%m-%d %H:%M:%S') pull images(graphscope, etcd, maxgraph_standalone_manager)"
pull_images

set +x
set +e
Expand Down
86 changes: 0 additions & 86 deletions scripts/prepare_env_wsl.sh

This file was deleted.