# Near Real Time RIC Deployment
## Environment
Use OSC Release F package
Ubuntu 20.4(18.04~)
Kubeadm 1.16 (suggest to use 1.18~1.21)
Note: SMO/Non RT RIC use “microk8s 1.22” by default
But as discussions in the OSC web, using Kubeadm 1.16 will meet some troubles when set up Kubernetes. So we suggest to use Kubeadm 1.18 for deployment.
You need to switch to root account to install Near RT RIC package, and after the installation, you can use [F Release Docker Image List](https://wiki.o-ran-sc.org/display/IAT/F+Release+Docker+Image+List) to check(compare) the pod lists that are installed.
## Deploy Step
Please refer to "[Near-RT RIC Deployment](https://wiki.o-ran-sc.org/display/SIM/Near-RT+RIC+Deployment)".
1. clone the git
2. intall k8s and helm
3. install_common_templates_to_helm
4. setup-ric-common-template
5. deploy ricplt (ric platform)
6. deploy ricaux (ric aux)
### Clone the git
```
git clone "https://gerrit.o-ran-sc.org/r/ric-plt/ric-dep"
```

Use file manager to navigate to the ric-dep/bin folder and modify the parameters.
#### Modify "install_k8s_and_helm.sh"
change "KUBEV" parameter to use kubeadm 1.18

in kubeadm 1.18, there are only 7 pods will be deployed. So change the number "8" to "7" and save the script file.

#### Intall k8s and helm
Execute the installation script:
```
cd ric-dep/bin
sudo ./install_k8s_and_helm.sh
```




Check the K8s status
```
kubectl get pods -A
```

#### Install_common_templates_to_helm
```
./install_common_templates_to_helm.sh
```

#### Setup-ric-common-template
```
./setup-ric-common-template
```

#### Deploy ricplt (ric platform)
Under ~/ric-dep repo folder, please check below 2 parameter files and make sure the parameters.
```
nano helm/appmgr/values.yaml
# replace tiller image with these values
# tiller:
# registry: ghcr.io
# name: helm/tiller
# tag: v2.12.3 (this tag number don't mind)
nano helm/infrastructure/values.yaml
# replace tiller image with these values
# tiller:
# registry: ghcr.io
# name: helm/tiller
# tag: v2.12.3 (this tag number don't mind)
```

edit the ../RECIPE_EXAMPLE/example_recipe_latest_stable.yaml file
make sure "extsvcplt" parameter:

#### About influxdb and jaegeradapter components
By default, these two parts do not be deployed. If you want to deplay them, please modify the "install" file under /ric-dep/bin and add into the line "COMPONENTS"
```
COMPONENTS="infrastructure dbaas appmgr rtmgr e2mgr e2term a1mediator submgr vespamgr o1mediator alarmmanager influxdb jaegeradapter $LIST_OF_COMPONENTS"
```
After deployed influxdb, you still have to create a persistent volume:
1. Create a file nano pv.yaml
2. Add this into the file:
```
apiVersion: v1
kind: PersistentVolume
metadata:
name: ricplt-influxdb-meta-0 (or maybe r4-influxdb-influxdb2)
labels:
name: local
spec:
capacity:
storage: 8Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
```
then apply the persistent volume (suggest apply before deploy influxdb)
```
kubectl apply -f pv.yaml
kubectl get pv
```

To retrieve the password for the 'admin' user:
```
echo $(kubectl get secret r4-influxdb-influxdb2-auth -o "jsonpath={.data['admin-password']}" --namespace ricplt | base64 --decode)
```
or maybe ca just deploy docker image: docker.io/influxdb:1.8.0-alpine
Deploy near RT RIC:
```
./install -f ../RECIPE_EXAMPLE/example_recipe_latest_stable.yaml
```

check the ricplt deployment and make sure the pods all up and running
```
kubectl get pods -n ricplt
kubectl get pods -n ricinfra
```

#### Deploy ricaux (ric aux)
```
cd ~/
git clone "https://gerrit.o-ran-sc.org/r/it/dep"
cd dep
```
Under ~/dep repo folder, please check below 2 parameter files and make sure the parameters.
```
nano RECIPE_EXAMPLE/AUX/example_recipe.yaml
# replace the ric-dashboard image with the one below
# image:
# registry: nexus3.o-ran-sc.org:10002/o-ran-sc
# name: ric-dashboard
# tag: 2.1.0
extsvcaux:
ricip:""
auxip:""
nano ric-aux/helm/infrastructure/subcharts/kong/values.yaml
# replace the ingressController image with the one below
#ingressController:
# enabled: true
# image:
# repository: docker.io/kong/kubernetes-ingress-controller
# tag: 0.7.0
```


```
apt install dos2unix
cd dep/bin
dos2unix -o deploy-ric-aux
kubectl label --overwrite nodes $(hostname) portal-storage=enable
kubectl label --overwrite nodes $(hostname) aaf-storage=enable
./deploy-ric-aux ../RECIPE_EXAMPLE/AUX/example_recipe.yaml
```

check the ricaux deployment and make sure the pods all up and running
```
kubectl get pods -n ricaux
```