728x90
SMALL
- MetalLB는 Bare Metal 환경에서 LoadBalancer 서비스를 사용할 수 있도록 도와줌.
- 결과적으로 MetalLB를 통해 Kubernetes 서비스에 외부에서 접근 가능해짐
✅ (1) MetalLB 설치
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/main/config/manifests/metallb-native.yaml
✔ 설치 확인
kubectl get ns
kubectl get pods -n metallb-system
✔ 정상 출력
NAME READY STATUS RESTARTS AGE
controller-5b5b575d55-cdxg4 1/1 Running 0 21s
speaker-24n4q 1/1 Running 0 21s
speaker-j8df9 0/1 Running 0 21s
speaker-r4h8j 1/1 Running 0 21s
✅ (2) MetalLB IP Address Pool 설정
📌 할당 가능한 IP 주소 범위를 설정해야 함
📌 파일명: metallb-config.yaml
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: first-pool
namespace: metallb-system
spec:
addresses:
- 192.168.98.200-192.168.98.210 # LoadBalancer에서 사용할 IP 범위
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: example
namespace: metallb-system
📌 적용 명령어
kubectl apply -f metallb-config.yaml
✔ 설정 확인
kubectl get ipaddresspools -n metallb-system
✔ 정상 출력 예시
NAME AUTO ASSIGN AVOID BUGGY IPS ADDRESSES
first-pool true false ["192.168.98.200-192.168.98.210"]
✅ (3) Ingress Controller 서비스 재배포
📌 Ingress Controller가 LoadBalancer를 정상적으로 할당받도록 다시 배포
(1) 기존 서비스 삭제
kubectl delete svc -n ingress-nginx ingress-nginx-controller
(2) 새로운 LoadBalancer 서비스 생성
📌 파일명: ingress-service.yaml
apiVersion: v1
kind: Service
metadata:
name: ingress-nginx-controller
namespace: ingress-nginx
spec:
type: LoadBalancer
selector:
app.kubernetes.io/name: ingress-nginx
ports:
- name: http
port: 80
targetPort: 80
- name: https
port: 443
targetPort: 443
📌 적용 명령어
kubectl apply -f ingress-service.yaml
✅ (4) EXTERNAL-IP 확인
kubectl get svc -n ingress-nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller LoadBalancer 10.110.92.164 192.168.98.200 80:30564/TCP,443:32331/TCP 2m35s
ingress-nginx-controller-admission ClusterIP 10.104.85.154 <none> 443/TCP 22m
🚀 이제 http://192.168.98.200/ 로 직접 접속 가능
상세 조회
- Pod 조회
kubectl get pods -n ingress-nginx
NAME READY STATUS RESTARTS AGE
ingress-nginx-admission-create-xn526 0/1 Completed 0 166m
ingress-nginx-admission-patch-mwwlq 0/1 Completed 0 166m
ingress-nginx-controller-84549bc57f-kzn44 1/1 Running 0 11m
- pod 접근 후 index.html 찾기
kubectl exec -it ingress-nginx-controller-84549bc57f-kzn44 -n ingress-nginx -- /bin/sh
/etc/nginx $
/etc/nginx $
/etc/nginx $
/etc/nginx $
/etc/nginx $
/etc/nginx $
/etc/nginx $
/etc/nginx $ find / -name index.html
find: /proc/tty/driver: Permission denied
find: /root: Permission denied
/usr/local/nginx/html/index.html
- 파일 내용 확인
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
LIST
'🔹Kubernetes' 카테고리의 다른 글
Kubernetes 워크로드 리소스들의 특징 및 종속성 (0) | 2025.02.25 |
---|---|
kubernetes Service vs Ingress 비교 (0) | 2025.02.02 |
Ingress Controller 설치 (0) | 2025.02.02 |
Kubernetes 설정 파일 제거 (0) | 2025.02.01 |
Service 정의 (0) | 2025.01.27 |