---
# System prepended metadata

title: '*Part2*_Install Kubernetes in Linux OS(有網路環境)'
tags: [Docker & Kubernetes]

---

# *Part2*_Install Kubernetes in Linux OS(有網路環境)
###### tags: `Docker & Kubernetes`
## Environment
:::info
**CPU:**
Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
CPU:32-bit, 64-bit
**OS:**
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian

:::

## 安裝 Docker
```
apt-get install docker.io
service docker status //查看Docker狀態
systemctl start docker //Docker未執行再執行這步驟
```
![](https://i.imgur.com/CWH9YUY.png)

## 安裝 Kubeadm,kubectl and kubelet
### 安裝Packages讓apt可以下載repository(公倉)
```
sudo apt-get update && apt-get install -y apt-transport-https curl

```
### 加入Kubernetes的倉庫
```
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
```

### 安裝 kubelet, kubeadm and kubectl
```
apt-get update
apt-get install -y kubelet kubeadm kubectl
```
**確認版本**
![](https://i.imgur.com/M5C7gBi.png)

## 安裝Master
### 初始化Master
#### 永久關閉Swap
```
sudo su
vim /etc/rc.local
```
:::success
加入swapoff -a到最後一行
:::
![](https://i.imgur.com/3NRe0wt.png)

#### 查看Swap狀態
```cat /proc/meminfo```
![](https://i.imgur.com/jBISc51.png)
:::danger
Swap還在運行
所以要重開機
```reboot```
:::
