IT 기술/K8s

rancher + k3s Single node 구축 (ubuntu)

to,min 2025. 2. 27. 16:12

개요

요즘 쿠버네티스 구축할 일이 너무 많다. 무튼 운영 환경과 유사한 쿠버네티스 환경을 꾸리고자

Rancher와 k3s로 간단히 개발환경을 꾸려봤다.

 

설치환경

ubuntu 24, ram 8GM, 4 core

 

설치

1. 도커 설치

sudo apt install -y docker.io

udo usermod -aG docker $USER

newgrp docker

sudo service docker start

sudo service docker enable

 

2. rancher 설치

- 만약 싱글노드로 저처럼 구축하실 거라면 rancher나 k3s 둘 중 하나의 포트포워딩을 80과 443이 아닌 것으로 해야 합니다. 추후 k3s 구축할 때 꼬일 수 있습니다.  전 rancher 포트를 변경해 줬습니다.

docker run -d --name=rancher-server --restart=unless-stopped -p 28080:80 -p 2443:443 --privileged rancher/rancher:v2.10-head

 

3. rancher 계정설정

https://server_ip:port에 접속하여 계정설정

 

 

 

 

4. k3s 설치

아래 명령어들 순차적으로 입력

curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.28.15+k3s1 sh -

 

# 권한 부여
sudo chmod 644 /etc/rancher/k3s/k3s.yaml

 

아래 명령어로 노드가 보이면 설치 완료

kubectl get node

 

5. rancher와 k3s 연동

rancher home 접속

 

General 클릭하여 정보 입력 후. 넘어가면

 

이런 창이 뜰 텐데 아래 명령어 copy 후 서버에 paste 하면

curl --insecure -sfL <your info>.yaml | kubectl apply -f -

 

 

이렇게 구성이 완료됩니다.

 

 

주의사항

아래와 같은 에러를 마주할때 참고하세요

 

404 page not found 

-> rancher와 k3s 포트가 겹칠 때 발생

 

rancher imprort resource mapping not found for name: "cattle-admin-binding"

-> rancher 버전과 k3s 버전이 안 맞을때 발생, 여기  참고

 

This cluster is currently Unavailable; areas that interact directly with it will not be available until the API is ready.
Cluster health check failed: Failed to communicate with API server: Unauthorized

-> 토큰 갱신이 안되는 문제인대, 마찬가지로 버전 맞추면 해결

 

 

참고

https://www.linuxtechi.com/how-to-install-rancher-on-ubuntu/

 

How to Install Rancher on Ubuntu 22.04 (Step by Step)

In this guide, we will cover how to Install Rancher on Ubuntu 22.04 step by step. Rancher allows to create and manage kubernetes cluster from its WebUI.

www.linuxtechi.com