Network Flow

물뮤 백엔드 네트워크 구성 완전 정복! 🚀

안녕하세요, 개발자 여러분! 😊 오늘은 제가 물뮤(MoolMeow) 프로젝트에서 온프레미스 쿠버네티스 클러스터를 외부에 어떻게 연결했는지 네트워크 구성에 대해 알려드릴게요. 집에서 서버 굴리는 분들에게 꿀팁이 될 거예요! 🍯

🌐 전체 네트워크 흐름도

먼저 큰 그림부터 봐볼까요? 물뮤의 네트워크는 여러 계층으로 구성되어 있답니다.

클라이언트 🖥️
   ↓
Cloudflare ☁️ (DNS + HTTPS/TLS termination)
   ↓
MikroTik Router 🌉 (포트포워딩 + NAT + 방화벽)
   ↓
MetalLB 🔄 (Kubernetes LoadBalancer)
   ↓
Ingress Controller 🚦 (nginx ingress)
   ↓
Kubernetes Services 🔹 (ClusterIP)
   ↓
Pods 📦 (Application backend)

이제 각 계층을 자세히 살펴볼게요! 🔍

☁️ 1단계: Cloudflare

역할: 글로벌 DNS와 HTTPS 보안의 첫 관문

  • DNS 설정

    • *.moolmeow.local → 우리 집 IP 주소로 연결
    • 집 IP가 바뀌어도 DNS가 자동으로 업데이트되는 장점이 있어요
  • 보안 이점

    • 무료 SSL/TLS 인증서 제공 (Let’s Encrypt)
    • DDoS 보호 기능
    • “Full (strict)” 모드로 엔드-투-엔드 암호화

🌉 2단계: MikroTik 라우터

역할: 외부에서 들어오는 트래픽을 쿠버네티스로 안전하게 전달

  • 포트포워딩 설정

    • 외부에서 들어오는 80/443 포트를 쿠버네티스 LoadBalancer IP로 전달
    • 예: 외부 포트 80 → 10.98.63.xx:80
  • 방화벽 설정

    • 필요한 포트만 허용하는 엄격한 규칙 적용
    • 국가별 IP 차단 기능도 활용 가능 (특정 국가에서의 접근 차단)
  • NAT 설정

    • 내부 Kubernetes 노드가 외부로 통신할 수 있도록 src-nat 설정
    • 내부 IP 주소 체계 보호 (사설 IP 사용)

🔄 3단계: MetalLB

역할: 베어메탈 환경에서 LoadBalancer 구현 (클라우드 없이!)

  • 설정 방법

    • IP 주소 풀 설정: 10.98.63.xx/xx 범위 지정
    • L2 광고 모드 활성화
  • 작동 원리

    • 쿠버네티스 서비스가 LoadBalancer 타입으로 요청하면 IP 할당
    • ARP 요청에 응답하여, 로컬 네트워크에 해당 IP로 트래픽을 라우팅하도록 알림
  • 실제 설정 예시

    apiVersion: metallb.io/v1beta1
    kind: IPAddressPool
    metadata:
      name: first-pool
      namespace: metallb-system
    spec:
      addresses:
      - 10.98.63.50-10.98.63.70  # 사용할 IP 범위
    

🚦 4단계: NGINX Ingress Controller

역할: 트래픽을 여러 서비스로 라우팅 (도메인별, 경로별 분배)

  • 설치 방법

    • Helm 차트로 간편하게 설치
    helm install ingress-nginx ingress-nginx/ingress-nginx \
      --namespace ingress-nginx \
      --create-namespace
    
  • 주요 기능

    • 호스트 기반 라우팅 (각 서비스마다 다른 서브도메인)
    • 경로 기반 라우팅 (같은 도메인 내에서 URL 경로에 따라 분배)
    • TLS 인증서 관리 (필요시)
    • 속도 제한, 리다이렉션 등 다양한 고급 기능
  • 실제 Ingress 예시

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: minio-console
      namespace: minio
    spec:
      ingressClassName: nginx
      rules:
      - host: minio.moolmeow.local
        http:
          paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: minio-console
                port:
                  number: 9001
    

