Try   HackMD
作者: 史啜林
撰寫日期:2021/11/24

<5G O-RAN 筆記3> xApp 部署/刪除/重新部署

xApp 是部署於 Near-RT RIC 的一種應用,這邊就基於之前說的來進行部署

事前確認

首先確認port 32080是否已被service 「r4-infrastructure-kong-proxy」使用

$ kubectl get service -A | grep 32080

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

此時,請先確認TCP port 32080 是否也同時被「kube-proxy」使用

$ netstat -anp | grep 32080

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

以下提供兩種解法,選擇好後才繼續進行下一步:

  1. 將官方指令中「$(hostname)」修改為「r4-infrastructure-kong-proxy」的 Cluster ip 地址(以下指令僅為示範差異,不要執行)
# 修改前
$ curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download"  --header 'Content-Type: application/json' --data-binary "@./onboard.hw.url"

# 修改後
$ curl --location --request POST "http://10.97.175.213:32080/onboard/api/v1/onboard/download"  --header 'Content-Type: application/json' --data-binary "@./onboard.hw.url"
  1. 設定port-forwarding功能
# 確認pod名稱
$ kubectl get pods -A | grep kong
ricplt        r4-infrastructure-kong-646b68bd88-tljzz                      2/2     Running     1          4h20m

# 設定port-forwarding (該視窗不可關閉,可於背景執行)
$ kubectl port-forward r4-infrastructure-kong-646b68bd88-tljzz 32088:32080 -n ricplt

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

當有資料進來時,便可以看到Handling的訊息出現

接著後續指令便可透過「localhost」的方式進行(以下指令僅為示範差異,不要執行)

# 修改前
$ curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download"  --header 'Content-Type: application/json' --data-binary "@./onboard.hw.url"

# 修改後
$ curl --location --request POST "http://localhost:32088/onboard/api/v1/onboard/download"  --header 'Content-Type: application/json' --data-binary "@./onboard.hw.url"

部署xApp

取得「Helloworld xApp」設定訊息拉下來,並存成url檔

$ echo '{ "config-file.json_url": "https://gerrit.o-ran-sc.org/r/gitweb?p=ric-app/hw.git;a=blob_plain;f=init/config-file.json;hb=HEAD" }' > onboard.hw.url

On-boarding xApp (這裡示範第二個解法)

$ curl --location --request POST "http://localhost:32088/onboard/api/v1/onboard/download"  --header 'Content-Type: application/json' --data-binary "@./onboard.hw.url"

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

驗證helm charts

$ curl --location --request GET "http://localhost:32088/onboard/api/v1/charts"

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

啟動xApp pod

$ curl --location --request POST "http://localhost:32088/appmgr/ric/v1/xapps"  --header 'Content-Type: application/json'  --data-raw '{"xappName": "hwxapp"}'
$ kubectl get pods -n ricxapp  # 要等待一下才會啟動

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

至此 xApp 部署已完成


刪除 xApp

首先中斷 xApp 的運行

$ kubectl get all -n ricxapp
$ kubectl delete deployment.apps/ricxapp-hwxapp -n ricxapp

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

找到運行管理 xApp 的 pod (appmgr)以及其 container

$ kubectl get pods -A | grep appmgr
$ docker container list | grep appmgr

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

接著進入 appmgr container 中,確認目前 appmr 所管理的 xApp 列表

$ docker exec -it 3c71f53defa4 sh
> pwd
> which helm
> helm list

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

helm list可以發現即使 xApp 的服務已經刪除,然而原本的 xApp 仍然還存在 appmgr 的儲存列表中
因此,若要完全刪除此 xApp,需進入 appmgr 進行刪除

> helm delete --purge hwxapp
> helm list

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

至此一個 xApp 完整被刪除


重新部署 xApp

首先確認 helm server 是正在運行的

$ helm serve

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

接著進入 appmgr container 中刪除 stable 選項,否則重新部署時會有超時(timeout)的問題

$ docker exec -it 3c71f53defa4 sh
> helm repo list
> helm repo remove stable
> helm repo list

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

接著重新執行部署 xApp 的流程
一樣先取得 url (若已經有了,則略過此步驟),將 xApp 上傳至 helm 儲存庫,最後部署 xApp