목표

이미 설치되어 있는 AKS의 NodePort를 외부로 노출시키기 위해 포트포워딩을 해주자.

쿠버네티스 NodePort 범위: 30000-32767

Network security group 찾기

Azure 콘솔의 Network security groups 페이지에서 MC_*<AKS Name> 으로 시작하는 Resource Group(인프라 리소스 그룹)에 속한 nsg를 검색해서 찾는다.

Untitled

Inbound security rule 추가

해당 nsg의 Inbound security rules 메뉴로 가서 +Add 버튼을 클릭한다.

Untitled

다음과 같이 써준 후 추가해준다. 반드시 똑같이 설정할 필요는 없다. range만 NodePort용으로 30000-32767 로 잘 설정해주면 된다.

Untitled

확인

nginx pod 배포

kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  labels:
    test: test
spec:
  containers:
    - name: nginx-container
      image: nginx
      ports:
        - containerPort: 80
EOF

pod nodeport로 expose

kubectl expose pod nginx-pod --type=NodePort

Nodeport 확인

kubectl get svc nginx-pod

NAME        TYPE       CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
nginx-pod   NodePort   10.0.35.124   <none>        80:30394/TCP   4m18s

AKS Node의 <External IP>:<nginx service Nodeport> 로 접근해보기

Trouble shooting