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

<5G O-RAN 筆記1> O-RAN SMO管理平台

為因應計畫要用的 Demo,先把我做過的事情紀錄一下

部署架構如下圖所示

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 →

實驗環境

  • Ubuntu 18.04
  • docker 20.10.7
  • kubectl 1.16.0
  • kubeadm 1.16.0
  • kubelet 1.16.0

遇到問題別緊張,最下面有個「Debug Space」,可以多去看看,如果出現沒有在這上面的問題的話,再去請教 Google 大師吧~!

Step 1: 取得 O-RAN 官方 github 內容

O-RAN 官方提供的 script 包含了 k8s 的安裝,所以其實可以不用先手動安裝 k8s,但如果已經有的話,你可以減少很多步驟,很棒~!

以下範例我們用 B 版本示範與說明 (我在寫得時候已經更新到 D 了)

$ cd /home/user
$ sudo -i
$ git clone http://gerrit.o-ran-sc.org/r/it/dep -b bronze
$ cd dep
$ git submodule update --init --recursive --remote

Step 2: 產生 cloud-init 腳本

此步驟將生成一個腳本,該腳本將設置單節點 Kubernetes 集群以安裝 SMO 元件。

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 →
注意: 由於 O-RAN SC Bronze SMO 是來自 ONAP Frankfurt版本的元件,因此基礎設施軟件堆棧(Docker、Kubernetes 和 Helm)版本符合 ONAP 部署的要求。

## 將版本需求設定調整為Frankfurt
$ cd tools/k8s/etc
$ vim infra.rc

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 →

此時即可生成部署K8S叢集腳本

$ cd ../bin
$ ./gen-cloud-init.sh
$ ls

產生之腳本 「k8s-1node-cloud-init-k_1_15-h_2_16-d_18_09.sh」

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 →

Step 3: 安裝Kubernetes、Helm、Docker等

官方提供的腳本中有一些問題,在部署時需要注意所有套件是否正常安裝完成(尤其是docker)
這裡主要是將腳本指令中的docker進行手動安裝

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 →
Hint: 官方標準是要 docker 18.09.7 版本,但超過 18 以上的也 OK,因此提出兩種解決方法:

  1. 照著下面步驟裝指定的 docker 版本
  2. 將上面修改的「infra.rc」中的 INFRA_DOCKER_VERSION="18.09.7" 註解掉即可載預設最新的版本
$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu  $(lsb_release -cs)  stable"
$ sudo apt-get update
$ apt-cache madison docker-ce
$ sudo apt-get install docker-ce=5:18.09.7~3-0~ubuntu-bionic

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 →

修改腳本「k8s-1node-cloud-init-k_1_15-h_2_16-d_18_09.sh」helm內容

helm init --stable-repo-url=https://charts.helm.sh/stable

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 →

完成上述修改後即可開始執行腳本

$ ./k8s-1node-cloud-init-k_1_15-h_2_16-d_18_09.sh

完成後主機將進行重啟,重啟完畢後便可檢查是否有啟動9個pod

$ sudo su
$ kubectl get pods --all-namespaces

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 →

Step 4 : 安裝SMO相關套件

部署SMO相關套件,包含nonrtric、onap、ricaux,安裝順序為 onap → nonrtric → ricaux

ONAP 安裝

前往資料夾並修改install腳本

$ cd /home/<user>/dep/smo/bin
$ vim install

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 →

若是第一次執行則使用以下指令

$ ./install initlocalrepo

若不是則使用以下指令

$ ./install 

這過程會很久很漫長,請耐心等候

當執行完成後,腳本在安裝 nonrtric 會出現問題(0.0),此時便需要跳脫腳本,進行手動安裝

NONRTRIC 安裝

根據自己 Near-RT RIC 主機 IP 為何,修改「example_recipe.yaml」的「baseUrl」
(若無,則不需要管此處的 IP addresses)

$ vim dep/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml

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 →

運行其安裝腳本

$ cd dep/bin
$ ./deploy-nonrtric -f /home/oprueba/oran/dep/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml

等待其腳本完成,應啟動如下Pod

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 →

