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 all 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
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ For Linux distributions, we provide a script to install the above dependencies a
# run the environment preparing script.
./scripts/prepare_env.sh

# if on WSL2, run prepare_env_wsl.sh
./scripts/prepare_env_wsl.sh
```

### Installation
Expand Down
95 changes: 71 additions & 24 deletions scripts/prepare_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -x
set -o pipefail

platform=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
is_in_wsl=false && [[ ! -z "${IS_WSL}" || ! -z "${WSL_DISTRO_NAME}" ]] && is_in_wsl=true

##########################
# Install packages
Expand All @@ -16,6 +17,7 @@ platform=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
# None
##########################
function install_dependencies() {
echo "$(date '+%Y-%m-%d %H:%M:%S') install dependencies."
if [[ "${platform}" == *"Ubuntu"* ]]; then
sudo apt-get update -y
sudo apt-get install -y git
Expand All @@ -42,9 +44,71 @@ 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
echo "$(date '+%Y-%m-%d %H:%M:%S') kubectl ${K8S_VERSION} installed."

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 [[ "${is_in_wsl}" = false ]]; 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
echo "$(date '+%Y-%m-%d %H:%M:%S') minikube ${K8S_VERSION} installed."
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
echo "$(date '+%Y-%m-%d %H:%M:%S') kind v0.9.0 installed."
fi
}

function start_docker() {
echo "$(date '+%Y-%m-%d %H:%M:%S') starting doker daemon."
# start docker daemon if docker not running.
if ! sudo docker info >/dev/null 2>&1; then
if [[ "${is_in_wsl}" = false ]]; then
sudo systemctl start docker
else
sudo dockerd > /dev/null&
fi
fi
echo "$(date '+%Y-%m-%d %H:%M:%S') docker started."
}

function launch_k8s_cluster() {
echo "$(date '+%Y-%m-%d %H:%M:%S') launching k8s cluster"
if [[ "${is_in_wsl}" = false ]]; then
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
echo "$(date '+%Y-%m-%d %H:%M:%S') cluster is lauched successfully."
}

function pull_images() {
echo "$(date '+%Y-%m-%d %H:%M:%S') pulling GraphScope 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
echo "$(date '+%Y-%m-%d %H:%M:%S') images pulled successfully."

if [[ "${is_in_wsl}" = true ]]; then
echo "$(date '+%Y-%m-%d %H:%M:%S') loading images into kind 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
echo "$(date '+%Y-%m-%d %H:%M:%S') images loaded."
fi
}

if [ -f "${HOME}/.kube/config" ];
Expand All @@ -60,31 +124,14 @@ fi

install_dependencies

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


# 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}"
start_docker

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
launch_k8s_cluster

minikube update-context
pull_images

# 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
echo "The script has successfully prepared an environment for GraphScope."
echo "Now you are ready to have fun with GraphScope."

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

This file was deleted.