관련링크 : https://cloud.google.com/kubernetes-engine/docs/concepts/ingress?hl=ko
애플리케이션 부하 분산기용 GKE 인그레스 | Google Kubernetes Engine(GKE) | Google Cloud
이 페이지에서는 애플리케이션 부하 분산기용 인그레스가 무엇인지와 Google Kubernetes Engine(GKE)에서 어떻게 작동하는지에 대해 설명합니다.
cloud.google.com
Public Cloud 내에서 K8S 컨테이너 서비스가 어떻게 서비스되어야 하는지 프로토타입을 제시코자 한다.
위 구성은 AWS 도 마찬가지다. 국내 Public Cloud는 ALB Ingress Controller가 없는 경우도 있어 해당이 안되겠지만, 글로벌 CSP는 위 구성이 Proto Type으로 생각하면된다. 위 구성의 핵심은 WorkerNode를 Internet-facing한 상태로 두지 않고, Application LoadBalancer를 통해서 어플리케이션에 인증서, Proxy 등의 다양한 작업을 할수 있어 유용하다.
어플리케이션 배포를 시작하기 전에 다음 포스팅을 모두 적용하여 인프라구축을 완료하자.
K8S구축 : https://armyost.tistory.com/451
(GCP-GKE) VPC 기반 Private k8s 클러스터 만들기
지난 번에 구축한 VPC를 기반하여 GKE클러스터를 구축하려한다. https://armyost.tistory.com/446 GCP VPC 구축하기 (Public/Private Subnet 구축하기) 필자가 만들고자 하는 VPC는 다음과 같다. AWS에서는 Subnet이 Inter
armyost.tistory.com
VPC 구축 : https://armyost.tistory.com/446
GCP VPC 구축하기 (Public/Private Subnet 구축하기)
필자가 만들고자 하는 VPC는 다음과 같다. AWS에서는 Subnet이 Internet-gateway가 연결되어 있으면 Internet-facing되었다고 생각하고 public subnet이라고 단정짓는다. 하지만 GCP는 private-subnet에 대한 개념이
armyost.tistory.com
1. GKE Kubernetes 엔진의 옵션에서 HTTP Load Balancing 이 Enable 설정이 되어 있는지 확인한다.
※ 가급적이면 container clusters update 는 하지 않기를 추천한다.. 너무 느리다.
2. 생성된 Worker Node가 Internet-facing에 노출되어 있지않는지를 다시 확인한다.
3. k8s 어플리케이션 리소스를 배포한다.
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world-deployment-1
spec:
selector:
matchLabels:
greeting: hello
version: one
replicas: 3
template:
metadata:
labels:
greeting: hello
version: one
spec:
containers:
- name: hello-app-1
image: "us-docker.pkg.dev/google-samples/containers/gke/hello-app:1.0"
env:
- name: "PORT"
value: "50000"
---
apiVersion: v1
kind: Service
metadata:
name: hello-world-1
spec:
type: NodePort
selector:
greeting: hello
version: one
ports:
- protocol: TCP
port: 60000
targetPort: 50000
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world-deployment-2
spec:
selector:
matchLabels:
greeting: hello
version: two
replicas: 3
template:
metadata:
labels:
greeting: hello
version: two
spec:
containers:
- name: hello-app-2
image: "us-docker.pkg.dev/google-samples/containers/gke/hello-app:2.0"
env:
- name: "PORT"
value: "8080"
---
apiVersion: v1
kind: Service
metadata:
name: hello-world-2
spec:
type: NodePort
selector:
greeting: hello
version: two
ports:
- protocol: TCP
port: 80
targetPort: 8080
4. k8s Ingress를 배포한다. 단 ALB Ingress Class를 사용한다.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
annotations:
# If the class annotation is not specified it defaults to "gce".
kubernetes.io/ingress.class: "gce"
spec:
rules:
- http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: hello-world-1
port:
number: 60000
- path: /v2
pathType: ImplementationSpecific
backend:
service:
name: hello-world-2
port:
number: 80
5. 작업완료 (ALB가 배포되는데 5분정도 걸린다)
아래와 같이 Ingress에서 정의했던 정책까지 모두 반영되어 있다.
서비스 확인
'IaaS > 퍼블릭클라우드' 카테고리의 다른 글
(GCP) 공유 VPC란 (1) | 2023.12.06 |
---|---|
(GCP) GCP IAM에 대하여 (1) | 2023.12.06 |
(GCP-GKE) VPC 기반 Private k8s 클러스터 만들기 (0) | 2023.11.27 |
GCP VPC 구축하기 (Public/Private Subnet 구축하기) (0) | 2023.11.24 |
AWS SaaS Boost 프로젝트 (0) | 2023.06.22 |