Kubernetes 클러스터에서 Ingress 리소스가 동작하려면, 실행 중인 Ingress 컨트롤러가 꼭 필요합니다. Ingress Controller는 일반적으로 로드 밸런서 또는 리버스 프록시를 사용하여 들어오는 트래픽의 실제 라우팅 및 로드 밸런싱을 처리합니다. 즉, 수신 리소스를 처리하고 수신 트래픽을 Ingress 리소스에 따라 클러스터 내의 적절한 서비스로 전달하여 Kubernetes 서비스의 외부 액세스를 가능하게 하는 트래픽 관리자 역할을 합니다.
아래의 명령은 NGINX Ingress 컨트롤러를 활성화합니다.
$ minikube addons enable ingress
💡 ingress is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.
You can view the list of minikube maintainers at: <https://github.com/kubernetes/minikube/blob/master/OWNERS>
💡 After the addon is enabled, please run "minikube tunnel" and your ingress resources would be available at "127.0.0.1"
▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230312-helm-chart-4.5.2-28-g66a760794
▪ Using image registry.k8s.io/ingress-nginx/controller:v1.7.0
▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230312-helm-chart-4.5.2-28-g66a760794
🔎 Verifying ingress addon...
🌟 The 'ingress' addon is enabled
$ kubectl get pods -n ingress-nginx
NAME READY STATUS RESTARTS AGE
ingress-nginx-admission-create-dz9qd 0/1 Completed 0 20s
ingress-nginx-admission-patch-6l78w 0/1 Completed 0 20s
ingress-nginx-controller-6cc5ccb977-j7tq6 0/1 Running 0 20s🎉
아래의 명령으로 Ingress 리소스를 다시 조회하면 ADDRESS 열에서 IPv4 주소 192.168.49.2를 확인할 수 있습니다.
$ kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
example-ingress <none> hello-world.info 192.168.49.2 80 15m🎉
💡 Note: 몇 분 정도 걸릴 수 있습니다.
현재 도커 환경에서 실행 중인 Minikube는 컨테이너로 가상의 노드를 하나 만들고 그 안에 Kubernetes 클러스터를 구성했습니다. 따라서 아래의 명령어로 Minikube 컨테이너 아이디를 확인하고 접속합니다.(컨테이너 아이디(48fe6593f1cc)를 사용자의 컨테이너 아이디로 치환해야 합니다.)
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
48fe6593f1cc gcr.io/k8s-minikube/kicbase:v0.0.39 "/usr/local/bin/entr…" 12 days ago Up About a minute 127.0.0.1:54869->22/tcp, 127.0.0.1:54870->2376/tcp, 127.0.0.1:54872->5000/tcp, 127.0.0.1:54873->8443/tcp, 127.0.0.1:54871->32443/tcp minikube
$ docker exec -it 48fe6593f1cc bash
root@minikube:/#
curl --resolve "hello-world.info:80:192.168.49.2" -i <http://hello-world.info🎉>
이후 아래의 명령어로 Ingress 컨트롤러가 트래픽을 전달하는지 확인합니다.(--resolve 옵션은 지정된 호스트 이름을 사용자 지정 IP 주소 및 포트 조합으로 대응합니다.)
$ curl --resolve "hello-world.info:80:192.168.49.2" -i <http://hello-world.info>
HTTP/1.1 200 OK
Date: Wed, 26 Jul 2023 07:14:31 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 60
Connection: keep-alive
Hello, world!
Version: 1.0.0
Hostname: web-68487bc957-vllsl🎉
Ingress 컨트롤러가 hello-world.info URL로 트래픽을 전달하는 것을 볼 수 있습니다.
[Kubernetes] 서비스 (cluster IP, Nodeport, Loadbalancer) 와 인그레스 (0) | 2024.05.21 |
---|---|
[Kubernetes] pod 설명 (1) | 2024.05.21 |
[Kubernetes] Yaml 설명 (0) | 2024.05.21 |
[Kubernetes] 설치하기 (minikube) (0) | 2024.05.21 |
[Kubernetes] 아키텍처 (0) | 2024.05.21 |