[雲端] Rancher === ###### tags: `雲端`, `Rancher` <br> ![](https://i.imgur.com/ldXQn23.png) [TOC] <br> :::success :checkered_flag: **預備知識:** - 基礎 Docker 概念 - 基礎 Container 概念 ::: <br> ## Rander 的故事 - [梁胜:用户是 Docker 最大的筹码](https://www.infoq.cn/article/sheng-talk-about-docker/) - [寵物與牛的故事](https://www.luoow.com/dc_tw/200112514) <br> ## Rancher 的本質 - ### 本質 - 被打包成 Docker 的軟體套件 - 為了==容器==和==叢集==的管理,提供了「**視覺化**」操作界面 - ### Github - https://github.com/rancher/rancher - [2016 年,推出 1.0 正式版](https://www.ithome.com.tw/news/105022) <br> ## Rancher 的架構 - 主從式架構 ![](https://i.imgur.com/QGaG3D1.png =60%x60%) <br> ## Rancher 的安裝方式 - ### STEP 1:[安裝 Docker](https://rancher.com/docs/rancher/v2.x/en/installation/requirements/installing-docker/) ``` curl https://releases.rancher.com/install-docker/18.09.sh | sh ``` 新版 ``` curl https://releases.rancher.com/install-docker/19.03.sh | sh ``` - ### STEP 2:Server 端 :::warning :warning: **注意底下 docker image 的不同** - Rancher 的容器(Container)管理平台,使用的 image 是 **rancher/==server==** - Rancher 的叢集(Cluster)管理平台,使用的 image 是 **rancher/==rancher==** ::: - #### 安裝 Container 的管理平台 (安裝過程,需 3 ~ 5 分鐘) :::info :information_source: **[安裝指令](https://rancher.com/docs/rancher/latest/en/quick-start-guide/) (官網資訊,目前版本 1.6.30 )** <code style="background: none;"> sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server </code> ::: - 需要等待數分鐘(3~5min)後,才能在瀏覽器上看到 http://localhost:8080 http://127.0.0.1:8080 [![](https://i.imgur.com/wQpbwz6.png)](https://i.imgur.com/wQpbwz6.png) - 在 AWS 上操作 - 可以成功啟動 rancher/server - 但無法當 agent,會 out of memory,因為 VM 只有 1GB RAM > docker: failed to register layer: Error processing tar file(exit status 2): fatal error: runtime: out of memory - #### 安裝 Cluster 的管理平台 :::info :information_source: **安裝指令** sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher ::: - ### STEP 3:Client 端 (Rancher 稱為 agent ) 由 rancher server 提供指令 <br> <hr> <br> ## Rancher 的容器(Container)管理平台 ### [使用 Rancher 的理由與痛點](https://blog.hellosanta.com.tw/網站設計/伺服器/視覺化管理眾多-docker-容器與部署的好工具:rancher) - Docker 指令控制也太麻煩了! - 如果發生問題還要連回主機處理耶。 - 有些事都還是要自己來把服務堆疊,速度不夠快。 - 容器與主機的權限管理一多就亂了怎麼辦? - ### 補充: - Rancher 可以說是 Container 的管理工具 - 在 Rancher 上 - 可以直接透過表單,建立 Container,不需要操作指令 [![](https://i.imgur.com/NtGred8.png)](https://i.imgur.com/NtGred8.png) <br> - 有 Container 中心管理平台,不需要操作指令,可透過 UI 點選、查詢與監控狀態 [![](https://i.imgur.com/mRL7CRK.png)](https://i.imgur.com/mRL7CRK.png) <br> [![](https://i.imgur.com/g6T5XJm.png)](https://i.imgur.com/g6T5XJm.png) <br> - 亦附有線上「命令列模式」 ![](https://i.imgur.com/nnNdsox.png) <br> ![](https://i.imgur.com/TAODnv0.png) <br> ### 新增主機(Add Host) - #### 入口點 - Infrastructure / Add Host - #### 主從架構 - 主機1:Rancher Server - 主機2:client 1 (角色:agent) - 主機3:client 2 (角色:agent) - 主機4:client 3 (角色:agent) - ... - #### 必須先設定 server 的 IP,這樣 agent 才可以跟 server 連線 server 和 agent 必須一起同在內網,或是一起同在外網 [![](https://i.imgur.com/KEgw7FY.png)](https://i.imgur.com/KEgw7FY.png) - #### 在 client 上,啟動指定的 docker >$ sudo docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.11 http://10.78.153.29:8080/v1/scripts/9EDE1261C7F236542905:1577750400000:O42CDJSUUy9HzguCQ6t8iylSAU > [![](https://i.imgur.com/qbSjZ8n.png)](https://i.imgur.com/qbSjZ8n.png) <br> 啟動 agent 後的結果:在 agent 機器上查看 [![](https://i.imgur.com/wUb3l5D.png)](https://i.imgur.com/wUb3l5D.png) <br> 啟動 agent 後的結果:在 Server UI 上查看 [![](https://i.imgur.com/feQNQCU.png)](https://i.imgur.com/feQNQCU.png) - #### with K8S - [Rancher 1.6 Docs / 设置KUBERNETES](https://rancher.com/docs/rancher/v1.6/zh/kubernetes/) - [Unable to access Rancher Kubernetes dashboard UI after upgrading to v1.8.9 - Error: Service Unavailable #12167](https://github.com/rancher/rancher/issues/12167) > You can follow the following order to see where the problem is: > 1. Check if etcd is healthy by running etcdctl cluster-health in the etcd containers > 2. Check if nodes are reporting as Ready by using kubectl get nodes > 3. See addon pod status using kubectl get pods -n kube-system - [Unable to open dashboard. #3322](https://github.com/kubernetes/dashboard/issues/3322) ``` $ kubectl -n kube-system get svc -o wide $ kubectl -n kube-system describe pod kubernetes-dashboard-77fd78f978-f8bxd ``` - ```-n```: namespace - 測試叢集的幾項方式 <br> ### trouble-shooting - "Error getting config." error="Invalid key content" (==still not work==) - [Running rancher/server (or any container) on RancherOS on GCE needs MTU configured to 1460 #8910](https://github.com/rancher/rancher/issues/8910) - [Rancher_Log_Errors:STARTUP FAILED #10347](https://github.com/rancher/rancher/issues/10347) <br> ### 容器參考資料 - [[Step-by-Step] Rancher Server v1](https://devonhubner.org/rancher_server/) - [Docker視覺化管理工具Rancher](https://www.itread01.com/content/1541623047.html) - [Rancher - 管理內部及外部 (Azure) Docker Cluster 的好工具](https://columns.chicken-house.net/2016/04/29/rancher-on-azure-lab/) <br> <hr> <br> ## Rancher 的叢集(Cluster)管理平台 ### 特色 - [Rancher Labs發布Rancher 2.0技術 支持多集群管理](https://kknews.cc/news/gbjb8be.html) > 在同一平台上管理全部Kubernetes集群 ### 新增叢集 - [Launching Kubernetes on Existing Custom Nodes](https://rancher.com/docs/rancher/v2.x/en/cluster-provisioning/rke-clusters/custom-nodes/) - [2. Create the Custom Cluster](https://rancher.com/docs/rancher/v2.x/en/cluster-provisioning/rke-clusters/custom-nodes/#2-create-the-custom-cluster) - Cluster / Add Cluster / Import an existing cluster > Import an existing Kubernetes cluster. For K3S backed clusters, Rancher can manage some aspects of the cluster configuration, such as version upgrades. For standard Kubernetes clusters, the provider will manage provisioning and configuration. > - 匯入現有的 Kubernetes 叢集 > - 對於 K3S 支援的叢集,Rancher 可以管理叢集配置的某些方面,例如版本升級。 > - 對於標準的 Kubernetes 叢集,提供商將管理配置和組態。 > [![](https://i.imgur.com/D50wx8S.png)](https://i.imgur.com/D50wx8S.png) <br> ``` $ kubectl apply -f https://10.78.153.29/v3/import/rwbs4rhznmgrnkdxdrzgjldz76j9d8r97k4r2dr7hklv2qjnj6qpmj.yaml Unable to connect to the server: x509: certificate signed by unknown authority ``` ``` $ curl --insecure -sfL https://10.78.153.29/v3/import/rwbs4rhznmgrnkdxdrzgjldz76j9d8r97k4r2dr7hklv2qjnj6qpmj.yaml | kubectl apply -f - clusterrole.rbac.authorization.k8s.io/proxy-clusterrole-kubeapiserver created clusterrolebinding.rbac.authorization.k8s.io/proxy-role-binding-kubernetes-master created namespace/cattle-system created serviceaccount/cattle created clusterrolebinding.rbac.authorization.k8s.io/cattle-admin-binding created secret/cattle-credentials-46f3854 created clusterrole.rbac.authorization.k8s.io/cattle-admin created deployment.apps/cattle-cluster-agent created daemonset.apps/cattle-node-agent created ``` <br> ### 新增叢集 / 新增現有的叢集 - 新增現有的 k8s cluster 之過程 - 連線到目的節點 ``` ssh ocis-tn@10.78.153.130 ``` ![](https://i.imgur.com/XrvJFEI.png) <br> - 查看當前節點,是否有 k8s cluster 資訊 ![](https://i.imgur.com/HtAlGfe.png) <br> - 在 Rancher Server 上,新增一個叢集管理窗口 <img src="https://i.imgur.com/LS6ScN7.png" style="border: solid 1px"> <br> <img src="https://i.imgur.com/NltdGxV.png" style="border: solid 1px"> <br> <img src="https://i.imgur.com/DaK5vPR.png" style="border: solid 1px"> - 可先執行中間這行的指令,可能會印出憑證問題 ``` kubectl apply -f https://10.78.153.29/v3/import/kg8ktm7bwk2hmbpsp92f66pt5z2whfnhrsprj6z2rt5nkw8k69sbsk.yaml ``` 憑證問題會顯示底下的訊息: ``` Unable to connect to the server: x509: certificate signed by unknown authority ``` - 若有憑證問題,則執行下面這行的指令 ``` curl --insecure -sfL https://10.78.153.29/v3/import/kg8ktm7bwk2hmbpsp92f66pt5z2whfnhrsprj6z2rt5nkw8k69sbsk.yaml | kubectl apply -f - ``` <br> - 在當前的前點,執行 Rancher Server 提供的指令 ![](https://i.imgur.com/j8O0bST.png) - 執行完指令後,會在 Rancher Server 的 cluster 清單中,出現新增的 cluster ![](https://i.imgur.com/hoHrQpI.png) - 狀態為 Active 表示「成功」且 cluster 處於健康的狀態 <br> ### 架構 - [Rancher Architecture Overview](https://godleon.github.io/blog/Rancher/Rancher-architecture-overview/) - Rancher Server Architecture - Rancher server 如何與下游的 k8s cluster 通訊 - [Port Requirements for the Rancher Management Plane](https://rancher.com/docs/rancher/v2.x/en/installation/requirements/#port-requirements) [![](https://i.imgur.com/4rbJDZv.png)](https://i.imgur.com/4rbJDZv.png) <br> ### 問題集 - Cluster Server: Unavailable > Cluster health check failed: Failed to communicate with API server: Get https://10.0.2.15:6443/api/v1/namespaces/kube-system?timeout=30s: dial tcp 127.0.0.1:6443: i/o timeout > [![](https://i.imgur.com/V6QXDpY.png)](https://i.imgur.com/V6QXDpY.png) <br> - VM node: not found [![](https://i.imgur.com/o3VAOeZ.png)](https://i.imgur.com/o3VAOeZ.png) <br> - 加入叢集時,etcd & control-plane 起不來 > embed: rejected connection from "192.168.3.2:60362" (error "tls: failed to verify client's certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kube-ca")", ServerName "") - [Ha deployment failed #21926](https://github.com/rancher/rancher/issues/21926) ![](https://i.imgur.com/iVvoots.png) ```bash docker stop $(docker ps -aq) docker system prune -f docker volume rm $(docker volume ls -q) rm -rf /etc/ceph \ /etc/cni \ /etc/kubernetes \ /opt/cni \ /opt/rke \ /run/secrets/kubernetes.io \ /run/calico \ /run/flannel \ /var/lib/calico \ /var/lib/etcd \ /var/lib/cni \ /var/lib/kubelet \ /var/lib/rancher/rke/log \ /var/log/containers \ /var/log/pods \ /var/run/calico ``` - 無法加入叢集 ```bash $ curl --insecure -sfL https://10.78.26.241/v3/import/wplgz94d7qpw4sjq2rqkzbsc9qmwzjjv8p6jrkcpx57hw952ch24w7.yaml | kubectl apply -f - clusterrole.rbac.authorization.k8s.io/proxy-clusterrole-kubeapiserver unchanged clusterrolebinding.rbac.authorization.k8s.io/proxy-role-binding-kubernetes-master unchanged namespace/cattle-system unchanged clusterrolebinding.rbac.authorization.k8s.io/cattle-admin-binding unchanged clusterrole.rbac.authorization.k8s.io/cattle-admin unchanged Error from server (Forbidden): error when creating "STDIN": serviceaccounts "cattle" is forbidden: unable to create new content in namespace cattle-system because it is being terminated Error from server (Forbidden): error when creating "STDIN": secrets "cattle-credentials-4551c2e" is forbidden: unable to create new content in namespace cattle-system because it is being terminated Error from server (Forbidden): error when creating "STDIN": deployments.apps "cattle-cluster-agent" is forbidden: unable to create new content in namespace cattle-system because it is being terminated Error from server (Forbidden): error when creating "STDIN": daemonsets.apps "cattle-node-agent" is forbidden: unable to create new content in namespace cattle-system because it is being terminated ``` - 共同問題:namespace cattle-system 有問題 > unable to create new content in namespace cattle-system because it is being terminated - 印出狀態 ``` $ kubectl get ns NAME STATUS AGE cas Active 12d cattle-system Terminating 7h55m <---------- default Active 40d demo Active 32d demo-echo Active 39d ``` - 解法 [A namespace is stuck in the Terminating state](https://www.ibm.com/support/knowledgecenter/en/SSBS6K_3.2.0/troubleshoot/ns_terminating.html) - Manually delete a terminating namespace - terminal-1 ``` # 檢視 cattle-system 狀態 $ kubectl get namespaces NAME STATUS AGE cas Active 14d cattle-system Terminating 44h default Active 41d demo Active 34d ... # 查看 namespace 組態,然後在匯出變更 $ kubectl get namespace cattle-system -o yaml $ kubectl get namespace cattle-system -o json > tmp.json $ nano tmp.json # 建立暫時的 IP 和 port $ kubectl proxy # 前往 terminal-2 操作 #重新檢視 cattle-system 狀態 $ kubectl get namespaces ``` - terminal-2 ``` $ curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/cattle-system/finalize ``` <br> ### 參考資料-中文 - [新版 Rancher 2.4 可支援 10 倍量叢集,官方預告未來可支援百萬叢集](https://www.ithome.com.tw/news/136709) > Rancher 2.4 最佳化了: 1. 叢集管理 2. Kubernetes 控制器 > 大幅降低: - 記憶體用量 - CPU負載 > 因此大幅提升可管理的叢集數量 - [視覺化管理眾多 Docker 容器與部署的好工具:Rancher](https://blog.hellosanta.com.tw/網站設計/伺服器/視覺化管理眾多-docker-容器與部署的好工具:rancher) - [Rancher - 管理內部及外部 (Azure) Docker Cluster 的好工具](https://columns.chicken-house.net/2016/04/29/rancher-on-azure-lab/) - [使用Rancher Server部署本地多節點K8S叢集](https://www.itread01.com/content/1578470467.html) - [22 启用 Rancher 群集的监控](https://zhuanlan.zhihu.com/p/104480704) - [云原生时代, Kubernetes 多集群架构初探](https://developer.aliyun.com/article/713012) <br> ### 參考資料-英文 - [From Web Scale to Edge Scale: Rancher 2.4 Supports 2,000 Clusters on its Way to 1 Million](https://rancher.com/blog/2020/rancher-edge-scale) - 從 Web 規模到 Edge 規模 - Rancher 可支援 100 萬個 K8S 叢集 - 但誰會用什麼多叢集? - 理由1:K8S 未來是多叢集的,且是完全異質的 - 理由2:根據不同的環境、使用案例,執行各自的最佳 K8S 部署 - [Rancher](https://rancher.com/) - [Why Kubernetes?](https://rancher.com/kubernetes/) - Diatango 的補充 - While Rancher can manage any CNCF-certified Kubernetes distribution regardless of its location, we recommend - [RKE](https://github.com/rancher/rke) for hybrid cloud environments 可以在容器裡運行輕量版的 kubernetes - [K3s](https://github.com/rancher/k3s) for IoT and edge use cases -> 約40MB - 看起來 [Rancher](https://github.com/rancher/rancher) 是一個 container management platform 而 RKE/K3S 則是裝在不同環境下的輕量版 kubernetes cluster - [Rancher Server Architecture](https://godleon.github.io/blog/Rancher/Rancher-architecture-overview/) <br> <hr> <br> ## Rancher Pipeline (@容器管理平台) ### 操作實例 - #### Step1: @容器管理平台 / Catelog,輸入 ==pipeline== 進行過濾所要的 app ![](https://i.imgur.com/cB63Bz5.png) - #### Step2: @容器管理平台 / Catelog / Rancher Pipeline, 安裝 ==Rancher Pipeline== (選項皆為預設) ![](https://i.imgur.com/O2TZh5t.png) <hr> ![](https://i.imgur.com/x8y0VZ6.png) - 備註: - 首次安裝時,等了一段非常久的時間,但二次安裝卻只要 1 分半 - 重新安裝後,前次的操作紀錄都還留著 - 安裝完後,導覽列上的最後一個頁籤,出現了 ==Pipeline== ![](https://i.imgur.com/S0Q0BpW.png) - #### Step3: @容器管理平台 / 導覽列, 點選 ==Pipeline== 進入,Pipeline 界面如下 ![](https://i.imgur.com/By85muU.png) - #### Step4: @容器管理平台 / Pipeline, 點選 ==齒輪== 進入設定 Pipeline<br>選擇綁訂 GitLab 作為原始碼來源 ![](https://i.imgur.com/1047wRr.png) ![](https://i.imgur.com/TcmIHtE.png) - **SCM 術語** - Source Code Management 原始碼管理 - 指得就是像 Github, Gitlab 等等 - **選擇 Gitlab 來操作,需要 Gitlab 提供** - webhook 帳號 (Client ID) - webhook 密碼 (Client Secret) - webhook 事件,則會傳遞到 ```http://10.78.153.29:8081/r/projects/1a5/pipeline-ui/``` <br> :::success :checkered_flag: **所以,目前的 action:** - 安裝 gitlab - 亦可使用外部的 [gitlab](https://gitlab.com/),如果可以存取的話 ::: - #### Step5: @容器管理平台 / Catelog,輸入 ==gitlab== 進行過濾所要的 app ![](https://i.imgur.com/aWaHUuz.png) - #### Step6: @容器管理平台/Catelog/Gitlab,安裝 ==gitlab== ![](https://i.imgur.com/PkDHCLB.png) ![](https://i.imgur.com/YnxDQJg.png) - 由於 app 會安裝到所加入的主機(假設註冊的主機 IP 是 10.78.153.130) ![](https://i.imgur.com/rPtunx1.png) - Hostname: 10.78.153.130 Registry hostname: 10.78.153.130 (目前無 hostname, 只好填 IP) - prefix 若選擇 https 則需要對應的憑證 /etc/gitlab/ssl/10.78.153.130.crt 否則會因找不到憑證,而一直印出 error - Gitlab 容器初始化過程,需等待 8 分鐘 ![](https://i.imgur.com/MZ02vHP.png) - #### Step7: @Gitlab - **首次使用,需要設定 root 的密碼** ![](https://i.imgur.com/LFGlYQK.png) <br> - **註冊使用者帳密** ![](https://i.imgur.com/dqd7oso.png) <br> - **新增一個 webhook** ![](https://i.imgur.com/exlrcS5.png) - 重新導向 URI - Rancher pipeline 所提供的 URI - 當 gitlab API 有被呼叫時,也會同時導向到 pipeline URI - 這個 API 可能是指 CRUD(Create, Read, Update, Delete) 之類的 API <br> - **webhook 新增完後,會產生一組** - webhook 帳號 (Client ID) - webhook 密碼 (Client Secret) ![](https://i.imgur.com/InZUVy9.png) <br> - **將 webhook 的帳密,回填到 Rancher pipeline** ![](https://i.imgur.com/2ZgkAsf.png) - [Use a private GitLab installation] 選項要打勾 若沒有打勾,則會轉接到外部的 gitlab ![](https://i.imgur.com/XNBtBVV.png) > Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method. - **Gitlab 會跳出詢問,是否允** ![](https://i.imgur.com/qKXA7yh.png) - URL - http://10.78.153.130/oauth/authorize - ?client_id=5a4cf4ac07b389a3a049c7d6cb9691f5f47da8b24cd3501c8acda21d414dec9e - &response_type=code - &state=0.5998188123213402 - &redirect_uri=http%3A%2F%2F10.78.153.29%3A8081%2Fr%2Fprojects%2F1a5%2Fpipeline-ui%2F%3FisTest%3D1 - http://10.78.153.29:8081/r/projects/1a5/pipeline-ui/?isTest=1 - #### Step8: @容器管理平台 / Pipeline, 這樣就可以開始打造自己的 pipeline ![](https://i.imgur.com/6LJwd2C.png) <br> ![](https://i.imgur.com/Orlhggp.png) - 詳細介紹,暫略 - **測試情境**:==自動更新 nginx web server== - 建立一個 nginx web server - 使用 Dockfile ```dockerfile FROM nginx # show the current version RUN echo 6 >> /usr/share/nginx/html/v.htm ``` - 編輯版號後,上傳到 gitlab,就會觸發 Rancher pipeline - 重新編譯 docker image,然後更新 container - 查看版號:http://10.78.153.130:8080/v.htm <br> ### 參考資料 - [Docker学习笔记_08使用Rancher pipeline搭建基于容器的CICD](https://www.shuzhiduo.com/A/KE5Q8YNLJL/) - [新年第一天,奉上Rancher Pipeline第一时间的尝鲜体验!](https://www.dazhuanlan.com/2019/11/05/5dc17229a4a3b/) - [Rancher Pipeline發布:開源、極簡、強大的CI/CD](https://kknews.cc/zh-tw/code/2vr5rgg.html) <br> <hr> <br> ## Rancher 的應用場景 ### 參考資料 - [CI/CD Pipeline Using GitLab and Rancher #2](https://github.com/Hujun/blog/issues/2) - [v2.0.x Pipeline Documentation](https://rancher.com/docs/rancher/v2.x/en/k8s-in-rancher/pipelines/docs-for-v2.0.x/) - [Illumina, the Leading Producer of DNA Sequencers, Implements Docker, Kubernetes, and Rancher to Support 300 Developers and 14 Production Deployments](https://rancher.com/customers/illumina/?utm_campaign=2018%3A%20Customer%20Stories&utm_content=100389648) - [Rancher Makes it Possible to Reduce the Downtime for Child Rescue Coalition, a Nonprofit Organization](https://rancher.com/customers/child-rescue-coalition/) <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <hr> <br> ## 安裝 Rancher OS :::info :information_source: **目的:** - 如果沒有多餘的主機可以進行 Rancher 管理測試, 可以安裝一些輕量級的虛擬主機(Rancher OS) </div> ::: - ### [本質](https://columns.chicken-house.net/2016/04/29/rancher-on-azure-lab/) - 專為執行 Docker 所發行的 Linux - 它拿掉所有不必要的服務 - ### GitHub - https://github.com/rancher/os - ### iso 下載點 - https://github.com/rancher/os/releases - e.g. - rancheros.iso - v1.5.5 - Docker 19.03.5 - Linux 4.14.138 - 147.8MB - ### 使用 Oracle VM VirtualBox 的設定 - **Type**:Linux - **Version**:(底下兩者都可) - Linux 2.6 / 3.x / 4.x (64-bit) - Other Linux (64-bit) - **RAM**: - 4GB (Rancher OS + Rancher Server) (後面有說明) - 啟動 iso 後的起始畫面 ![](https://i.imgur.com/qHKMH1E.png) <br> - ### 在 RancherOS 上,安裝 Rancher/Server 執行 ```docker run -d --restart=always -p 8080:8080 rancher/server``` 會遇到 no space left on device ![](https://i.imgur.com/oZwZTe4.png) <br> 顯示硬碟容量,實際情況並沒有全滿 ![](https://i.imgur.com/p5ANrIX.png) - 試圖加大硬碟空間到 128GB 仍然無解 - [Error message: 'No space left on device in default machine'](https://success.docker.com/article/error-message-no-space-left-on-device-in-default-machine) - [RancherOS don't start: "No space left on device" (Autoexpand hdd ?) #2740](https://github.com/rancher/os/issues/2740) - [No space left in device : Cant’s install rancher on rancherOS](https://forums.rancher.com/t/no-space-left-in-device-cants-install-rancher-on-rancheros/701) <br> - ### ==最後測試的結果:== - 不是硬碟空間不夠的問題,而是記憶體太少 - VM 的記憶體,[至少要配置 4GB 以上](https://github.com/rancher/os/issues/2740) ![](https://i.imgur.com/XINBr8E.png) - 2020/05/29 解法 - 記憶體需要 4GB 前提是: - OS 沒有裝到 disk,直接跑在 RAM 上 - 如果將 OS 安裝到 disk,應該就不需要太多記憶體 - [[Rancher] Installing to Disk](https://rancher.com/docs/os/v1.x/en/installation/server/install-to-disk/) - 需要準備 ```cloud-config.yml``` 檔 - [[心得分享] RancherOS的本地化安裝](https://www.itdaan.com/tw/c72004ae287a14722a1483df9183364a) - ### 備註 - #### Hosts: Add Host > will not work if the machine is behind a firewall/NAT or if it is the same machine that is running the rancher/server container. - #### 在同一台機器上安裝 Server & agent 如果用 VM 安裝 Rancher OS + Rancher Server 此 Rancher Server 的 IP (http://172.17.0.2/) 與主機的 IP (http://10.78.153.29/) 本質上仍然是同一台機器 雖然 agent 有連線到 server,且沒有印出錯誤訊息,在 web 上也沒有看到新增的主機 感覺應該是失敗... ![](https://i.imgur.com/wI6hDe9.png) <br> - 其他參考資料 - [Install Rancher OS – The Container Operating System](https://linuxhint.com/install_rancher_os/) - ~~It’s does not need much memory to run.~~ (真是大誤) - A computer or Virtual Machine with at least 2GB of RAM for installing Rancher OS. (文章前後互相矛盾) <br> ## 巢狀 Docker (Docker-in-Docker) :::info :information_source: **目的:** &emsp;&emsp;如果擴增虛擬主機(host),可以用巢狀 Docker方式來測試 </div> ::: - ### [Docker can now run within Docker](https://www.docker.com/blog/docker-can-now-run-within-docker/) ```bash $ docker run --privileged -it jpetazzo/dind ``` - Dockerfile https://github.com/jpetazzo/dind/blob/master/Dockerfile - ### 新增第二台虛擬主機 - #### 新增一個特殊的 container - 原始指令 ```bash $ docker run --name "tj-virtual-host" --privileged -dt jpetazzo/dind ``` - 在真實的 host 上,新增一個 container [![](https://i.imgur.com/cxkReQ6.png)](https://i.imgur.com/cxkReQ6.png) <br> [![](https://i.imgur.com/2LpFGOH.png)](https://i.imgur.com/2LpFGOH.png) - #### 在 container 上,執行 add-host 的指令 (來自 Rancher/Server 上提供的指令) - 點此取得 add-host 指令 ![](https://i.imgur.com/sV4NvKH.png) <br> ```bash $ sudo docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.11 http://10.78.153.29/v1/scripts/957EC6D5C2E4E6930AD4:1577750400000:dQxO95rVPcuBlONi0NaMCkTRfQ ``` - 在新增的 container 上,執行 add-host 指令 [![](https://i.imgur.com/1mPRcqF.png)](https://i.imgur.com/1mPRcqF.png) - #### 執行結果 共新增兩台虛擬主機,IP 皆是一樣 10.78.26.241 [![](https://i.imgur.com/M5ewIp9.png)](https://i.imgur.com/M5ewIp9.png) <br> ## 其他參考資料 - ### Rancher 的由來 - [寵物與牛的故事](https://www.luoow.com/dc_tw/200112514) - ### 公司融資 - [Rancher Labs Raises $40 Million Series D Round to Accelerate Growth of Its Kubernetes Management Platform](https://rancher.com/press/rancher-labs-raises-series-d-fundraising-to-accelerate-growth-of-kubernetes-management-platform) - ### 公司營收 - [RANCHER LABS Revenue, Growth & Competitor Profile](https://incfact.com/company/rancherlabs-mountainview-ca/#) ![](https://i.imgur.com/iVatDTY.png) - ### 產品收費問題 - [Request pricing](https://rancher.com/pricing/) - [標準和白金計畫](https://rancher.com/support-maintenance-terms/) - ### Rancher 被收購 - [Linux company SUSE outbids competitors for fast-growing start-up Rancher Labs](https://www.cnbc.com/2020/07/08/suse-acquires-rancher-labs.html) - Two people familiar with the deal say SUSE is paying at least $600 million. 兩名知情人士表示,SUSE至少支付6億美元 - ### 如何與 DevOps 整合 - [CI/CD容器應用開發流程示意圖](https://www.inwinstack.com/2018/03/14/kubernetes-ceph-rancher/) ![](https://i.imgur.com/JvJyqrz.png) - 維運人員 (Op Engineer) 利用 Rancher 對叢集管理的功能及特性,分別管理 Kubernetes 中的測試與正式環境