
minikube
kubernetes 클러스터에 (로컬로) 다음 설정이 있습니다.
- 네임스페이스
customer-a
- 1 배포 -> "Hi from Customer A"를 인쇄합니다.
- 1 LoadBalancer 유형 서비스
- 1 수신 -> 호스트
customer-a.example.com
- 네임스페이스
customer-b
- 1 배포 -> "Hi from Customer B"를 인쇄합니다.
- 1 LoadBalancer 유형 서비스
- 1 수신 -> 호스트
customer-b.example.com
- 네임스페이스
customer-c
- 1 배포 -> "Hi from Customer C"를 인쇄합니다.
- 1 LoadBalancer 유형 서비스
- 1 수신 -> 호스트
customer-c.example.com
이 설정을 클러스터에서 실행 중이므로 수신 서비스에 액세스하려면 명령을 minikube
사용해야 합니다.minikube tunnel
현재 설정은 다음과 같습니다.
// kubectl get ing, svc -n customer-a
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress.networking.k8s.io/customer-a nginx customer-a.example.com 80 11s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/customer-a LoadBalancer 10.96.39.62 127.0.0.1 80:30048/TCP 11s
// kubectl get ing, svc -n customer-b
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress.networking.k8s.io/customer-b nginx customer-b.example.com 192.168.49.2 80 30s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/customer-b LoadBalancer 10.110.126.198 127.0.0.1 80:31292/TCP 30s
// kubectl get ing, svc -n customer-c
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress.networking.k8s.io/customer-c nginx customer-c.example.com 192.168.49.2 80 6m36s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/customer-c LoadBalancer 10.104.99.195 127.0.0.1 80:32717/TCP 6m36s
위 내용에 따르면 EXTERNAL-IP
모든 유형의 서비스는 동일하지만 트래픽 흐름을 차별화하기 위해 위와 같이 ( , , ) LoadBalancer
을 사용했습니다.HOSTS
customer-a.example.com
customer-b.example.com
customer-c.example.com
그리고 아래와 같이 IP를 호스트 이름에 매핑했습니다 /etc/hosts
.
127.0.0.1 customer-a.example.com customer-b.example.com customer-c.example.com
각 URL에 액세스하려고 하면 동일한 결과만 표시됩니다.Hi from Customer C
// curl -kv http://customer-a.example.com
> GET / HTTP/1.1
> Host: customer-a.example.com
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< date: Thu, 29 Dec 2022 00:24:49 GMT
< server: uvicorn
< content-length: 20
< content-type: application/json
<
* Connection #0 to host customer-a.example.com left intact
{"response":"Hi from Customer C"}
// curl -kv http://customer-b.example.com
> GET / HTTP/1.1
> Host: customer-b.example.com
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< date: Thu, 29 Dec 2022 00:24:49 GMT
< server: uvicorn
< content-length: 20
< content-type: application/json
<
* Connection #0 to host customer-b.example.com left intact
{"response":"Hi from Customer C"}
// curl -kv http://customer-c.example.com
> GET / HTTP/1.1
> Host: customer-c.example.com
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< date: Thu, 29 Dec 2022 00:24:49 GMT
< server: uvicorn
< content-length: 20
< content-type: application/json
<
* Connection #0 to host customer-c.example.com left intact
{"response":"Hi from Customer C"}
누군가 이 문제를 찾는 데 도움을 줄 수 있습니까? 나는 이것이 minikube tunnel
?
답변1
이것은 minikube 터널과는 아무런 관련이 없습니다. 여기서 문제는 모든 서비스가 동일한 포트를 사용하여 클러스터 외부와 통신한다는 것입니다. tcp 프로토콜에서는 동일한 시스템에서 실행되는 두 애플리케이션이 동일한 포트 번호를 가질 수 없으므로 이 경우 세 배포 모두에 대해 사용자 지정 포트 번호를 구성하고 로드 밸런서, 수신 또는 nginx 구성에 적절하게 매핑해야 합니다.