[k8s] 서비스 외부에 노출하기 - NodePort

Donghyun Kim·2023년 3월 27일
0

Service Port 유형

NodePort

  • 외부에서 접속하기 위해 사용하는 포트

port

  • Cluster 내부에서 사용할 Service 객체의 포트

targetPort

  • Service객체로 전달된 요청을 Pod(deployment)로 전달할때 사용하는 포트

전체 서비스 흐름으로 보면 NodePort --> Port --> targetPort

예시

apiVersion: v1
kind: Service
metadata:
  name: helloworld-service
spec:
  ports:
  - nodePort: 31001
    port: 8080
    targetPort: 80
    protocol: TCP
  selector:
    app: helloworld
  type: NodePort

Worker Node의 IP와 Service에 등록된 NodePort로 접근하면
Service의 targetPort로 Selector에 매핑된 Pod와 연결 후
Pod에 생성된 컨테이너 Port로 다시 연결

profile
"Hello World"

0개의 댓글