kubernetes
[따배쿠] Ingress - 개념 및 설치
bbiyak2da
2024. 12. 9. 10:07
Ingress
- 클러스터 외부에서 내부로 접근하는 요청들을 어떻게 처리할 지 정의해둔 규칙들의 모음
- HTTP나 HTTPS를 통해 클러스터 내부의 서비스를 외부로 노출
- 기능
- Service에 외부 URL을 제공 (Client들이 쿠버네티스 내부 서비스에 연결하도록 도와준다.)
- 트래픽을 로드밸런싱 (Pod Ingress Controller가 Client 요청을 받아서, Service에 트래픽 분배하는 구조)
- SSL 인증서 처리 (https 기반 작동)
- 도메인 기반 가상 호스팅 제공
- Ingress는 Rule들을 정의해놓은 리소스이며, 이를 실제 작동시키기 위해 반드시 Ingress Controller가 필요
- 즉, Ingress Controller은 NodePort(80/443)를 열어서 Client 요청을 받은 뒤 Ingress Rules에 따라 서비스를 제공
동작 방식
- #1. Ingress Rules 등록
- https://www.example.com/ > Service main
- https://www.example.com/login > Service login
- https://www.example.com/order > Service order
- #2. Pod Ingress Controller에 의해, Ingress Rule 기반 작동
- https://www.example.com/ 접속 시 > Pod Ingress Controller > Service main
- https://www.example.com/login 접속 시 > Pod Ingress Controller > Service login
- https://www.example.com/order 접속 시 > Pod Ingress Controller > Service order
Ingress Controller 설치
- Ingress Controller는 자동으로 실행되지 않고, 상황에 맞게 적합한 컨트롤러를 선택하여 설치해야한다.
- VM 기반 k8s를 설치했으므로, 해당 공식 문서의 Bare-Metal 항목을 참고하였다.
Installation Guide - Ingress-Nginx Controller
Installation Guide There are multiple ways to install the Ingress-Nginx Controller: with Helm, using the project repository chart; with kubectl apply, using YAML manifests; with specific addons (e.g. for minikube or MicroK8s). On most Kubernetes clusters,
kubernetes.github.io
# Ingress Controller 설치
root@master:~# kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.12.0-beta.0/deploy/static/provider/baremetal/deploy.yaml
namespace/ingress-nginx created
serviceaccount/ingress-nginx created
serviceaccount/ingress-nginx-admission created
role.rbac.authorization.k8s.io/ingress-nginx created
role.rbac.authorization.k8s.io/ingress-nginx-admission created
clusterrole.rbac.authorization.k8s.io/ingress-nginx created
clusterrole.rbac.authorization.k8s.io/ingress-nginx-admission created
rolebinding.rbac.authorization.k8s.io/ingress-nginx created
rolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created
clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx created
clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created
configmap/ingress-nginx-controller created
service/ingress-nginx-controller created
service/ingress-nginx-controller-admission created
deployment.apps/ingress-nginx-controller created
job.batch/ingress-nginx-admission-create created
job.batch/ingress-nginx-admission-patch created
ingressclass.networking.k8s.io/nginx created
validatingwebhookconfiguration.admissionregistration.k8s.io/ingress-nginx-admission created
# 확인
root@master:~# kubectl get pods -n ingress-nginx
NAME READY STATUS RESTARTS AGE
ingress-nginx-admission-create-2x8cw 0/1 Completed 0 13m
ingress-nginx-admission-patch-98tz4 0/1 Completed 2 13m
ingress-nginx-controller-846949fc46-8bvn9 1/1 Running 0 13m
root@master:~# kubectl get svc -n ingress-nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller NodePort 10.105.230.106 <none> 80:31246/TCP,443:31684/TCP 13m
ingress-nginx-controller-admission ClusterIP 10.108.228.15 <none> 443/TCP 13m
참고 영상
https://www.youtube.com/watch?v=y5-u4jtflic&list=PLApuRlvrZKohaBHvXAOhUD-RxD0uQ3z0c&index=28
참고 문서
쿠버네티스 인그레스(Ingress) & 인그레스 컨트롤러(Ingress Controller) + 모니터링