참고

정적 외부 IP 주소 예약 | Compute Engine 문서 | Google Cloud

사전준비

외부 고정 IP 생성

<aside> 💡 Ingress에서 자동으로 생성하고 annotation까지 붙으니 생략해도 된다. 약 5분 정도 걸림.

</aside>

VPC 네트워크 콘솔 > 고정 주소 예약 클릭

Untitled

유형을 꼭 전역으로 선택해야 함

Untitled

생성된 고정 IP들은 gcloud compute addresses list 명령어로도 확인가능하다.

고정 IP는 아래 명령어로 삭제 가능하다.

gcloud compute addresses delete <address name>

A Record 생성

레코드 세트 추가 를 클릭하여 <sub name>.<cloud dns name> 로 sub domain을 생성한다.

Untitled

IP를 위에서 생성한 Ingress IP(이 ip는 외부 고정 ip이다.)로 설정해준다.

Service 생성

LoadBalancer/NodePort 상관 없음

kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  type: LoadBalancer
  ports:
  - port: 80
    name: http
    targetPort: 80
  selector:
    app: nginx
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        ports:
        - containerPort: 80
          name: http
EOF