IT/클라우드

[container] 오프라인 환경에서 k3s 설치하기

고잉킴 2023. 10. 18. 16:17

오프라인 환경에서 k3s 설치하는 방법 (Air-Gap Install)


Kubernetes는 사용하기 쉽고 유연한 컨테이너 기반 인프라를 제공하는 오프소스 플랫폼입니다. K3s는 이를 오프라인 환경에서 쉽게 설치하고 운영할 수 있도록 최적화된 버전입니다. 이 글에서는 오프라인 환경에서 k3s를 설치하는 방법을 알아보겠습니다.
 

1. 사전 준비

K3s를 오프라인 환경에서 설치하기 위해서는 다음과 같은 준비물이 필요합니다.
최소 1개의 노드(서버) - Linux x64 기준
1개만 있어도 된다니.. 확실히 경량화된 k8s가 맞는듯 싶습니다.
또한 해당 노드에는 최소 1개의 lan이 활성화 되어 있어야 합니다.


2. k3s 다운로드

K3s는 GitHub에서 다운로드할 수 있습니다.
https://github.com/k3s-io/k3s/releases

 

Releases · k3s-io/k3s

Lightweight Kubernetes. Contribute to k3s-io/k3s development by creating an account on GitHub.

github.com

k3s, k3s-airgap-images-amd64.tar
install script는 install.sh 라는 이름으로 다운로드합니다.
 
 

3. k3s 설치

앞서 다운받은 tar파일과 install.sh을 아래의 경로에 넣어줍니다.

sudo mv install.sh /usr/local/bin/
sudo mkdir -p /var/lib/rancher/k3s/agent/images/
sudo cp ./k3s-airgap-images-$ARCH.tar /var/lib/rancher/k3s/agent/images/

 
여기서 air-gap install 이어도 
 
단일 노드에서 설치한다면 아래와 같이 설치해주시면 됩니다.
(컨테이너 런타임을 도커를 사용한다면 --docker 라고 해주시면 되어요)

INSTALL_K3S_SKIP_DOWNLOAD=true ./install.sh

 
 
아주 간단하죠? 
사실 k3s 사이트에 아주 잘 기재되어 있어서 그대로 따라하면 됩니다.
https://docs.k3s.io/installation/airgap

 

Air-Gap Install | K3s

You can install K3s in an air-gapped environment using two different methods. An air-gapped environment is any environment that is not directly connected to the Internet. You can either deploy a private registry and mirror docker.io, or you can manually de

docs.k3s.io

 

4. 노드 추가

agent 추가시 아래와 같이 실행해주시면 됩니다.

INSTALL_K3S_SKIP_DOWNLOAD=true K3S_URL=https://<SERVER_IP>:6443 K3S_TOKEN=<YOUR_TOKEN> ./install.sh

 

5. 결론

웬만한 k8s 기능은 커버하는 것 같지만 현장에서는 k3s를 실무에 잘 사용하진 않았어요. k8s 를 설치하자니 요구되는 노드 수나 설치 방법 등이 조금 귀찮을 수 있는데 테스트용이나 검증용으로는 쓸만하지 않을까 싶습니다.
 
감사합니다.

'IT > 클라우드' 카테고리의 다른 글

[container] wsl2 사용해서 docker 기동하기  (1) 2023.10.23