-
[K8S] Kubespray를 이용한 Cluster초기화, Node 추가/제거Kubernetes 2024. 3. 7. 00:17
Cluster 초기화
kubespray에서 'reset.yml' 파일을 이용하여 배포된 Cluster를 배포 이전의 상태로 초기화 할 수 있습니다.
- 초기화 명령어
ansible-playbook -i inventory/mycluster/hosts.yaml --become reset.yml Are you sure you want to reset cluster state? Type 'yes' to reset your cluster.: yes
Node 추가/제거
Worker Node 추가
- Cluster 배포한 Master 노드에서 hosts.yaml 파일 수정 (kubespray/inventory/mycluster/hosts.yaml)
- 추가하려는 node의 정보 입력 (hosts 정보 추가, 역할 (kube_node) 에 추가)
- hyun-test02 이름으로 worker node 추가 시 예제 ↓
all: vars: ansible_user: 'root' ansible_password: 1234 ansible_become_password: 1234 hosts: hyun-test01: ansible_host: 192.168.0.100 ip: 192.168.0.100 access_ip: 192.168.0.100 hyun-test02: ansible_host: 192.168.0.101 ip: 192.168.0.101 access_ip: 192.168.0.101 children: kube_control_plane: hosts: hyun-test01: kube_node: hosts: hyun-test01: hyun-test02: etcd: hosts: hyun-test01: k8s_cluster: children: kube_control_plane: kube_node: calico_rr: hosts: {}
- Worker Node 추가 명령어
'scale.yml' 파일을 이용하여 배포된 Cluster에 새로운 Worker Node를 추가할 수 있습니다.
ansible-playbook -i inventory/mycluster/hosts.yaml --become scale.yml
Master Node 추가
- cluster.yml은 전체 클러스터의 구성을 정의 합니다.
- master node 는 cluster 안에서 중요한 역할(마스터, 워커, 네트워킹, 인증 및 기타 중요한 구성 정보 )을 수행하기 때문에 단일 작업을 수행하는 scale.yml이 아닌 cluster.yml을 이용해 추가해야 합니다.
- Cluster 배포한 Master 노드에서 hosts.yaml 파일 수정 (kubespray/inventory/mycluster/hosts.yaml)
- 추가하려는 node의 정보 입력 (hosts 정보 추가, 역할 (kube_control_plane, etcd) 에 추가)
- hyun-test02, hyun-test03 이름으로 Master node 추가 시 예제 ↓
all: vars: ansible_user: 'root' ansible_password: 1234 ansible_become_password: 1234 hosts: hyun-test01: ansible_host: 192.168.0.100 ip: 192.168.0.100 access_ip: 192.168.0.100 hyun-test02: ansible_host: 192.168.0.101 ip: 192.168.0.101 access_ip: 192.168.0.101 hyun-test03: ansible_host: 192.168.0.102 ip: 192.168.0.102 access_ip: 192.168.0.102 children: kube_control_plane: hosts: hyun-test01: hyun-test02: hyun-test03: kube_node: hosts: hyun-test01: hyun-test02: hyun-test03: etcd: hosts: hyun-test01: hyun-test02: hyun-test03: k8s_cluster: children: kube_control_plane: kube_node: calico_rr: hosts: {}
- Master Node 추가 명령어
ansible-playbook -i inventory/mycluster/hosts.yaml --become cluster.yml
Node 제거
'remove.yml' 파일을 이용하여 배포된 Cluster에 구성되어 있는 Node를 제거할 수 있습니다.
ansible-playbook -i inventory/mycluster/hosts.yaml --become remove-node.yml -e node={삭제할node명} Are you sure you want to delete nodes state? Type 'yes' to delete nodes.:yes
'Kubernetes' 카테고리의 다른 글
[K8S] Kubespray 설정 파일 변경하기 (0) 2024.03.09 [K8S] Reserve Compute Resources (0) 2024.03.07 [K8S] Kubespray로 Kubernetes 설치하기 - CentOS7/Rocky8 (0) 2024.03.01 Kubespray 분석 (0) 2023.08.25 [K8S] ETCD Backup & Restore (0) 2023.08.24