본문 바로가기
Container & Orchestration/Kubernetes

ubuntu 22.x 에서 도커로 Rancher 설치

by abstract.jiin 2025. 2. 11.

Rancher? 컨테이너 워크로드를 보다 쉽게 관리할 수 있도록 도와주는 멀티 클러스터 관리 플랫폼

ubuntu 22.04 에서

  • Docker 설치
  • Rancher 설치

해보자

Docker 설치

1. 우분투 시스템 패키지 업데이트

sudo apt-get update

2. 필요한 패키지 설치

sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

3. Docker의 공식 GPG키를 추가

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

4. Docker의 공식 apt 저장소를 추가

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

5. 시스템 패키지 업데이트

sudo apt-get update

6. Docker 설치

sudo apt-get install docker-ce docker-ce-cli containerd.io

7. Docker 설치 확인

docker ps
#docker 그룹 확인 
$ cat /etc/group | grep -i docker
docker:x:999:

#계정 확인
$ cat /etc/passwd

#소속 그룹(docker ) 에 추가하기
$ sudo usermod -aG docker [사용자id]

#확인 
$ id -a [사용자id]
uid=1000([사용자id]) gid=1000([사용자id]) groups=1000([사용자id]),10(wheel),999(docker)

#특정 사용자 id 그룹 확인 ex user01
$ groups user01
user01 : user01 docker

7-1 도커 실행상태 확인

sudo systemctl status docker

7-2 기타

#도커 버전 확인

docker ––version

#부팅시 도커 시작하도록 세팅

sudo systemctl enable docker

#도커 시작

sudo systemctl start docker

Rancher설치

  • docker compose yml
  • version: '3' services: rancher: image: rancher/rancher:latest container_name: rancher3 ports: - "80:80" - "443:443" volumes: - /rancher:/var/lib/rancher privileged: true restart: unless-stopped
 sudo docker run --privileged -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher
$ docker logs [Container_ID] 2>&1 | grep "Bootstrap Password:"

단일 서버에 worker, controlplane, etcd 모두 체크하여 수행

https://velog.io/@leesjpr/Rancher-를-통한-Kubernetes-클러스터-구축

편리한 Util

kstomize 설정

wget https://github.com/kubernetes-sigs/kustomize/releases/download/v3.2.0/kustomize_3.2.0_linux_amd64

chmod +x kustomize_3.2.0_linux_amd64

sudo mv kustomize_3.2.0_linux_amd64 /usr/local/bin/kustomize

kustomize version

kubectx, kubens 설치

wget https://github.com/ahmetb/kubectx/releases/download/v0.9.4/kubectx

sudo install kubectx /usr/local/bin
wget https://github.com/ahmetb/kubectx/releases/download/v0.9.4/kubens

sudo install kubens /usr/local/bin

Rancher 깨끗하게 삭제하기

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

Cleaning up Nodes

  • RKE1
  • RKE2
  • K3s

You need to remove the following components from Rancher-provisioned RKE2 nodes:

  • The rancher-system-agent, which connects to Rancher and installs and manages RKE2.
  • RKE2 itself.

Removing rancher-system-agent

To remove the rancher-system-agent, run the system-agent-uninstall.sh script:

curl https://raw.githubusercontent.com/rancher/system-agent/main/system-agent-uninstall.sh | sudo sh

Removing RKE2

To remove the RKE2 installation, run the rke2-uninstall script that is already present on the node:

sudo rke2-uninstall.sh

Directories and Files

The following directories are used when adding a node to a cluster, and should be removed. You can remove a directory using rm -rf /directory_name.

NOTE

Depending on the role you assigned to the node, some of the directories will or won't be present on the node.

Directories


/etc/ceph

/etc/cni

/etc/kubernetes

/etc/rancher

/opt/cni

/opt/rke

/run/secrets/kubernetes.io

/run/calico

/run/flannel

/var/lib/calico

/var/lib/etcd

/var/lib/cni

/var/lib/kubelet

/var/lib/rancher

/var/log/containers

/var/log/kube-audit

/var/log/pods

/var/run/calico

To clean the directories:

rm -rf /etc/ceph \
       /etc/cni \
       /etc/kubernetes \
       /etc/rancher \
       /opt/cni \
       /opt/rke \
       /run/secrets/kubernetes.io \
       /run/calico \
       /run/flannel \
       /var/lib/calico \
       /var/lib/etcd \
       /var/lib/cni \
       /var/lib/kubelet \
       /var/lib/rancher\
       /var/log/containers \
       /var/log/kube-audit \
       /var/log/pods \
       /var/run/calico

Network Interfaces and Iptables

The remaining two components that are changed/configured are (virtual) network interfaces and iptables rules. Both are non-persistent to the node, meaning that they will be cleared after a restart of the node. To remove these components, a restart is recommended.

To restart a node:

# using reboot
$ sudo reboot

# using shutdown
$ sudo shutdown -r now

If you want to know more on (virtual) network interfaces or iptables rules, please see the specific subjects below.

해당 디렉토리는 직접 수기로 삭제

 /var/lib/rancher/