🔹 5단계: Kubernetes Services

역할: 파드 집합에 대한 안정적인 엔드포인트 제공

  • 주요 서비스

    • ArgoCD 서버
    • Jenkins
    • MinIO 콘솔
    • 기타 백엔드 서비스들
  • 설정 방식

    • 대부분 ClusterIP 타입 사용 (내부 통신용)
    • Selector로 적절한 파드 타겟팅
    • 필요한 포트 노출

📦 6단계: 애플리케이션 Pods

역할: 실제 애플리케이션 실행

  • 구성 요소

    • 물뮤 백엔드 API 서버
    • 인증 서비스
    • 데이터베이스
    • 캐시 서버
    • 미디어 저장소
  • 스토리지 연결

    • NFS 기반 PV/PVC로 데이터 영속성 확보
    • MinIO 객체 스토리지 사용

💡 유용한 팁

로컬 개발 환경에서 테스트하기

  • /etc/hosts 파일에 다음 내용 추가
    10.98.63.xx jenkins.moolmeow.local10.98.63.xx argocd.moolmeow.local10.98.63.xx minio.moolmeow.local
    

보안 강화 방법

  • Cloudflare의 무료 WAF(웹 애플리케이션 방화벽) 활용
  • MikroTik에서 불필요한 포트 차단
  • 쿠버네티스 네트워크 정책 적용

모니터링 설정

  • 프로메테우스 + 그라파나로 네트워크 트래픽 모니터링
  • 알림 설정하여 비정상 트래픽 감지

🎯 물뮤 네트워크 구성의 장점

  1. 비용 효율성 – 클라우드 서비스 없이도 LoadBalancer 활용 가능
  2. 보안성 – 여러 계층의 보안 장치
  3. 확장성 – 트래픽 증가에 따라 쉽게 확장 가능
  4. 유연성 – 다양한 서비스를 하나의 IP로 호스팅

📝 마무리

집에서 쿠버네티스 클러스터를 운영하면서 외부에 서비스를 제공하는 것은 쉽지 않은 일이지만, 이런 계층화된 네트워크 구성을 통해 안정적이고 안전하게 서비스를 운영할 수 있습니다. 물뮤 프로젝트를 통해 배운 이 구성이 여러분의 홈 서버 운영에도 도움이 되길 바랍니다! 🙌

궁금한 점이나 더 자세히 알고 싶은 부분이 있으시면 댓글로 남겨주세요! 기술적인 세부사항도 공유해 드릴 수 있어요. 💌

MoolMeow Backend Network Architecture: A Comprehensive Guide! 🚀

Hello fellow developers! 😊 Today I’m excited to share how I connected my on-premises Kubernetes cluster to the internet for the MoolMeow project. If you’re running servers from home, this will be super helpful! 🍯

🌐 Overall Network Flow

Let’s start with the big picture! The MoolMeow network is structured in multiple layers:

Client 🖥️
   ↓
Cloudflare ☁️ (DNS + HTTPS/TLS termination)
   ↓
MikroTik Router 🌉 (Port forwarding + NAT + Firewall)
   ↓
MetalLB 🔄 (Kubernetes LoadBalancer)
   ↓
Ingress Controller 🚦 (nginx ingress)
   ↓
Kubernetes Services 🔹 (ClusterIP)
   ↓
Pods 📦 (Application backend)

Now, let’s explore each layer in detail! 🔍

☁️ Layer 1: Cloudflare

Role: Global DNS and first line of HTTPS security

  • DNS Configuration

    • *.moolmeow.local → Your home IP address
    • Benefit: DNS updates automatically if your home IP changes
  • Security Benefits

    • Free SSL/TLS certificates (Let’s Encrypt)
    • DDoS protection
    • “Full (strict)” mode for end-to-end encryption

