이번엔 쿠버네티스 클러스터에 Master, Worker 노드 추가해보도록 하겠습니다.
Master와 Worker 노드를 추가하려면 token을 생성해주어야 합니다.
아래의 명령어를 통해 Master 노드에서 Token을 생성 할 수 있습니다.
# kubeadm token create
아래 명령어로 생성된 토큰을 확인 할 수 있습니다.
# kubeadm token list

Master 노드 추가하는 방법
Master 노드를 추가하려면 certificate key를 생성 해줍니다.
# kubeadm init phase upload-certs --upload-certs
<결과>
I0418 11:01:19.681646 532904 version.go:256] remote version is much newer: v1.30.0; falling back to: stable-1.29
[upload-certs] Storing the certificates in Secret "kubeadm-certs" in the "kube-system" Namespace
[upload-certs] Using certificate key:
061d1e6daa368983ba6325bb383ad7dbf7082b31c7fb7d7dc1b0e556af90955f
구성되어 있는 쿠버네티스 클러스터에 노드를 추가 하기 위해서는 Master Node에서 Token 생성이 필요합니다.
Token을 생성할 때, 위에서 생성한 certificate key를 넣어서 Token을 생성 해줍니다.
# kubeadm token create --certificate-key 061d1e6daa368983ba6325bb383ad7dbf7082b31c7fb7d7dc1b0e556af90955f --print-join-command
<결과>
kubeadm join 10.10.91.31:6443 --token eo0690.pk9qx6w3vp58bb66 --discovery-token-ca-cert-hash sha256:d03d97c1b3b90a054978f66fcbfcb9c4000f515e3f330506404f1a93c5152ba3 --control-plane --certificate-key 061d1e6daa368983ba6325bb383ad7dbf7082b31c7fb7d7dc1b0e556af90955f
결과에 나온 명령어를 추가할 Master 노드에서 명령어를 입력해주면 추가가 완료 됩니다.
Master 노드 추가 시 겪었던 오류
그런데, 저는 명령어를 입력하니 아래와 같은 오류가 나왔었습니다.
[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'
error execution phase preflight:
One or more conditions for hosting a new control plane instance is not satisfied.
unable to add a new control plane instance to a cluster that doesn't have a stable controlPlaneEndpoint address
Please ensure that:
* The cluster has a stable controlPlaneEndpoint address.
* The certificates that must be shared among control plane instances are provided.
To see the stack trace of this error execute with --v=5 or higher
에러 내용을 확인해보면 controlplane의 endpoint 주소 관련한 오류 같아서,
최초 구성한 쿠버네티스 클러스터의 configmap에서 controlplaneEndpoint를 수정을 해주었습니다.
# kubectl edit configmaps -n kube-system kubeadm-config
위의 명령어로 configmap 파일에서 controlPlaneEndpoint를 추가해주었습니다.

controlPlaneEndpoint 주소는 <처음 구성한 controlplane의 IP주소>:6443 으로 지정해주고
추가하려는 controlplane 노드에서 kubeadm join 명령어를 입력하였더니 정상적으로 master 노드가 추가 되었습니다.
Worker 노드 추가하는 방법
Master 노드 추가하는 방법보다 간단합니다.
Token 생성 시에 --print-join-command 옵션을 추가해주면 아래 결과와 같이 나옵니다.

그리고 명령어 복사를 복사해서 Worker Node에 넣어주면 바로 추가가 됩니다.

감사합니다.
'쿠버네티스' 카테고리의 다른 글
Kubernetes 네임스페이스 별 자원할당 (0) | 2024.06.11 |
---|---|
쿠버네티스 Metrics 설치 (1) | 2024.06.10 |
MetalLB 사용해서 외부로 노출 시키기 (0) | 2024.04.15 |
쿠버네티스 harbor에서 이미지 받아 오기 (insecure-registry) (1) | 2024.04.08 |
Kubernetes 설치 (2) | 2024.01.08 |