差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:rke-k8s [2021/04/07 19:05] – [安裝 rke 與建立 K8s Cluster] jonathantech:rke-k8s [2022/07/19 16:55] (目前版本) – [關閉 rke (移除 K8s Cluster)] jonathan
行 53: 行 53:
  
 ===== 安裝 rke 與建立 K8s Cluster ===== ===== 安裝 rke 與建立 K8s Cluster =====
 +  * 參考 - https://github.com/rancher/rke/releases/
   * 下載 rke 1.2.7 <cli>   * 下載 rke 1.2.7 <cli>
 wget https://github.com/rancher/rke/releases/download/v1.2.7/rke_linux-amd64 wget https://github.com/rancher/rke/releases/download/v1.2.7/rke_linux-amd64
行 95: 行 96:
 [+] Authentication Strategy [x509]: [+] Authentication Strategy [x509]:
 [+] Authorization Mode (rbac, none) [rbac]: [+] Authorization Mode (rbac, none) [rbac]:
-[+] Kubernetes Docker image [rancher/hyperkube:v1.20.5-rancher1]: rancker/jyperkube:v1.18.17-rancher1-1+[+] Kubernetes Docker image [rancher/hyperkube:v1.20.5-rancher1]: rancher/hyperkube:v1.18.17-rancher1
 [+] Cluster domain [cluster.local]: iiidevops-k8s [+] Cluster domain [cluster.local]: iiidevops-k8s
 [+] Service Cluster IP Range [10.43.0.0/16]: [+] Service Cluster IP Range [10.43.0.0/16]:
行 141: 行 142:
 : :
 </file> </file>
 +  * 開始執行安裝 <cli>
 +rke up --config cluster.yml
 +</cli> 因為要下載一些 images 需要等一些時間才會完成, 最後應該可以看到類似以下的訊息<cli>
 +:
 +INFO[0378] [addons] Executing deploy job rke-ingress-controller
 +INFO[0405] [ingress] ingress controller nginx deployed successfully
 +INFO[0405] [addons] Setting up user addons
 +INFO[0405] [addons] no user addons defined
 +INFO[0405] Finished building Kubernetes cluster successfully
 +</cli>
 +  * 將產生的檔案備份起來 <cli>
 +$ ls -lt
 +total 4476
 +-rw-r-----  1 localadmin localadmin  105805 Apr  7 19:18 cluster.rkestate
 +-rw-r-----  1 localadmin localadmin    5381 Apr  7 19:13 kube_config_cluster.yml
 +-rw-r-----  1 localadmin localadmin    5653 Apr  7 19:12 cluster.yml
 +</cli>
 +  * 複製 kubeconfig 檔案及驗證 kubeconfig 檔案<cli>
 +cp kube_config_cluster.yml ~/.kube/config
 +kubectl get nodes
 +</cli>如果沒問題應該會出現類似以下的訊息<cli>
 +$ kubectl get node
 +NAME         STATUS   ROLES                      AGE     VERSION
 +10.20.0.35   Ready    controlplane,etcd,worker   7m52s   v1.18.17
 +10.20.0.37   Ready    worker                     7m47s   v1.18.17
 +</cli>
  
 +===== 新增與移除 K8s Node ====
 +  * 只要修改 cluster.yml 節點資料, 再執行以下指令即可 <cli>rke up --update-only --config cluster.yml </cli>
 +  * Exp. 加上 10.20.0.36
 +    * 前面所有節點準備程序都要進行
 +    * 修改 cluster.yml <file>
 +nodes:
 +- address: 10.20.0.35
 +  port: "22"
 +  internal_address: 10.20.0.35
 +  role:
 +  - controlplane
 +  - worker
 +  - etcd
 +  hostname_override: ""
 +  user: rkeuser
 +  docker_socket: /var/run/docker.sock
 +  ssh_key: ""
 +  ssh_key_path: ~/.ssh/id_rsa
 +  ssh_cert: ""
 +  ssh_cert_path: ""
 +  labels: {}
 +  taints: []
 +- address: 10.20.0.36
 +  port: "22"
 +  internal_address: 10.20.0.36
 +  role:
 +  - worker
 +  hostname_override: ""
 +  user: rkeuser
 +  docker_socket: /var/run/docker.sock
 +  ssh_key: ""
 +  ssh_key_path: ~/.ssh/id_rsa
 +  ssh_cert: ""
 +  ssh_cert_path: ""
 +  labels: {}
 +  taints: []
 +- address: 10.20.0.37
 +  port: "22"
 +  internal_address: 10.20.0.37
 +  role:
 +  - worker
 +  hostname_override: ""
 +  user: rkeuser
 +  docker_socket: /var/run/docker.sock
 +  ssh_key: ""
 +  ssh_key_path: ~/.ssh/id_rsa
 +  ssh_cert: ""
 +  ssh_cert_path: ""
 +  labels: {}
 +  taints: []
 +services:
 +  etcd:
 +:
 +:
 +</file>
 +  * 執行更新 <cli>
 +rke up --update-only --config cluster.yml
 +</cli>
 +
 +===== 關閉 rke (移除 K8s Cluster) ====
 +  * 直接執行 rke remove 就會將 K8s 移除 <cli>
 +rke remove --config cluster.yml
 +</cli>
 +  * 執行後原本運行中的 rancher 服務還會持續運行, 可以透過重新開機解決
  
 ===== 參考網址 ===== ===== 參考網址 =====
   * https://www.mdeditor.tw/pl/glor/zh-tw   * https://www.mdeditor.tw/pl/glor/zh-tw
 +  * https://rancher.com/docs/rke/latest/en/managing-clusters/
  
-{{tag>RKE K8s}}+{{tag>Rancher RKE K8s}}
  • tech/rke-k8s.1617793545.txt.gz
  • 上一次變更: 2021/04/07 19:05
  • jonathan