RICAUX 安裝

首先建立namespace

$ kubectl create ns ricinfra

接著取得相依套件

$ cd ~/dep/ric-aux/helm/infrastructure
$ helm dep update

開始進行安裝部署

$ cd ../
$ helm install -f ~/dep/RECIPE_EXAMPLE/AUX/example_recipe.yaml --name cherry-infra --namespace ricaux ./infrastructure

完成後可以先透過指令查詢是否成功,若不成功可以先進行修正

$ kubectl get all -n ricaux

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 →

確認沒問題後,可以進行VES的安裝

$ cd ves/
$ helm dep update
$ cd ../
$ helm install -f ~/dep/RECIPE_EXAMPLE/AUX/example_recipe.yaml --name cherry-ves --namespace ricaux ./ves

當完成後就可以查看所有pod的狀態

$ kubectl get pod -A

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 →

以上,SMO主機已部署完成


Debug Space

  1. 在執行 helm init 遇到的問題

    解決方式,參考網址
    在 init 後面加上如下指令即可
$ helm init --stable-repo-url=https://charts.helm.sh/stable

  1. 執行 helm deploy 時跳出不存在deploy指令時

    代表helm沒有deploy的指令,要去plugin相關套件才可,參考網址
$ git clone https://gerrit.onap.org/r/oom.git
$ cp -R oom/kubernetes/helm/plugins/ ~/.helm/

複製完成後,再次輸入helm指令便可看到deploy命令,完成後進行intall腳本繼續安裝

  1. 執行 install script 時,出現沒有 Chart.yaml

    請先執行以下步驟確認是否均正常,參考網址
  • 確認tiller pod有正常運行 - 應於部署k8s期間就已啟動
  • 確認helm service有正常運行
    • 透過指令查詢狀態,bash $ sudo helm serve,其結果應顯示如下圖所示

      顯示「already in use」代表已正常啟動;若僅檢視「Now serving you on 127.0.0.1:8879」則開啟新的terminal執行第3步
  • 確認透過指令「helm search onap」有找到35個charts list
    • 若顯示為「No results found」,則執行下一步
    • 前往指定位置進行「make all」指令
    ​​​​$ cd /home/oprueba/oran/dep/smo/bin/smo-deploy/smo-oom/kubernetes
    ​​​​$ make all
    
    此時有可能遇到此問題

    此處關鍵錯誤為:

    代表你的helm的初始化設定未完成,因此這邊必須進行初始化
    ​​​​$ helm init --client-only # 因為此處tiller已正常啟動,因此後面需要添加「--client-only」
    
    然而初始化的時候也有可能跳出Q1的問題,此時照著Q1的步驟做即可
    • 完成後再次執行「helm search onap」便可看到35個charts list,便可回到「步驟4 - onap安裝」繼續進行
      • 若透過指令「helm search onap」已確認有35個charts list但仍跳出第3的錯誤,則將「smo-deploy」資料夾刪除,並重新執行「install」指令
  1. 當在安裝 RICAUX 時,出現 ImagePullBackOff

    先透過describe指令查詢其image檔案是為何無法下載
$ kubectl describe pod/cherry-infra-kong-7d6555954f-h2fp9 -n ricaux


可以發現錯誤訊息為「Failed to pull image "kong-docker-kubernetes-ingress-controller.bintray.io/kong-ingress-controller:0.7.0(http://kong-docker-kubernetes-ingress-controller.bintray.io/kong-ingress-controller:0.7.0)": rpc error: code = Unknown desc = Error response from daemon: error parsing HTTP 403 response body: invalid character以下略」

可能為該映像檔聯結有誤,可進入設定檔進行修改

$ vim ~/dep/ric-aux/helm/infrastructure/subcharts/kong/values.yaml
repository: kong/kubernetes-ingress-controller tag: 0.7.0


完成後再回到步驟4的ricaux安裝流程

  1. 當在安裝 RICAUX 時,出現 UPGRADE FAILED

    解決方式,參考網址
$ kubectl create serviceaccount --namespace kube-system tiller
$ kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
$ kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'      
$ helm init --service-account tiller --upgrade