Commit 608e5cd6 authored by Yann Garcia's avatar Yann Garcia
Browse files

Adding MEC-Sandbox-Deployment-Guide

parent 244a631a
Loading
Loading
Loading
Loading
+150 KiB
Loading image diff...
+161 KiB
Loading image diff...
+136 KiB
Loading image diff...
+329 −0
Original line number Original line Diff line number Diff line
# Introduction


# Hardware requirement

Recommended System Requirements:

- Ubuntu 20.04 LTS or 22.04 LTS
- Intel I7-8750H ~4GHz
- 6 Cores - 12 threads
- 32GB RAM (64GB better)
- 500 GB SSD
- Ethernet/WLAN

Minimum System Requirements:
- Ubuntu 20.04 LTS or 22.04 LTS
- Intel Xeon E5-2600-v4
- 4 Cores
- 8GB RAM
- 70 GB SSD
- Ethernet/WLAN

Note: Minimum Requirements are tested on VM on server with above specs.

# System update

After system installation, the following updates and installation shall be done:

```bash
sudo apt-get update && sudo apt-get dist-upgrade -y && sudo apt-get autoremove --purge -y && sudo apt-get autoclean && sudo init 6
sudo apt update && sudo apt install libguestfs-tools openssh-server build-essential libssl-dev git net-tools emacs uidmap apt-transport-https tree iperf
sudo systemctl status ssh
```

In addition, you can install k9s tools

# Installation procedure for the MEC Sandbox (manually)

## Runtime Setup

### Dockers

```bash
curl -fsSL https://get.docker.com -o get-docker.sh
chmod 755 get-docker.sh && ./get-docker.sh
# Add user to docker group
sudo usermod -aG docker $USER
# Restart shell to apply changes
exit
```

### Kubernetes

- STEP 1 - Verify pre-requisites
```bash
sudo swapoff -a
sudo sed -i '/\/swap\.img/s/^/#/' /etc/fstab
```

- STEP 2 - Configure Containerd to use systemd
```bash
containerd config default | sudo tee /etc/containerd/config.toml

# Set Systemd to true
sudo sed -i '/\[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options\]/,/^\s*\[/{s/^.*SystemdCgroup *= *.*/        SystemdCgroup = true/}' /etc/containerd/config.toml

# Set sandbox image to recommended version
sudo sed -i '/\[plugins."io.containerd.grpc.v1.cri"\]/,/^\s*\[/{s/^\(\s*\)sandbox_image *= *.*/\1sandbox_image = "registry.k8s.io\/pause:3.10"/}' /etc/containerd/config.toml

# Restart containerd and docker
sudo systemctl restart containerd
sudo systemctl restart docker
```

                    
- STEP 3 - Install kubeadm, kubelet & kubectl (K8s version 1.33 Latest version)
```bash
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl gpg
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.33/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.33/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
```

- STEP 4 - Initialize master (details) using calico 
```bash
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.30.1/manifests/tigera-operator.yaml
# Wait for some time before running next command
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.30.1/manifests/custom-resources.yaml
# This will take some time depending on network bandwidth
# For Single node cluster
kubectl taint nodes --all node-role.kubernetes.io/control-plane-
```

- STEP 5 - Optionally add worker nodes to K8s cluster
    N/A

- STEP 6 - Enable kubectl auto-completion
```bash
echo "source <(kubectl completion bash)" >> ~/.bashrc
exit
```

- STEP 7 - Configure Docker Registry
in /etc/hosts, add the line
    172.29.10.52 meep-docker-registry
        127.0.0.1       localhost
        127.0.1.1       FSCOM-MEC
        172.29.10.52    meep-docker-registry
        # The following lines are desirable for IPv6 capable hosts
        ::1     ip6-localhost ip6-loopback
        fe00::0 ip6-localnet
        ff00::0 ip6-mcastprefix
        ff02::1 ip6-allnodes
        ff02::2 ip6-allrouters

```bash
VM_IP=<VM_IP>
LINE="$VM_IP meep-docker-registry"
grep -qF "$LINE" /etc/hosts || echo "$LINE" | sudo tee -a /etc/hosts

sudo cp /etc/kubernetes/pki/ca.crt /usr/local/share/ca-certificates/kubernetes-ca.crt
sudo chmod 644 /usr/local/share/ca-certificates/kubernetes-ca.crt
sudo update-ca-certificates
# Restart docker daemon
sudo systemctl restart docker
# Restart containerd daemon
sudo systemctl restart containerd
```

