Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

k8s env setup guide and script #128

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
115 changes: 115 additions & 0 deletions deployments/env_setup/kube-cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# This doc is for set up the k8s env
Suggest to put this on the k8s control node.
### The scripts can:
1. Install k8s
2. Pull docker images
3. Install dependencies on each compute node
4. Remove `/root/work/` folder on each compute node

### First need to install ansible in venv:
___

```
sudo apt update
sudo apt upgrade
sudo apt install python3-dev python3-venv libffi-dev gcc libssl-dev git

python3 -m venv ansible
source ansible/bin/activate

pip install -U pip
pip install 'ansible<2.10'
```

### Set up k8s
___

Run:
`ansible-playbook -i aws-host kube-dependencies.yml`

After the above command, run the follow to init k8s on the master node:
Comment on lines +28 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yanmo96 Explain what is aws-host.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aws-host is a file with a list of hosts and their config for ansbile to run on. I can change the name to just hosts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yanmo96 yes, please change it to hosts.

`kubeadm init --pod-network-cidr=10.244.0.0/16`

Then run and put the follow line in `.profile` to be able to manage k8s:
`export KUBECONFIG=/etc/kubernetes/admin.conf`

To install flannel:
`kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml`

All done with k8s setup!

## Install other dependencies like ovs:
___

`ansible-playbook -i aws-host prepare_machine.yml`
The current `prepare_machine.yml` file will also install python and python-docker, which then used for pulling docker images later.

## Pull docker images:
___

`ansible-playbook -i aws-host pull_image.yml`

## Install Linkerd:
___

To install Linkerd, can follow the link or commands below:

https://linkerd.io/2.12/getting-started/

- Install the Linkerd CLI:
- `curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install | sh`
- Export the Linkerd path:
- `export PATH=$PATH:/home/ubuntu/.linkerd2/bin`
- Validate Kubernetes cluster:
- `linkerd check --pre`
- Install Linkerd:
- `linkerd install --crds | kubectl apply -f -`
- `linkerd install | kubectl apply -f -`
- Check if Linkerd is installed properly:
- `linkerd check`

## Install Meshnet
___

```
git clone https://github.com/networkop/meshnet-cni.git
cd meshnet
kubectl apply -k manifests/base
```

## Install Temporal
___
```
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
git clone https://github.com/temporalio/helm-charts.git
cd helm-charts/
helm dependencies update

helm install \
--set server.replicaCount=20 \
--set cassandra.config.cluster_size=5 \
--set prometheus.enabled=false \
--set grafana.enabled=false \
--set elasticsearch.enabled=false \
temporaltest . --timeout 25m

cd ~
git clone https://github.com/temporalio/tctl.git
cd tctl
make

# in a new window, or in screen run
kubectl port-forward services/temporaltest-frontend 7233:7233

# back to the main window
./tctl namespace register
```

## Install Alcor
```
# install alcor
./alcor_kubernetes/createYaml.sh

# after deploy run create default talble
./alcor_kubernetes/createDefaultTable.sh
```
5 changes: 5 additions & 0 deletions deployments/env_setup/kube-cluster/add-node-to-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- hosts: workers
become: yes
tasks:
- name: join cluster
shell: "kubeadm join 172.31.52.142:6443 --token xbgvlb.el3strzd70iirrp9 --discovery-token-ca-cert-hash sha256:46bc105f5d2c515552ac0706bb8385804c6775dd2a46a2c45a137acc95f286bf"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl -X POST -H "Content-Type: application/json" -H "Accept: */*" "http://localhost:30001/segments/createDefaultTable"
112 changes: 112 additions & 0 deletions deployments/env_setup/kube-cluster/alcor_kubernetes/createYaml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# MIT License
# Copyright(c) 2020 Futurewei Cloud
#
# Permission is hereby granted,
# free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


#!/bin/bash

# Install prerequisites
if [[ "$OSTYPE" == "linux-gnu" ]]; then

echo "Create ignite yaml files"

for d in db/ignite/*.yaml;
do
kubectl create -f $d
echo "Create ignite yaml - $d completed"
done

echo "Create yaml files done"


numberOfRnningPods="foo"
numberOfAllPods="bar"

while [ "$numberOfRnningPods" != "$numberOfAllPods" ];
do
sleep 10s
numberOfRnningPods=$(kubectl get pods -A --field-selector=status.phase=Running | wc -l)
numberOfAllPods=$(kubectl get pods -A | wc -l)
echo "numberOfRnningPods: " "$numberOfRnningPods"
echo "numberOfAllPods: " "$numberOfAllPods"
done

kubectl exec -it ignite-alcor-0 -n ignite-alcor -c ignite-alcor-node -- /opt/ignite/apache-ignite/bin/control.sh --activate
kubectl exec -it ignite-alcor-ip-0 -n ignite-alcor-ip -c ignite-alcor-ip-node -- /opt/ignite/apache-ignite/bin/control.sh --activate
kubectl exec -it ignite-alcor-mac-0 -n ignite-alcor-mac -c ignite-alcor-mac-node -- /opt/ignite/apache-ignite/bin/control.sh --activate
kubectl exec -it ignite-alcor-port-0 -n ignite-alcor-port -c ignite-alcor-port-node -- /opt/ignite/apache-ignite/bin/control.sh --activate
kubectl exec -it ignite-alcor-dpm-0 -n ignite-alcor-dpm -c ignite-alcor-dpm-node -- /opt/ignite/apache-ignite/bin/control.sh --activate
kubectl exec -it ignite-alcor-ncm-0 -n ignite-alcor-ncm -c ignite-alcor-ncm-node -- /opt/ignite/apache-ignite/bin/control.sh --activate


#cd apache-ignite/bin/
#./control.sh --activate

echo "ignite cluster has been activated"

for d in services/*.yaml;
do
kubectl create -f $d
echo "Create services yaml - $d completed"
done

echo "Cluster has been created"

elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "Install prerequisites in Mac OSX"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install maven

# echo "Clean build legacy controller project"
# mvn clean
# mvn compile
# mvn install -Dmaven.test.skip=true

echo "Clean build common library project"
cd lib
mvn clean
mvn compile
mvn install -Dmaven.test.skip=true
cd ..

echo "Clean build web project"
cd web
mvn clean
mvn compile
mvn install -Dmaven.test.skip=true
cd ..

echo "Build service one by one under services directory"
cd services
for d in ./*/;
do
echo "Build service - $d"
cd $d
mvn clean
mvn compile
mvn install -Dmaven.test.skip=true
cd ..
echo "Build service - $d completed"
done

elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
echo "Install prerequisites in Linux environment of Windows"
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
echo "Install prerequisites in MinGW of Windows"
else
echo "Unknown supported OS"
fi

echo "Build completed"
Loading