[Kubernetes] Rancher를 이용한 클러스터 구성

Rancher

Enterprise Kubernetes management solution이라고 한다. kubeadm으로 하나하나 붙이니 뭔가 관리가 더 빡세서 사랑하는 GUI를 보여줄 수 있는 시스템을 선택하였다.

Rancher 설치

호스트 OS는 Rocky 8로 진행하였다.

docker 설치

sudo dnf check-update
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo systemctl status docker

rancher 설치

최신 버전에서는 문제가 있는 것 같다. 2.4.9를 설치하자

sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:v2.4.9

2023년 3월 23일 기준. 설치를 종료하고 웹으로 접속이 안되면 최신/스테이블 버전이 설치되었을 확률이 높다. 도커 로그를 보면 k3s가 종료되었다는 메세지를 볼 수 있다. 스테이블은 포기하고 2.4.9를 쓰거나 리눅스 배포판을 바꾸자.

sudo docker logs [ranchercontainerid]
.
.
.
[FATAL] k3s exited with: exit status

웹 접근

처음 켜면 관리자(admin) 비밀번호를 설정한다. 잘 설정하자.

테스트 클러스터 추가

특별한 내용은 없다.

"""4. Create the Cluster Welcome to Rancher! You are now able to create your first Kubernetes cluster.

In this task, you can use the versatile Custom option. This option lets you add any Linux host (cloud-hosted VM, on-prem VM, or bare-metal) to be used in a cluster.

If you chose I'm only going to use the cluster Rancher was installed on when setting the default view, click the Cluster Manager button in the upper-right of the UI to access the Clusters page.

From the Clusters page, click Add Cluster.

Choose Existing Nodes.

Enter a Cluster Name.

Skip Member Roles and Cluster Options. We'll tell you about them later.

Click Next.

From Node Role, select all the roles: etcd, Control, and Worker.

Optional: Rancher auto-detects the IP addresses used for Rancher communication and cluster communication. You can override these using Public Address and Internal Address in the Node Address section.

Skip the Labels stuff. It's not important for now.

Copy the command displayed on screen to your clipboard.

Log in to your Linux host using your preferred shell, such as PuTTy or a remote Terminal connection. Run the command copied to your clipboard.

When you finish running the command on your Linux host, click Done."""

방화벽 설정

rancher와 클러스터 사이에 많은 방화벽들을 열어야 한다. https://velog.io/@leesjpr/Rancher-%EB%A5%BC-%ED%86%B5%ED%95%9C-Kubernetes-%ED%81%B4%EB%9F%AC%EC%8A%A4%ED%84%B0-%EA%B5%AC%EC%B6%95

클러스터에 새로운 노드 추가

guest os 준비

worker 추가를 진행할 때, worker node가 설치된 guest os를 복제하여 노드 추가 스크립트(랜처 에이전스 실행)를 돌리면 정상 동작하지 않는다. 워커노드로 추가할 때 설치된 kubernetes관련 설정들이 게스트 오에스에 남아있기 때문. 게스트 오에스를 새로 설치하거나 아래 링크를 확인하여 클린업을 진행하자.

https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/manage-clusters/clean-cluster-nodes

완료

클러스터에 워커가 잘 보면 설치가 잘 된거다. 이제 워크로드를 올려보자.

참고

[1] How To Install and Use Docker on Rocky Linux 8 https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-rocky-linux-8

[1] Rancher 매뉴얼 퀵 가이드 : https://ranchermanager.docs.rancher.com/v2.5/getting-started/quick-start-guides/deploy-rancher-manager/helm-cli

[1]

https://www.golinuxcloud.com/install-rancher-rocky-linux-9/

[1] 방화벽 설정