### HELM
```bash
sudo snap install helm --channel=3.3/stable --classic
sudo snap refresh helm --channel=3.3/stable --classic
```

### GPU Support
    N/A for me (DELL laptop)

## Development Setup

### Install GO

```bash
wget https://go.dev/dl/go1.17.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.17.linux-amd64.tar.gz
mkdir -p ~/gocode/bin
```
Update ~/.bashrc
    # Add the following lines at the end of your $HOME/.bashrc
    export GOPATH=$HOME/gocode
    export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin
```bash
echo -e '\n# Go environment setup\nexport GOPATH=$HOME/gocode\nexport PATH=$PATH:$GOPATH/bin:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc
```

Restart session

### Install NVM & NodeJS

```bash
sudo apt-get update
sudo apt-get install build-essential libssl-dev
# Download & install NVM
curl -skL https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh -o install_nvm.sh
bash install_nvm.sh
source ~/.profile
# Download Node
nvm install 12.19.0
npm install -g npm@6.14.8
# Final checks
node -v
npm -v
```

DO NOT UPDATE NPM (do not run npm install -g npm, got issues on my side)

### Install ESLint
```bash
npm install -g eslint@5.16.0
npm install -g eslint-plugin-react
# installation verification
eslint -v
```


### Install GolangCI-Lint
```bash
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.0
# Installation Verification
golangci-lint --version
```
## Deploying MEC Sandbox

### Clone MEC Sandbox frontend and Backend in the home directory
```bash
git clone https://labs.etsi.org/rep/mec/etsi-mec-sandbox.git
git clone https://labs.etsi.org/rep/mec/etsi-mec-sandbox-frontend.git
```
### Check out required branches, In my case i will use following branches for frontend and backend

```bash
# For frontend (etsi-mec-sandbox-frontend)
git checkout -b STF678_Task_5_TTF_T043 origin/STF678_Task_5_TTF_T043

# For backend (etsi-mec-sandbox)
git checkout -b STF678_Task_5_TTF_T043 origin/STF678_Task_5_TTF_T043
```

###	OAuth Applications using external providers
#### GIT
- Go to github.com's User Account --> Settings --> Developer settings --> OAuth Apps --> New OAuth App
- Application Name: ETSI MEC Sandbox
- Homepage URL: ``https://<IP-address-of-local-VM>``
- Application description: Optional description...
- Authorization callback URL: ``https://<IP-address-of-local-VM>/platform-ctrl/v1/authorize``
- NOTES:
  - An application logo can be added so that users can see it during authentication
  - Once created, keep note of the OAuth App Client ID & Secret; this secret is only temporarily available on GitHub... keep a copy in a safe place!
  - If a new secret is to be generated, the MEC Sandbox will have to be updated accordingly

### Configure MEC Sandbox
- Configure session && OAuth secrets
    - nano etsi-mec-sandbox/config/secrets.yaml
      -	Set a unique session encryption key
      - Set the OAuth provider client ID & secrets using the values from the OAuth Applications
    - Above two steps should also be performed for ``etsi-mec-sandbox-frontend/config/secrets.yaml``
- Configure deployment
    - Navigate to folder ``etsi-mec-sandbox-frontend/config/``
    - Edit following variables in ``.meep-repo-config.yaml``:
        - Set value of ``host`` (line 41) to your ``<VM_IP>``
        - Set value of ``ca`` (line 51) to ``self-signed``
        - Set value of ``redirect-uri`` (Line 82) to given format: ``https://<VM_IP>/platform-ctrl/v1/authorize``
    - Run following command
    ```bash
    sed -i 's/Thanos/Prometheus/g' ~/etsi-mec-sandbox-frontend/config/dashboards/mec-sandbox.json
    ```
- Build and deploy frontend
    - Navigate to frontend folder ``etsi-mec-sandbox-frontend`` and run following commands
    ```bash
    ./build.sh && ./deploy.sh
    ```
- Configure secrets for backend
    - Navigate to backend ``etsi-mec-sandbox``
    - Create secrets at backend using following commands
    ```bash
    python3 config/configure-secrets.py set config/secrets.yaml
    ```
    - Install meepctl using install.sh script in ``etsi-mec-sandbox/go-apps/meepctl/``
- Configure meepctl using following commands
    ```bash
        meepctl config ip <NODE_IP (VM_IP)>
        meepctl config gitdir ~/etsi-mec-sandbox
    ```
