아래와 같은 k8s 클러스터에 노드를 조인해보자.
[root@k8s-control ~]# k get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8s-compute1 Ready <none> 26d v1.32.7 10.0.2.12 <none> Rocky Linux 10.0 (Red Quartz) 6.12.0-55.22.1.el10_0.x86_64 cri-o://1.30.14
k8s-compute2 Ready <none> 26d v1.32.7 10.0.2.13 <none> Rocky Linux 10.0 (Red Quartz) 6.12.0-55.22.1.el10_0.x86_64 cri-o://1.30.14
k8s-control Ready control-plane 26d v1.32.7 10.0.2.11 <none> Rocky Linux 10.0 (Red Quartz) 6.12.0-55.22.1.el10_0.x86_64 cri-o://1.30.14
사전 준비(새 워커 노드)
# swap 끄기
sudo swapoff -a
sudo sed -i '/ swap / s/^/#/' /etc/fstab
# SELinux permissive
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
# 커널 모듈 및 sysctl
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
sudo sysctl --system
# firewalld 끄기
systemctl diable firewalld
systemctl stop firewalld
CRI-O 설치(v1.30)
K8S_VERSION="v1.32"
CRIO_VERSION="v1.30"
cat <<EOF | sudo tee /etc/yum.repos.d/cri-o.repo
[cri-o]
name=CRI-O
baseurl=https://download.opensuse.org/repositories/isv:/cri-o:/stable:/$CRIO_VERSION/rpm/
enabled=1
gpgcheck=1
gpgkey=https://download.opensuse.org/repositories/isv:/cri-o:/stable:/$CRIO_VERSION/rpm/repodata/repomd.xml.key
EOF
sudo dnf install -y container-selinux
sudo systemctl enable --now crio
CRITOOLS_VERSION="v1.32.0"
wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$CRITOOLS_VERSION/crictl-$CRITOOLS_VERSION-linux-amd64.tar.gz
sudo tar zxvf crictl-$CRITOOLS_VERSION-linux-amd64.tar.gz -C /usr/local/bin
rm -f crictl-$CRITOOLS_VERSION-linux-amd64.tar.gz
[root@k8s-compute3 ~]# export PATH=$PATH:/usr/local/bin/
[root@k8s-compute3 ~]# chown root: /usr/local/bin/crictl
[root@k8s-compute3 ~]# crictl version
Version: 0.1.0
RuntimeName: cri-o
RuntimeVersion: 1.30.14
RuntimeApiVersion: v1
kubeadm / kubelet / kubectl 설치(v1.32.7)
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.32/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.32/rpm/repodata/repomd.xml.key
EOF
sudo dnf install -y kubelet-1.32.7 kubeadm-1.32.7 kubectl-1.32.7
sudo systemctl enable --now kubelet
Control Plane(마스터)에서 Join Command 발급
[root@k8s-control ~]# kubeadm token create --print-join-command
kubeadm join 10.0.2.11:6443 --token muc909.oyxpppfume39vff4 --discovery-token-ca-cert-hash sha256:72c392de14006d6f6ba4d92254dddd31fcf56b459367a3dff007aa7da9128ba5
새 워커노드에서 실행
/etc/hosts 에 아래와 같이 입력
<추가할 노드의 IP> <host 명>
sudo kubeadm join 10.0.2.11:6443 --token muc909.oyxpppfume39vff4 \
--discovery-token-ca-cert-hash sha256:72c392de14006d6f6ba4d92254dddd31fcf56b459367a3dff007aa7da9128ba5
실패 시 다시 시도하는 법
# 새로운 워커노드에서 실행
sudo kubeadm reset -f
sudo rm -rf /var/lib/kubelet /etc/kubernetes /var/lib/kube-proxy
sudo lsof -i :10250
# master 노드에서 실행
kubectl get node -> 새로운 워커노드 join 여부 확인
kubectl delete node <새로운 워커노드 명> (join 확인 시)
확인
[root@k8s-control ~]# k get node
NAME STATUS ROLES AGE VERSION
k8s-compute1 Ready <none> 30d v1.32.7
k8s-compute2 Ready <none> 30d v1.32.7
k8s-compute3 Ready <none> 9s v1.32.7
k8s-control Ready control-plane 30d v1.32.7
# test 용 yaml
apiVersion: v1
kind: Pod
metadata:
labels:
run: nginx
name: nginx
spec:
nodeSelector:
kubernetes.io/hostname: k8s-compute3
containers:
- image: nginx:1.27
name: nginx
[root@k8s-control ~]# k get po -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 1/1 Running 0 12m 10.50.4.2 k8s-compute3 <none> <none>
Trouble Shooting
# 상황
아래와 같이 kubelet 과 연결이 안되어 nginx pod 에 연결이 안 됨
[root@k8s-control ~]# telnet 10.0.2.14 10250
Trying 10.0.2.14...
telnet: connect to address 10.0.2.14: No route to host
# 조치
[root@k8s-compute3 ~]# systemctl stop firewalld
[root@k8s-compute3 ~]# systemctl disable firewalld
[root@k8s-control ~]# curl 10.50.4.2
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>'k8s' 카테고리의 다른 글
| HPA (0) | 2025.12.15 |
|---|---|
| metric server 설치 (0) | 2025.09.02 |
| ansible 을 활용한 k8s 클러스터 구축 (0) | 2025.08.01 |
| PV 테스트 (0) | 2025.07.15 |
| Prometheus 와 Grafana 설치 (1) | 2025.07.11 |