참고자료: 따배쿠 (따라하면서 배우는 쿠버네티스 이성미 강사님 자료)
[환경]
Master Node : 1개
Worker Node : 2개
Ubuntu 18.04 (중요) --> Kubernetes 1.25와 Ubuntu 20.04 이상은 호환성 문제가 있음.
방화벽
Inbound: 443, 80, 6443, 22 open
[전체적인 설치 프로세스]
1. Doker Install (모든 node에 필요)
2. K8s Install
- 설치전 환경 설정
- kubeadm, kubectl, kubelet 설치
- control-plane 구성
- worker node 구성
- 설치 확인
1 sudo swapoff -a
2 sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
3 sudo tee /etc/modules-load.d/containerd.conf <<EOF
overlay
br_netfilter
EOF
4 sudo modprobe overlay
5 sudo modprobe br_netfilter
6 sudo tee /etc/sysctl.d/kubernetes.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
7 sudo sysctl --system
8 sudo apt install -y curl gnupg2 software-properties-common apt-transport-https ca-certificates
9 sudo apt-get update
10 sudo apt-get install -y ca-certificates curl gnupg lsb-release
11 sudo apt install -y curl gnupg2 software-properties-common apt-transport-https ca-certificates
12 sudo mkdir -p /etc/apt/keyrings
13 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
14 echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
15 sudo apt-get update
16 sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
17 sudo systemctl restart containerd
18 sudo systemctl enable containerd
19 sudo systemctl enable docker
20 sudo systemctl start docker
21 sudo docker version
# 여기까지 Docker 설치 및 확인
22 sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
23 echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
24 sudo apt-get update
25 sudo apt-get install -y apt-transport-https ca-certificates curl
26 sudo apt update
27 sudo apt install -y kubelet kubeadm kubectl
28 sudo apt-mark hold kubelet kubeadm kubectl
29 sudo ls -altr /etc/containerd/config.toml
30 sudo kubeadm init
31 sudo rm /etc/containerd/config.toml
32 sudo systemctl restart containerd
33 sudo kubeadm init
34 mkdir -p $HOME/.kube
35 sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
36 sudo chown $(id -u):$(id -g) $HOME/.kube/config
37 kubectl get nodes
38 kubectl get pods -n kube-system
39 curl https://projectcalico.docs.tigera.io/manifests/calico.yaml -O
40 kubectl apply -f calico.yaml
41 kubectl get pods -n kube-system
위 30번 명령에서 kubeadm init 수행
sudo kubeadm init
아래와 같이 에러 발생
에러 해결 방법 (31~33 명령)
sudo rm /etc/containerd/config.toml
sudo systemctl restart containerd
sudo kubeadm init
Worker Node
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg lsb-release
sudo apt install -y curl gnupg2 software-properties-common apt-transport-https ca-certificates
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
## 여기까지 docker 설치
10 sudo swapoff -a
11 sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
12 sudo tee /etc/modules-load.d/containerd.conf <<EOF
overlay
br_netfilter
EOF
13 sudo modprobe overlay
14 sudo modprobe br_netfilter
15 sudo tee /etc/sysctl.d/kubernetes.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
16 history
17 sudo systemctl restart containerd
18 sudo systemctl enable containerd
19 sudo systemctl enable docker
20 sudo systemctl start docker
21 sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
22 echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
23 sudo apt-get update
24 sudo apt-get install -y apt-transport-https ca-certificates curl
25 sudo apt update
26 sudo apt install -y kubelet kubeadm kubectl
27 sudo apt-mark hold kubelet kubeadm kubectl
28 sudo kubeadm join xxx:6443 --token xevxt7.xxx --discovery-token-ca-cert-hash sha256:xxx
29 sudo rm /etc/containerd/config.toml
30 sudo systemctl restart containerd
31 sudo kubeadm join xxx:6443 --token xevxt7.xxx --discovery-token-ca-cert-hash sha256:xxx
여러번 수행한 것이라 잘 될 것입니다.
Kubernetes Service Type (0) | 2022.01.16 |
---|---|
Kubernetes auto complete command (0) | 2022.01.09 |
Kubernetes worker join failed (0) | 2022.01.09 |
Failed creating Kubernetes cluster (0) | 2022.01.09 |
댓글 영역