Kubernetes - 쿠버네티스 다중 클러스터 구성하기

choko's avatar
Jun 29, 2024
Kubernetes - 쿠버네티스 다중 클러스터 구성하기
 
notion image
멀티 노드(서버 여러대)에 k8s 클러스터 구축하기
  • master(control-plane)
    • kube-system이 포함되어 있는 노드 → sudo kubeadm init 를 한 노드
    • 현재 클러스터 상태를 사용자가 원하는 클러스터 상태로 조정해준다.
    • 보통 멀티노드 구성 시 masterkube-system 관련 컨테이너들만 운영하는걸 추천함
      • kube-system → api-server, Scheduler, etcd 등
  • worker(data-plane)
    • 구축할 프로그램들이 워커에서 운영
    • kubelet : worker 노드는 kubelet을 통해 master 노드와 통신한다.
    • kube-proxy : IP 변환, 네트워크 통신 관리 등
 
 

멀티노드 구축

master, worker에 iptable, kubernetes, docker, nfs 등이 설치되어 있다고 가정한다.
  1. worker에서 master의 host 이름을 등록
      • /etc/hosts
        • 127.0.0.1 localhost # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts {Master Ip} {control-plane name}
           
  1. master kubeadm 세팅
      • kubeadm.yaml
      // kubeadm.yaml apiVersion: kubeadm.k8s.io/v1beta2 kind: ClusterConfiguration kubernetesVersion: stable-1.24 controlPlaneEndpoint: mdl-control-plane:6443
      • kubeadm init
      echo "127.0.0.1 mdl-control-plane" | sudo tee -a /etc/hosts sudo kubeadm init --config kubeadm.yaml mkdir -p "$HOME"/.kube sudo cp -i /etc/kubernetes/admin.conf "$HOME"/.kube/config sudo chown "$(id -u)":"$(id -g)" "$HOME"/.kube/config sudo systemctl restart kubelet.service
      • kubeadm init에서 token 정보 조회가 가능하다
      ... You can now join any number of control-plane nodes by copying certificate authorities and service account keys on each node and then running the following as root: kubeadm join mdl-control-plane:6443 --token itfxow.uuomu945zd1mmri5 \ --discovery-token-ca-cert-hash sha256:3c2b420c03205a600de56c6c2ae9826850d547f259c77151667514a37af96c2a \ --control-plane Then you can join any number of worker nodes by running the following on each as root: kubeadm join mdl-control-plane:6443 --token itfxow.uuomu945zd1mmri5 \ --discovery-token-ca-cert-hash sha256:3c2b420c03205a600de56c6c2ae9826850d547f259c77151667514a37af96c2a
 
  1. worker join
    1. 위 kubeadm join 토큰을 입력한다
      ubuntu@ip-172-31-13-105:~/adc-manager$ sudo kubeadm join mdl-control-plane:6443 --token itfxow.uuomu945zd1mmri5 \ > --discovery-token-ca-cert-hash sha256:3c2b420c03205a600de56c6c2ae9826850d547f259c77151667514a37af96c2a [preflight] Running pre-flight checks [preflight] Reading configuration from the cluster... [preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml' [kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml" [kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env" [kubelet-start] Starting the kubelet [kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap... This node has joined the cluster: * Certificate signing request was sent to apiserver and a response was received. * The Kubelet was informed of the new secure connection details. Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
 
  1. taint, tolerration 및 Cni 적용
 
 
 
 
 
 
 

ref
Share article

Tom의 TIL 정리방