# SMO 安裝步驟 ###### tags: `Construction` ## Prerequisite Official-Guideline suggestion * OS: Ubuntu 18.04 LTS (Bionic Beaver) * CPU(s): 8 * RAM: 32 GB * Storage: 160 GB 實際操作 * OS : Ubuntu 18.04 LTS (Bionic Beaver) * CPU(s): 12 * RAM: 50 GB * Storage: 160GB 安裝相關套件 ```shell= # 更新 sudo apt update # 安裝 git vim net-tools screen sudo apt install git vim net-tools screen # 安裝 docker 18.09.7 sudo apt-get install -y 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 update sudo apt install docker-ce=5:18.09.7~3-0~ubuntu-bionic sudo systemctl enable docker # 安裝 helm 2.17.0 wget https://get.helm.sh/helm-v2.17.0-linux-amd64.tar.gz tar xvf helm-v2.17.0-linux-amd64.tar.gz sudo mv linux-amd64/helm /usr/local/bin/ sudo mv linux-amd64/tiller /usr/local/bin/ ``` ## 安裝 SMO [跟著步驟做](#Install-Step) [部署失敗解決辦法](#Trouble-Shooting) ### Install Step 下載 repo ```shell= sudo -i git clone http://gerrit.o-ran-sc.org/r/it/dep -b cherry cd dep git submodule update --init --recursive --remote ``` 設定版本資訊 ```shell= cd tools/k8s/etc # 註解 RIC tested 以下的版本資訊 # 刪除 ONAP Frankfurt 以下的註解 # 將 INFRA_HELM_VERSION 改成2.17.0 vim infra.rc ``` ![](https://i.imgur.com/whjpWqm.png) 安裝相依套件 ```shell= cd ../bin ./gen-cloud-init.sh ./k8s-1node-cloud-init-k_1_15-h_2_17-d_18_09.sh ``` 接著會卡在 ```shell= + helm version Client: &version.Version{SemVer:"v2.17.0", GitCommit:"a690bad98af45b015bd3da1a41f6218b1a451dbe", GitTreeState:"clean"} Error: could not find a ready tiller pod + echo 'Waiting for Helm to be ready' Waiting for Helm to be ready ``` 等他一下之後會成功並且自動 reboot。 執行以下指令,確認是否有9個pod running ```shell= sudo -i kubectl get pods --all-namespaces ``` ![](https://i.imgur.com/NBRnZWy.png) 接著以 screen 執行 helm ```shell= # 執行 screen 指令後,要再按一次 enter screen sudo -i helm serve ``` ![](https://i.imgur.com/A5fDzSr.png) 開啟另外一個 terminal,先建立 helm 的 k8s RABC ```shell= sudo -i # 注意第一個 command 執行,可能會顯示已經存在,不用理會,繼續執行第二、三個command 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"}}}}' ``` ![](https://i.imgur.com/qFlwxOn.png) 接下來的步驟會花很多時間(以小時計),所以用 screen 部署 smo 第二 因為cherry版本裡面沒有smo/ 所以我的做法是 從root 新開一個temp/ clone bronze 版本 然後複製過去 最後再把temp刪掉 ```shell= cd root/ mkdir temp && cd temp git clone http://gerrit.o-ran-sc.org/r/it/dep -b bronze # temp/dep/ cd dep # move smo from root/temp/dep to root/dep/ sudo mv smo/ ../../dep/ sudo rm -rf root/temp/ # 執行 screen 指令後,要再按一次 enter screen cd dep cd dep/smo/bin/ # 第一次執行 # 一定要先執行這個,雖然一定會失敗 ./install initlocalrepo ``` 過程中除了一開始的 clean 會有 error 以外,應該都不會有其他 error,注意執行到最後時,可能會花比較久的時間,很像是卡住,但不要動他,繼續等,直到結束 ![](https://i.imgur.com/h68RCwt.png) 出現以下畫面時,代表正在部署 ![](https://i.imgur.com/DCZHJJJ.png) 因為我們是使用 screen 部署,所以可以透過 detach 跳脫當前畫面 (應該一共兩個 terminal 可以detach,一個是跑 helm,一個是部署SMO) detach 方法: ctrl+A+D 若要重新 attach 可用以下相關指令 ```shell= # 看 screen 清單,會列出目前的 screen screen -list # 連接 screen, 以下指令的 pid 即為 screen -list 中名字前的數字 screen -r <pid or name> ``` 因為安裝真的很久,可以先去吃個飯... 過程中可以用以下指令看 pod 狀況 ```shell= kubectl get pods --all-namespaces ``` 如下 ![](https://i.imgur.com/EAT7qkN.png) 如果發現有些 pod 的 status 為 error 可用以下指令刪除,以觸發其自動重新部署 ```shell= # <pod-name> 請換成想刪除的 pod 的 name kubectl delete pod <pod-name> -n onap ``` 當全部變成 running 以後,會繼續下載XD 如果是第一次安裝 通常會遇到以下問題,這很常見 直接ctl+C 結束就行 ![](https://i.imgur.com/3ZDNxyR.png) 然後去改裡面的檔案 1. Create requirements.yaml ```shell= cd /root/dep/smo/bin/smo-deploy/smo-dep/nonrtric/helm/nonrtric # 創一個yaml檔案 sudo touch requirements.yaml # 然後把以下內容複製貼上 ``` ```yaml= dependencies: - name: nonrtric-common version: ^2.0.0 repository: "@local" - name: a1controller version: ~2.0.0 repository: "@local" condition: nonrtric.installA1controller - name: a1simulator version: ~2.0.0 repository: "@local" condition: nonrtric.installA1simulator - name: controlpanel version: ~2.0.0 repository: "@local" condition: nonrtric.installControlpanel - name: policymanagementservice version: ~2.0.0 repository: "@local" condition: nonrtric.installPms - name: enrichmentservice version: ~1.0.0 repository: "@local" condition: nonrtric.installEnrichmentservice - name: rappcatalogueservice version: ~1.0.0 repository: "@local" condition: nonrtric.installRappcatalogueservice - name: nonrtricgateway version: ~1.0.0 repository: "@local" condition: nonrtric.installNonrtricgateway ``` 2. 改 example_recipe.yaml ```shell= cd /root/dep/smo/bin/smo-deploy/smo-dep/nonrtric/RECIPE_EXAMPLE sudo vim example_recipe.yaml ``` 將以下flag 設為true ![](https://i.imgur.com/hHdrCBD.png) 3. 重新下載charts ```shell= cd /dep/smo/bin/smo-deploy/smo-oom/kubernete make all ``` 以上三步驟都做完之後 重新安裝 ```shell= cd /dep/smo/bin/ sudo ./install ``` 重新安裝之後,因為版本的問題 有兩個image 會因為權限的問題無法 docker pull 所以直接去docker hub pull 下來就行 然後更改image 的 tag 為指定的名稱 最後就會直接重新部署 最後就完成了 ### Trouble Shooting 假設部署失敗,有可能是以下幾個原因 要一一確認其正常運作 1. tiller pod 的 state is RUNNING ```shell= kubectl get pods --all-namespaces ``` 2. helm service in RUNNING state ```shell= sudo helm serve ``` 3. 有 35 個 charts listed for onap ![](https://i.imgur.com/KvXcjg7.png) ```shell= sudo helm search onap # 如果不存在 cd ~/oran/dep/smo/bin/smo-deploy/smo-oom/kubernetes make all ``` 然後等它重新下載 也是會卡在這個步驟 等就對了 ![](https://i.imgur.com/Uv38ytV.png) 4. 確認 /root/.helm helm plugin module ```shell= helm deploy # if command not found # 複製 plugin 到 /root/.helm cd ~/oran/dep/smo/bin/smo-deploy/smo-oom sudo cp -R ./kubernetes/helm/plugins/ /root/.helm ``` 5. requirements.yaml for nonrtric 在install smo步驟的最後 以可能會遇到以下情況 No resources found 無限loop ![](https://i.imgur.com/VlwTvww.png) 這個問題是因為 bronze 這個版本 git clone 不會連同這個檔案一起clone ```requirements.yaml``` ```txt= This error is due to the missing requirements.yaml in the directory /root/dep/smo/bin/smo-deploy/smo-dep/bin/../nonrtric/helm/nonrtric: ```