🌉 Layer 2: MikroTik Router

Role: Securely forwarding external traffic to Kubernetes

  • Port Forwarding Configuration

    • Forward external ports 80/443 to Kubernetes LoadBalancer IP
    • Example: External Port 80 → 10.98.63.xx:80
  • Firewall Settings

    • Strict rules allowing only necessary ports
    • Optional country-based IP blocking (block access from specific countries)
  • NAT Configuration

    • src-nat setup to allow internal Kubernetes nodes to communicate externally
    • Protects internal IP address scheme (using private IPs)

🔄 Layer 3: MetalLB

Role: Implementing LoadBalancer in bare-metal environments (without cloud!)

  • Setup Method

    • IP address pool configuration: Specify 10.98.63.xx/xx range
    • Enable L2 advertisement mode
  • How It Works

    • Assigns IPs when Kubernetes services request LoadBalancer type
    • Responds to ARP requests, instructing local network to route traffic to that IP
  • Real Configuration Example

    apiVersion: metallb.io/v1beta1
    kind: IPAddressPool
    metadata:
      name: first-pool
      namespace: metallb-system
    spec:
      addresses:
      - 10.98.63.50-10.98.63.70  # IP range to use
    

🚦 Layer 4: NGINX Ingress Controller

Role: Routing traffic to various services (by domain, by path)

  • Installation Method

    • Easy installation with Helm chart
    helm install ingress-nginx ingress-nginx/ingress-nginx \
      --namespace ingress-nginx \
      --create-namespace
    
  • Key Features

    • Host-based routing (different subdomain for each service)
    • Path-based routing (distribution within same domain based on URL path)
    • TLS certificate management (if needed)
    • Advanced features like rate limiting, redirections, etc.
  • Real Ingress Example

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: minio-console
      namespace: minio
    spec:
      ingressClassName: nginx
      rules:
      - host: minio.moolmeow.local
        http:
          paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: minio-console
                port:
                  number: 9001
    

🔹 Layer 5: Kubernetes Services

Role: Providing stable endpoints for pod sets

  • Main Services

    • ArgoCD server
    • Jenkins
    • MinIO console
    • Other backend services
  • Configuration Approach

    • Mostly using ClusterIP type (for internal communication)
    • Targeting appropriate pods with Selector
    • Exposing necessary ports

📦 Layer 6: Application Pods

Role: Running actual applications

  • Components

    • MoolMeow Backend API server
    • Authentication service
    • Database
    • Cache server
    • Media storage
  • Storage Connection

    • Data persistence with NFS-based PV/PVC
    • Using MinIO object storage

💡 Useful Tips

Testing in Local Development Environment

  • Add the following to your /etc/hosts file
    10.98.63.xx jenkins.moolmeow.local10.98.63.xx argocd.moolmeow.local10.98.63.xx minio.moolmeow.local
    

Enhancing Security

  • Utilize Cloudflare’s free WAF (Web Application Firewall)
  • Block unnecessary ports on MikroTik
  • Apply Kubernetes network policies

Setting Up Monitoring

  • Monitor network traffic with Prometheus + Grafana
  • Configure alerts to detect abnormal traffic

🎯 Benefits of MoolMeow Network Architecture

  1. Cost Efficiency – Using LoadBalancer without cloud services
  2. Security – Multiple layers of security measures
  3. Scalability – Easy expansion as traffic increases
  4. Flexibility – Hosting multiple services with a single IP

📝 Conclusion

Running a Kubernetes cluster at home and exposing services externally isn’t easy, but with this layered network configuration, you can operate services reliably and securely. I hope that the configuration we learned through the MoolMeow project helps with your home server operations too! 🙌

If you have any questions or want to know more details, please leave a comment! I’d be happy to share more technical specifics. 💌

답글 남기기