NodePort란?

Untitled

오른쪽 하단에 위치한 외부의 End user가 접속 할 수 있도록 worker node에 port를 열어주는 역할

Untitled


  1. kubectl config use-context k8s
  2. kubectl get pod —selector app=webui —show labels ⇒ -selector 대신 -l 로 줄여써도 됌
  3. service(공홈) → type: clusterIP 부분에 코드 존재
apiVersion: v1
kind: Service
metadata:
	name: my-service(임의로 지정하면 됌)
spec:
	type: NodePort
	selector:
		app.kubernetes.io/name: MyApp
	ports:
    -port: 80
		# By default and for convenience, the `targetPort` is set to
		# the same value as the `port` field.
		targetPort: 80
		# Optional field
		# By default and for convenience, the Kubernetes control plane
		# will allocate a port from a range (default: 30000-32767)
		nodePort: 30007
apiVersion: v1
kind: Service
metadata:
	name: my-service
spec:
	type: NodePort
	selector:
		app: webui
	ports:
    -port: 80
		targetPort: 80
		nodePort: 32767

⇒ 문제에 주어진 대로 값 변경

  1. cat > myservice.yaml
  2. 4.번 이후 수정한 코드 복붙
  3. kubectl apply -f myservice.yaml ⇒ yaml 파일 만든 후 실행 시키기 위함
  4. kubectl get svc my-service ⇒ 생성 확인
  5. curl k8s-weroker1:32767 ⇒ Ready 상태인게 k8s-worker1이여서 k8s-worker1로 curl을 수행