- 일반적으론 외부에서 내부로 향하는 것을 지칭하는 단어
- Ingress 트래픽이라고 하면, 외부에서 서버로 유입되는 트래픽이라 생각하면 된다
- Ingress가 하는 역할은 무수히 많다고 하지만, 대표적으로 꼽으면 아래와 같다고 한다
- 외부 요청의 라우팅 : 특정 경로로 들어온 요청을 특정 Service로 전달하는 규칙을 설정
- 가상 호스트 기반의 요청 처리 : 같은 IP의 다른 도메인으로 요청이 올때, 어떻게 처리할 것인지 설정
- SSL/TLS 보안 연결 처리 : 보안 연결을 위한 인증서 적용
왜 사용할까?
- 하나의 어플리케이션이 여러 개의 Service, Deployment로 생성되어 동작한다고 가정할 때, 이 운영에 대한 설정을 수정할려면 여러 개의 Service와 Deployment에 대해 일일이 설정 수정을 해야 한다
- 그러나 Ingress가 있다면 설정에 대한 수정을 Ingress만 수정을 해주면 되고, 나머지 라우팅 처리는 지정한 규칙에 따라 Service로 포워딩, Service는 Pod로 포워딩해주기 때문에 이에 대한 관리는 편하다고 볼 수 있다
- Ingress는 외부 요청에 대한 처리 규칙을 쿠버네티스 자체의 기능으로 편리하게 관리할 수 있다는 것이 특징
- 그럼 Ingress만 생성해서 사용하면 되는건가? 그렇지 않다. Ingress는 요청을 처리하는 규칙만 정의할 뿐, 실제 외부 요청을 받아들이는 서버가 아니기 때문이다
Ingress Controller
- 실제로 외부 요청을 받아들이는 것은 Ingress Controller 서버이며, 이 서버가 Ingress 규칙을 로드하여 사용하게 된다
- Controller 서버는 여러 종류가 있지만, 대표적으로는 쿠버네티스에서 공식적으로 개발하고 있는 Nginx Ingress Controller를 많이 사용한다고 한다
- 로컬에서 적용할려면 아래와 같이 명령어를 수행한다, 그러면 관련 Pod, Deployment와 Ingress가 생성된다
$ kubectl apply -f <https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.45.0/deploy/static/provider/aws/deploy.yaml>
- Ingress를 사용하는 방법을 순서대로 정리하면 아래와 같다
- 공식 Github에서 제공하는 파일로 Nginx Ingress Controller를 생성한다
- Nginx Ingress Controller를 외부로 노출하기 위한 Service를 생성한다
- 요청 처리 규칙을 정의하는 Ingress를 생성한다
- 여기서 Controller가 자동으로 Ingress를 로드하고 주기적으로 모니터링을 한다고 함
- Nginx Ingress Controller로 들어온 요청은 Ingress 규칙에 따라 Service, Pod로 전달된다