본문 바로가기

Kubernetes

kubernetes ingress

What is Ingress?

인그레스는 클러스터 외부에서 클러스터 내 서비스로의 HTTP 및 HTTPS 경로를 노출합니다. 트래픽 라우팅은 인그레스 리소스에 정의된 규칙에 의해 제어됩니다.

 

 

 

왜 사용할까?

접근하려는 엔드포인트마다, 로드밸런서를 붙이기에는 현실적으로 어렵기에,
ingress의 URI기반 라우팅을 이용하여 로드밸런서 수를 최소화할 수 있습니다.

 

그림과 같이 path 기반으로 각각 다른 서비스로의 라우팅이 일어나고 있습니다.
아래는 해당 그림에 대한 Ingress.yaml 파일입니다.

 

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: simple-fanout-example
spec:
  rules:
  - host: foo.bar.com
    http:
      paths:
      - path: /foo
        pathType: Prefix
        backend:
          service:
            name: service1
            port:
              number: 4200
      - path: /bar
        pathType: Prefix
        backend:
          service:
            name: service2
            port:
              number: 8080

 

 

 

외부 클라이언트 -> 쿠버네티스 pod 까지의 요청 흐름도

 

flowchart TD
    A[클라이언트 Browser / 앱] --> B[LoadBalancer]
    B --> C[Kubernetes Node의 NodePort]
    C --> D[Ingress Controller Pod 예: NGINX]
    D --> E[ClusterIP Service 가상 IP]
    E --> F[kube-proxy iptables/ipvs]
    F --> G[Pod Container]

    G -->|Response| A

    classDef infra fill:#dff0d8,stroke:#4cae4c;
    classDef kube fill:#d9edf7,stroke:#31708f;
    class B,C infra
    class D,E,F,G kube