인그레스(Ingress)란?
ingress를 이해하려면 ingress controller를 이해해야 한다.
ingress는 트래픽을 어떻게 라우팅 할 것인가를 정리한 '룰'이고
ingress controller는 ingress의 룰을 적용하여 실제로 라우팅하는 App이다.
정리하면
엔지니어가 ingress를 생성하여 라우팅룰을 설정하고
ingress controller는 ingress를 검증하고 적용한다.
오픈소스로 공개된 ingress-nginx-controller를 기준으로 보자.( https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml )
유저의 트래픽은 ingress controller의 로드밸런서 서비스를 통해 들어온다. ingress controller에 적용된 라우팅 룰을 기준으로 트래픽을 특정한 서비스에 전달한다.
ingress 리소스 예시
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
위 인그레스가 적용된 인그레스 컨트롤러라고 가정해보자. 만약 foo.bar.com을 url로 하는 트래픽이 들어오면
https://foo.bar.com/foo 인 경우, ingress controller는 service1의 4200번 포트로
https://foo.bar.com/bar 인 경우, ingress controller는 service2의 8080번 포트로 라우팅 된다.
ingress와 ingress controller는 N:1 관계를 맺는다.
도메인별로 ingress를 생성하면
실제로 라우팅이 일어나는 곳은 한 곳이지만, 도메인별로 트래픽의 라우팅룰을 나누어 관리할 수 있다.
도메인이 여러 개라고 ingress controller를 여러 개 두는 것은 추천되지 않는다.
ingress controller는 ingress가 생성/수정 이벤트가 발생하면 webhook으로 요청을 가져와, 생성/수정 예정인 ingress에 대한 validation을 진행한다. ( webhook은 https 통신으로 진행되기에, TLS 인증 과정이 필요하다. ) 그러므로 단순히 ingress controller App만 여러 개 띄운다고 될 문제가 아니다. 설정이 복잡해지고 관리 포인트가 많아지므로, ingress controller는 하나를 띄우고 여러 개의 ingress를 관리하는 것이 효과적이다.
다만, ingress controller의 종류를 여러 개라면 ( ex. 하나는 nginx, gce, aws ) 아래 링크를 참조하는 것을 추천한다. https://kubernetes.github.io/ingress-nginx/user-guide/multiple-ingress/
Multiple Ingress controllers - Ingress-Nginx Controller
Multiple Ingress controllers By default, deploying multiple Ingress controllers (e.g., ingress-nginx & gce) will result in all controllers simultaneously racing to update Ingress status fields in confusing ways. To fix this problem, use IngressClasses. The
kubernetes.github.io
참고자료
What is a Kubernetes Ingress Controller | Traefik Labs
A Kubernetes Ingress and ingress controller enable traffic from the internet to reach internal cluster Services. Let's look into what they are and how they work.
traefik.io
Ingress
Make your HTTP (or HTTPS) network service available using a protocol-aware configuration mechanism, that understands web concepts like URIs, hostnames, paths, and more. The Ingress concept lets you map traffic to different backends based on rules you defin
kubernetes.io
What is a difference between Ingress and Ingress controller?
I'm using k8s on GCP. It is required to set ingress to setup TLS connection so I set ingress for my application, it works !!! BTW what is Ingress controller like as Nginx Ingress Controller? I'm...
stackoverflow.com
'DevOps > K8S' 카테고리의 다른 글
[Kubernetes] 프론트엔드, 백엔드 서비스 및 디플로이먼트 생성하기 (0) | 2023.10.12 |
---|---|
[Kubernetes] Minikube 설치 및 인그레스 설치 및 설정하기 (0) | 2023.10.12 |
[Kubernetes] 우분투 환경에서 클러스터 구성하기(4) - 마스터노드, 워커노드 구성하기 (0) | 2023.09.26 |
[Kubernetes] 우분투 환경에서 클러스터 구성하기(3) - 넷필터 브릿지 (0) | 2023.09.25 |
[Kubernetes] 우분투 환경에서 클러스터 구성하기(2) - kubeadm, kubelet, kubectl (0) | 2023.09.22 |