---
# System prepended metadata

title: Kubernetes cluster 半手動建置
tags: [K8s]

---

# Kubernetes cluster 半手動建置
###### tags: `K8s`
---
[toc]

## Ubuntu相關前置作業設定
- 修改root密碼
    ```
    sudo passwd root
    ```
- DNS設定(For Ubuntu 18.04 or above)
  - [Reference](https://roychou121.github.io/2020/07/15/ubuntu-dns/)
  
  - 方法一: 修改systemd-resolv
    1. 編輯resolved.conf
        ```terminal
        sudo vi /etc/systemd/resolved.conf
        ```
    2. 輸入偏好的DNS Server
       ```conf
       DNS=8.8.8.8 8.8.4.4
       LLMNR=no #這行取消註解
       ```
    3. 重啟服務
        ```terminal
        sudo systemctl daemon-reload
        sudo systemctl restart systemd-networkd
        sudo systemctl restart systemd-resolved
        ```
- 關閉swap(所有主機都要做)
    ```powershell
    swapoff -a
    
    #註解/etc/fstab理swap相關的內容
    vi /etc/fstab
    
    #設定完成後重開機
    ```
- 編輯/etc/hosts(所有主機都要做)
  - 當作master node的主機需要將所有當作worker node的主機的IP加入。Ex:
  ```powershell
  vi /etc/hosts
  
  #在文件中加入
  140.121.101.182 workernode
  ```
  - 當作worker node的主機需要將當作master node的主機的IP加入。Ex:
  ```powershell
  vi /etc/hosts
  
  #在文件中加入
  140.121.101.181 masternode
  ```


## K8s建置參考資料
- docker version: docker-ce | 20.10.14
- K8s version: 1.23.6
- 
> 步驟依照該網頁操作: [Link](https://rickhw.github.io/2019/03/17/Container/Install-K8s-with-Kubeadm/)
