> For the complete documentation index, see [llms.txt](https://rexs-organization.gitbook.io/kubernetes-installation-steps/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rexs-organization.gitbook.io/kubernetes-installation-steps/zai-master-node-0-shang-she-ding.md).

# 在 master node 0 上設定

**修改 Kubeadm Config 檔案**

使用 `kubeadm config print init-defaults` 指令匯出設定 YAML 檔案。

```
kubeadm config print init-defaults > kubeadm-config.yaml
```

修改 `kubeadm-config.yaml` 檔案:

> kubeadm-config.yaml refs: link
>
> 注意 `podSubnet` 及 `serviceSubnet` 最好不要與目前電腦的 private IP 相同網段, 避免發生衝突。
>
> kube-proxy 使用模式為 `ipvs`
>
> podSubnet: `10.244.0.0/16`
>
> serviceSubnet: `10.96.0.0/12`

```
vi kubeadm-config.yaml
```

**初始化 Kubernetes**

> 初始化成功後, 系統會提示將 `/etc/kubernetes/admin.conf` 複製到 `$HOME/.kube/config`, 便可以使用 `kubectl get nodes` 查看狀況。

```
kubeadm init --config=kubeadm-config.yaml --upload-certs
```

**安裝 Calico operator**

```
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/tigera-operator.yaml
```

**設定 Calico POD\_CIDR**

下載 `calico.yaml`, 修改 `spec.calicoNetwork.ipPools.cidr` 為 `10.244.0.0/16`

```
curl -OL https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/custom-resources.yaml

vi custom-resources.yaml

kubectl apply -f custom-resources.yaml
```

檢查 calico 安裝進度:

```
watch kubectl get pods -n calico-system
```

安裝完成後, 便可使用 kubernetes。
