AWS EKS에서 Service가 여러 개 있을 때 ELB 관찰

woosung LEE·2021년 9월 3일
0

EKS

목록 보기
1/1

개요

AWS EKS에서 서비스를 등록하면 AWS ELB에 자동으로 등록된다.
그런데 같은 포트(80)로 서비스를 여러개 등록하면 어떻게 되는지를 확인하고 싶었다.

테스트

먼저, AWS eksworkshop의 예제로 등록되어 있는 microservice를 배포한다.
https://www.eksworkshop.com/beginner/050_deploy/

apiVersion: v1
kind: Service
metadata:
  name: ecsdemo-frontend
spec:
  selector:
    app: ecsdemo-frontend
  type: LoadBalancer
  ports:
   -  protocol: TCP
      port: 80
      targetPort: 3000

그리고 아래 nginx의 서비스도 80포트로 배포한다.

apiVersion: v1
kind: Service
metadata:
  name: ingress-test
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30010
  type: LoadBalancer

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ingress-test
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80

결과

ecsdemo-frontend와 ingress-test는 모두 80번 포트를 LISTEN하는 서비스인데, EXTERNAL-IP를 보면 서로 다른 ELB 주소를 자동으로 할당하였다.

ic***@DESKTOP-***:~$ k get svc --all-namespaces
NAMESPACE     NAME               TYPE           CLUSTER-IP       EXTERNAL-IP                                                                    PORT(S)         AGE
default       ecsdemo-crystal    ClusterIP      172.20.19.86     <none>                                                                         80/TCP          58m
default       ecsdemo-frontend   LoadBalancer   172.20.147.233   ***773a-1225086146.ap-northeast-2.elb.amazonaws.com   80:30112/TCP    57m
default       ecsdemo-nodejs     ClusterIP      172.20.48.204    <none>                                                                         80/TCP          57m
default       ingress-test       LoadBalancer   172.20.21.117    ***ae25-1267690970.ap-northeast-2.elb.amazonaws.com   80:30010/TCP    37m
default       kubernetes         ClusterIP      172.20.0.1       <none>                                                                         443/TCP         11h
kube-system   kube-dns           ClusterIP      172.20.0.10      <none>                                                                         53/UDP,53/TCP   11h

AWS의 로드밸런서 항목을 확인해도 서로 다른 두개의 LB가 프로비저닝 되어 있다.

0개의 댓글