폐쇄망(air-gapped) 환경에서 Kubernetes 클러스터를 설치하려면, 인터넷 연결 없이도 필요한 패키지, 컨테이너 이미지, Helm 차트를 안정적으로 공급할 수 있는 내부 저장소가 필요하다.
이 문서는 Master Node에 Nexus Repository와 Apache2 웹 서버를 설치하고, 이를 통해 APT 패키지, Docker 이미지, Helm 차트를 공급하는 방식으로 Kubernetes를 설치하는 절차를 설명한다.
nexus 전용 서버를 별도로 두는 구성을 권장하나, 비용 절감 측면에서 k8s cluster의
master node에 호스트 기반으로 nexus 설치하는 방법으로 글을 쓴 부분이니
참고바란다.
1. 아키텍처 개요
- Master Node
- Nexus Repository (APT, Docker Registry, Helm Repo)
- Apache2 웹 서버 (kubeadm, kubelet, kubectl 바이너리 제공)
- Kubespray 실행 제어
- Worker Nodes
- Master Node Nexus에서 패키지 및 이미지 Pull
- Master Node Apache2에서 K8s 바이너리 가져오기
Apache2는 기본 80 포트, Nexus는 기본 8081 (APT/Helm) / 5000 (Docker Registry) 사용.
2. 사전 준비
- 필요 파일
kube-system.tar.gz(ctr image export로 추출한 K8s 이미지 번들)docker-images/디렉토리 (추가 필요 이미지)nexus-3.xx-unix.tar.gz- Java 8 이상 (OpenJDK 17 권장, Ubuntu 24.04 기본 제공)
- 환경
- Master Node: 192.168.100.10 (예시)
- Worker Node: 192.168.100.11, 192.168.100.12 …
- OS: Ubuntu 24.04 (noble)
3. kube-system 이미지 압축 해제 (Master)
tar xvzf ~/kube-system.tar.gz
4. Nexus 설치 및 실행 (Master)
- 압축 해제
tar xvzf nexus-3.74.0-05-unix.tar.gz -C /opt/
ln -s /opt/nexus-3.74.0-05 /opt/nexus
- systemd 서비스 등록
/etc/systemd/system/nexus.service:
[Unit]
Description=Nexus Repository
After=network.target
[Service]
Type=forking
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
User=nexus
Restart=on-abort
[Install]
WantedBy=multi-user.target
systemctl enable nexus
systemctl start nexus
systemctl status nexus
- 접속 주소:
http://192.168.100.10:8081
5. Nexus Repository 구성
- APT Repository:
ubuntu24-repo(Hosted) - Docker Registry:
docker-registry(Hosted, HTTP Port 5000) - Helm Repository:
helm-charts(Hosted)
⚠️ Worker Node Docker 설정: /etc/docker/daemon.json
{
"insecure-registries": ["192.168.100.10:5000"]
}
systemctl restart docker
6. Apache2 설치 (Master)
apt install apache2 -y
systemctl enable apache2
systemctl start apache2
/var/www/html/경로에kubeadm,kubelet,kubectl배치- Kubespray의
download_url설정을 Apache2 주소(http://192.168.100.10/)로 지정해야 함
7. Kubespray 설정 (Master)
- Inventory 설정
vi ~/kubespray/inventory/mycluster/inventory.ini
- 다운로드 URL 수정
roles/download/defaults/main.yml:
kubeadm_download_url: "http://192.168.100.10/kubeadm"
kubectl_download_url: "http://192.168.100.10/kubectl"
kubelet_download_url: "http://192.168.100.10/kubelet"
8. Docker 이미지 복사 (Master → Worker)
scp -r ~/docker-images user@192.168.100.11:/home/user/
scp -r ~/docker-images user@192.168.100.12:/home/user/
9. APT Repository 설정 (모든 노드)
Ubuntu 24.04 (noble) → /etc/apt/sources.list.d/nexus.sources
Types: deb
URIs: http://192.168.100.10:8081/repository/ubuntu24-repo/
Suites: noble noble-updates noble-backports
Components: main universe restricted multiverse
Trusted: yes
Types: deb
URIs: http://192.168.100.10:8081/repository/ubuntu24-repo/
Suites: noble-security
Components: main universe restricted multiverse
Trusted: yes
⚠️ 폐쇄망에서는 GPG 키 검증 대신
Trusted: yes사용 권장.
10. Python3 & Ansible 설치 (Master)
apt update
apt install python3 python3.12-venv -y
cd ~/kubespray
python3 -m venv myenv
source myenv/bin/activate
pip install -U -r requirements.txt
11. Kubernetes 클러스터 설치
- SSH Key 배포
ssh-keygen -t rsa
ssh-copy-id user@192.168.100.11
ssh-copy-id user@192.168.100.12
- 설치 실행
ansible-playbook -i inventory/mycluster/inventory.ini \
--become --become-user=root cluster.yml -K
- 이미지 에러 발생 시
sudo ctr image import ~/docker-images/kube-system.tar
12. Helm Repository 구성 (Master)
- Repo 등록
helm repo add internal-helm http://192.168.100.10:8081/repository/helm-charts/
- 차트 업로드
helm package mychart/
curl -u admin:password \
--upload-file mychart-0.1.0.tgz \
http://192.168.100.10:8081/repository/helm-charts/
- 갱신
helm repo update
13. Nexus 활용 확장
- APT/YUM → OS 및 시스템 도구 공급
- Docker Registry → K8s 이미지 공급
- Helm Repo → 모니터링/로깅/인그레스 애드온 설치
- Maven/NPM/PyPI → 내부 개발 패키지 관리
정리
폐쇄망 K8s 환경에서 Nexus를 Master Node에 설치하면, APT 패키지 / Docker 이미지 / Helm 차트를 통합 관리할 수 있다.
- Apache2 → K8s 바이너리 제공
- Nexus → 중앙 저장소 (APT, Docker, Helm)
- Kubespray → 클러스터 자동화
운영 안정성을 위해 insecure-registries, Trusted: yes, download_url 등을 반드시 올바르게 설정해야 하며, 이는 폐쇄망 설치 성공 여부를 좌우한다.
ⓒ 2025 엉뚱한 녀석의 블로그 [quirky guy's Blog]. All rights reserved. Unauthorized copying or redistribution of the text and images is prohibited. When sharing, please include the original source link.
🛠 마지막 수정일: 2025.09.26
답글 남기기
댓글을 달기 위해서는 로그인해야합니다.