---
# System prepended metadata

title: Untitled

---

---master---
sudo apt-get update
sudo apt install -y docker.io

sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

sudo kubeadm init

sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

mkdir -p $HOME/.kube
sudo \cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

### core dns
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
![](https://i.imgur.com/y5uwFOn.png)


---- worker ----

sudo apt-get update

sudo apt install -y docker.io
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl


## 연주 master 토큰
```
kubeadm join 192.168.111.128:6443 --token 0ywwxa.ll4863heivbzpjgt \
        --discovery-token-ca-cert-hash sha256:768c6eb72707212eddd0c532a2f64e754d2368af27faa470a2473a77f5e514fd
```
![](https://i.imgur.com/yiyw4uC.png)


hostnamectl set-hostname worker

## master와 worker의 서버네임이 겹치면 안됩니다!

kubectl create deploy --image=nginx