# <center>Upgraded KPIMON xApp deployment</center> **Repository**: https://github.com/openaicellular/upgraded-kpimon-xApp **Deployment Guide**: https://openaicellular.github.io/oaic/kpimon-workshop.html # Upgraded KPIMON deployment The xApp descriptor files (config.json) must be hosted on a web server when we use the xapp-onboarder to deploy xApps. To host these files we use Nginx to create a web server. In a New Terminal, go through the following commands one by one: ```bash $ sudo apt-get install nginx $ sudo systemctl status nginx $ cd /etc/nginx/sites-enabled $ sudo unlink default $ cd ../ $ cd ../../var/www $ sudo mkdir xApp_config.local $ cd xApp_config.local/ $ sudo mkdir config_files $ cd ../../../etc/nginx/conf.d $ sudo vim xApp_config.local.conf ``` Paste the following content in the conf file. ```bash server { listen 5010 default_server; server_name xApp_config.local; location /config_files/ { root /var/www/xApp_config.local/; } } ``` Save the configuration file and check if there are any errors in the configuration file. ```bash sudo nginx -t ``` We can now clone the repositories. Under the OAIC directory, run the following commands: ```bash $ cd <path-to-oaic-directory> $ git clone https://github.com/openaicellular/upgraded-kpimon-xApp.git ``` Create a symlink from the xapp’s config file (in this case kpimon). This can be replaced by another symlink in the future. Reload Nginx once this has been done. ```bash $ cd upgraded-kpimon-xApp $ sudo cp scp-kpimon-config-file.json /var/www/xApp_config.local/config_files/ $ sudo systemctl reload nginx ``` Check if the config file can be accessed from the newly created server. ```bash $ export MACHINE_IP=`hostname -I | cut -f1 -d' '` $ curl http://${MACHINE_IP}:5010/config_files/scp-kpimon-config-file.json ``` Now, we create a docker image of the KPIMON xApp using the given docker file. ```bash $ sudo docker build . -t xApp-registry.local:5008/scp-kpimon:1.0.1 ``` Get some variables of RIC Platform ready. The following Three variables represent the IP addresses of the services running on the RIC Platform. ```bash $ export KONG_PROXY=`sudo kubectl get svc -n ricplt -l app.kubernetes.io/name=kong -o jsonpath='{.items[0].spec.clusterIP}'` $ export APPMGR_HTTP=`sudo kubectl get svc -n ricplt --field-selector metadata.name=service-ricplt-appmgr-http -o jsonpath='{.items[0].spec.clusterIP}'` $ export ONBOARDER_HTTP=`sudo kubectl get svc -n ricplt --field-selector metadata.name=service-ricplt-xapp-onboarder-http -o jsonpath='{.items[0].spec.clusterIP}'` ``` Check for helm charts: ```bash $ curl --location --request GET "http://$KONG_PROXY:32080/onboard/api/v1/charts" ``` Next, we need to create a .url file to point the xApp-onboarder to the Nginx server to get the xApp descriptor file and use it to create a helm chart and deploy the xApp. Get IP address by one of the two commands below: ```bash $ hostname -I or $ echo $MACHINE_IP$ ``` Create url file: ```bash $ vim scp-kpimon-onboard.url ``` Paste the following in the scp-kpimon-onboard.url file. Substitute the `<machine_ip_address>` with the IP address of your machine. ```bash {"config-file.json_url":"http://<machine_ip_address>:5010/config_files/scp-kpimon-config-file.json"} ``` Save the file. Deploying the xApp: Check for helm charts and determine if the current xApp is present. If no helm chart exists, proceed. If a chart exists, either use it or delete it before continuing. ```bash $ curl -L -X POST "http://$KONG_PROXY:32080/onboard/api/v1/onboard/download" --header 'Content-Type: application/json' --data-binary "@scp-kpimon-onboard.url" $ curl -L -X GET "http://$KONG_PROXY:32080/onboard/api/v1/charts" $ curl -L -X POST "http://$KONG_PROXY:32080/appmgr/ric/v1/xapps" --header 'Content-Type: application/json' --data-raw '{"xappName": "scp-kpimon"}' ``` Verify xApp Deployment: There should be a ricxapp-scp-kpimon pod in ricxapp namespace: ```bash $ sudo kubectl get pods -A ``` In the terminal, print the KPIMON logs: ```bash $ sudo kubectl logs -f -n ricxapp -l app=ricxapp-scp-kpimon ``` If you already have KPIMON xApp deployed on your system, you need to restart the pod using the command below before running the rest of the commands. In a New Terminal, print the KPIMON Metrics: ```bash $ sudo kubectl exec -it -n ricxapp `sudo kubectl get pod -n ricxapp -l app=ricxapp-scp-kpimon -o jsonpath='{.items[0].metadata.name}'` -- tail -F /opt/kpimon.log ``` If the above deployment has an issue, you can restart the KPIMON xApp: ```bash $ sudo kubectl -n ricxapp rollout restart deployment ricxapp-scp-kpimon ```