* ubuntu 20.04 LTS 사용
* master 192.168.2.10/24 | work1 192.168.2.11/24 | work2 192.168.2.12/24
참고 - https://kubernetes.io/ko/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
# master, work1, work2
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
# docker repository 사용
apt update
apt-get install ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# containerd 설치
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io
systemctl status containerd
cat <<EOF | tee -a /etc/containerd/config.toml
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
EOF
sed -i 's/^disabled_plugins \=/\#disabled_plugins \=/g' /etc/containerd/config.toml
systemctl restart containerd
# 설치 확인
ls /var/run/containerd/containerd.sock
# kubernetes 관련 패키지 설치
mkdir /etc/apt/keyrings
apt-get update
apt-get install -y apt-transport-https ca-certificates curl
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg
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
sudo apt-get update
apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl
# net filter bridge 설정
modprobe br_netfilter
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
우선 모든 노드에서 위 명령을 실행해준다
* 모든 명령은 root에서 실행함
# master
kubeadm reset
kubeadm init
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
# cilium 설치
curl -LO https://github.com/cilium/cilium-cli/releases/latest/download/cilium-linux-amd64.tar.gz
tar xzvfC cilium-linux-amd64.tar.gz /usr/local/bin
rm cilium-linux-amd64.tar.gz
cilium install
# 설치 확인
cilium status
master에서 위 명령들을 실행한 후 cilium status에 cilium과 operator에 ok가 떠있으면 된다
# work1, work2
kubeadm join 192.168.2.10:6443 --token [token] --discovery-token-ca-cert-hash [hash]
# master
kubectl get nodes
# kubectl이 실행되지않을시
unset KUBECONFIG
export KUBECONFIG=/etc/kubernetes/admin.conf
master에서 kubectl init 실행시 아래쪽에 kubeadm join ~~~ 라는 명령어가 나오는데
해당 명령어를 복사해서 work1,2에 넣어서 master에 join 해준다음
master에서 node를 확인해 join이 되어있는지 status가 ready인지 확인해준다
'Kubernetes' 카테고리의 다른 글
kubernetes를 활용한 emptydir 실습 예제 (0) | 2023.11.02 |
---|---|
cilium사용 시 session affinity가 적용이 안되는 문제 해결 (0) | 2023.11.01 |
kubernetes를 활용한 deployment 예제 (0) | 2023.10.31 |
minikube를 활용한 nginx 로드분산 예제 (0) | 2023.10.24 |
minikube를 활용한 wordpress mysql 연동 예제 (0) | 2023.10.23 |