- Build demo 4
    - Navigate to ``etsi-mec-sandbox/examples/demo4-ue``
    - Now run script ``build-demo4-ue.sh``
- Deploy backend with following commands
    ```bash
    meepctl deploy dep
    # Incase while deploying any service fails that is normally due to network flactuations.
    # in that case run following command until all dependencies are deployed
    meepctl deploy dep -f # in case any dependency fails to deploy otherwise skip it
    meepctl build --nolint all
    meepctl dockerize all
    docker image prune -f
    meepctl deploy core
    ```
- Download monaco map using following steps
    ```bash
    cd ~
    wget https://geodata.maptiler.download/extracts/osm/v3.11/2020-02-10/europe/osm-2020-02-10-v3.11_france_monaco.mbtiles
    mv ~/osm-2020-02-10-v3.11_france_monaco.mbtiles ~/.meep/omt/
    # Restart the open-map-tiles-xxxx-yy container to load the maps
    kubectl get pods -A
    kubectl exec -it <meep-open-map-tiles-pod-name> -c open-map-tiles -- /bin/sh -c "kill 1"
    ```    
- Log in sandbox, address <VM_IP>, using github
    - Initialy you will not see any network scenario on the frontend so for that perform steps given below.
- Sign out from Sandbox
- Run the following commands
```bash
kubectl exec -it pod/meep-postgis-0 -- sh
psql -U postgres
\c meep_auth_svc
```
- ### Here you have two options either create exsiting user as admin or ADD A NEW USER
- For creating exsiting user as admin:
```bash
SELECT * FROM users;
UPDATE users SET role = 'admin' WHERE id = 1;
```
- For creating a new user
```bash
INSERT INTO users (provider, username, password, sboxname, role) VALUES ('github', '<github-user-name>', '', '<sandbox>','admin');
# Here <sandbox> is the namespace created for the user in k8s cluster
# Example
#INSERT INTO users (provider, username, password, sboxname, role) VALUES ('github', 'mudassarkhan', '', 'sbxc8xbgqx','admin');
```
- ### Add Network Scenarios
- Download all of yaml files inside ``etsi-mec-sandbox-frontend/networks`` to your local PC
- Sign in sandbox
- Navigate to admin panel by append ``/alt`` at the end of http address. 
* NOTE: If this id exsits as admin only then you can access admin panel
- Admin Panel
![Admin Panel](Images/Admin%20panel.PNG)
- Navigate to configure 
![Configure](Images/Configure.PNG)
- Import Network scenario using import button (These are yaml files download previously to your local PC)
- Then save the scenario using save button
![Save](Images/save.PNG)
- Repeat these steps for all scenarios
- After importing all scenarios go back to frontend by just removing ``/alt`` from address
- Now you have complete sandbox up and running.
## Incase of redeployment
- Delete previous deployment
    ```bash
    meepctl delete dep && meepctl delete core
    ```
- Build and deploy frontend (./build.sh && ./deploy.sh) in ``etsi-mec-sandbox-frontend``
- Now only deploy backend
    ```bash
    meepctl deploy dep && meepctl build all --nolint && meepctl dockerize all && docker image prune -f && meepctl deploy core
    ```
 No newline at end of file
+1 −0
Original line number Original line Diff line number Diff line
@@ -10,5 +10,6 @@ This material is intended to define MEC Sandbox capabilities.
* [MEC Sandbox Scenario - Macro Network City Scenario - Monaco](./Macro-Network-Scenario/README.md)
* [MEC Sandbox Scenario - Macro Network City Scenario - Monaco](./Macro-Network-Scenario/README.md)
* [MEC Sandbox User Interface & Wireframe ](./Sandbox-User-Interface)
* [MEC Sandbox User Interface & Wireframe ](./Sandbox-User-Interface)
* [MEC Sandbox Software Architecture](./Software-Architecture)
* [MEC Sandbox Software Architecture](./Software-Architecture)
* [MEC Sandbox Deployment Guide](./MEC-Sandbox-Deployment-Guide)
* [MEC Sandbox Feature Development Guide](./Feature-Development-Guide)
* [MEC Sandbox Feature Development Guide](./Feature-Development-Guide)
* [MEC Sandbox API Development Guide](./Mec_Sandbox_API)
* [MEC Sandbox API Development Guide](./Mec_Sandbox_API)