์ด ํ์ด์ง์์๋ ์ฌ๋ฌ Google Kubernetes Engine(GKE) ํด๋ฌ์คํฐ(๋๋ Fleet)์ ์ธ๊ทธ๋ ์ค ํธ๋ํฝ์ ๋ถํ ๋ถ์ฐํ๊ธฐ ์ํด Kubernetes ๊ฒ์ดํธ์จ์ด ๋ฆฌ์์ค๋ฅผ ๋ฐฐํฌํ๋ ๋ฐฉ๋ฒ์ ์ค๋ช ํฉ๋๋ค. ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ฅผ ๋ฐฐํฌํ๋ ค๋ฉด ๋จผ์ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด ์ฌ์ฉ ์ค์ ์ ์ฐธ์กฐํ์ฌ ํ๊ฒฝ์ ์ค๋นํ์ธ์.
์ธ๊ทธ๋ ์ค ํธ๋ํฝ์ ๋จ์ผ GKE ํด๋ฌ์คํฐ๋ก ๋ถํ ๋ถ์ฐํ๊ธฐ ์ํ ๊ฒ์ดํธ์จ์ด๋ฅผ ๋ฐฐํฌํ๋ ค๋ฉด ๊ฒ์ดํธ์จ์ด ๋ฐฐํฌ๋ฅผ ์ฐธ์กฐํ์ธ์.
๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด
๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ ์ฌ๋ฌ Kubernetes ํด๋ฌ์คํฐ ๊ฐ์ ํธ๋ํฝ์ ๋ถํ ๋ถ์ฐํ๋ ๊ฒ์ดํธ์จ์ด ๋ฆฌ์์ค์
๋๋ค. GKE์์ gke-l7-global-external-managed-mc
, gke-l7-regional-external-managed-mc
, gke-l7-rilb-mc
, gke-l7-gxlb-mc
GatewayClass๋ ์ฌ๋ฌ GKE ํด๋ฌ์คํฐ, Kubernetes ๋ค์์คํ์ด์ค, ๋ฆฌ์ ๊ฐ์ HTTP ๋ผ์ฐํ
, ํธ๋ํฝ ๋ถํ , ํธ๋ํฝ ๋ฏธ๋ฌ๋ง, ์ํ ๊ธฐ๋ฐ ์ฅ์ ์กฐ์น ๋ฑ์ ์ ๊ณตํ๋ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ฅผ ๋ฐฐํฌํฉ๋๋ค.
๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ ์ธํ๋ผ ๊ด๋ฆฌ์๋ฅผ ์ํด ์ฌ๋ฌ ํด๋ฌ์คํฐ ๋ฐ ํ ๊ฐ์ ์ ํ๋ฆฌ์ผ์ด์
๋คํธ์ํน ๊ด๋ฆฌ๋ฅผ ์ฝ๊ณ , ์์ ํ๊ณ , ํ์ฅ ๊ฐ๋ฅํ๊ฒ ๋ง๋ญ๋๋ค.
์ด ํ์ด์ง์์๋ GKE Gateway Controller๋ฅผ ์ฌ์ฉํ์ฌ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ฅผ ๋ฐฐํฌํ๋ ๋ฐฉ๋ฒ์ ์๋ ค์ฃผ๊ธฐ ์ํด ์ธ ๊ฐ์ง ์์๋ฅผ ์๊ฐํฉ๋๋ค.
- ์์ 1: ์ธํฐ๋ท ํธ๋ํฝ์ ์ํด 2๊ฐ์ GKE ํด๋ฌ์คํฐ ๊ฐ์ ๋ถํ ๋ถ์ฐ์ ์ ๊ณตํ๋ ์ธ๋ถ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด
- ์์ 2: ๋ด๋ถ VPC ํธ๋ํฝ์ ์ํด 2๊ฐ์ GKE ํด๋ฌ์คํฐ ๊ฐ์ ๋ธ๋ฃจ-๊ทธ๋ฆฐ ๊ฐ์ค์น ๊ธฐ๋ฐ ํธ๋ํฝ ๋ถํ ๋ฐ ํธ๋ํฝ ๋ฏธ๋ฌ๋ง
- ์์ 3: ์ต๋ ์ฉ๋์ ๊ธฐ์ค์ผ๋ก ์ฌ๋ฌ ๋ฐฑ์๋๋ก ์์ฒญ์ ๋ถํ ๋ถ์ฐํ๋ ์ฉ๋ ๊ธฐ๋ฐ ๊ฒ์ดํธ์จ์ด
๊ฐ ์์์์๋ ๋์ผํ ๋งค์ฅ ๋ฐ ์ฌ์ดํธ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฌ์ฉํ์ฌ ์จ๋ผ์ธ ์ผํ ์๋น์ค์ ์น์ฌ์ดํธ ์๋น์ค๊ฐ ๊ฐ๋ณ ํ์ ์ํด ์์ ๋ฐ ์ด์๋๊ณ ๊ณต์ ๋๋ GKE ํด๋ฌ์คํฐ์ Fleet ๊ฐ์ ๋ฐฐํฌ๋๋ ์ค์ ์๋๋ฆฌ์ค๋ฅผ ๋ชจ๋ธ๋งํฉ๋๋ค. ๊ฐ ์์์์๋ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด์์ ์ฌ์ฉ ์ค์ ํ๋ ์๋ก ๋ค๋ฅธ ํ ํด๋ก์ง์ ์ฌ์ฉ ์ฌ๋ก๋ฅผ ๊ฐ์กฐํ์ํฉ๋๋ค.
๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ ๋ฐฐํฌ๋๊ธฐ ์ ๋ช ๊ฐ์ง ํ๊ฒฝ์ ์ธ ์ค๋น๊ฐ ์๊ตฌ๋ฉ๋๋ค. ๊ณ์ํ๊ธฐ ์ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด ์ฌ์ฉ ์ค์ ์ ๋จ๊ณ๋ฅผ ๋ค๋ฅด์ธ์.
GKE ํด๋ฌ์คํฐ๋ฅผ ๋ฐฐํฌํฉ๋๋ค.
Fleet์ ํด๋ฌ์คํฐ๋ฅผ ๋ฑ๋กํฉ๋๋ค.
๋ฉํฐ ํด๋ฌ์คํฐ ์๋น์ค ๋ฐ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด ์ปจํธ๋กค๋ฌ๋ฅผ ์ฌ์ฉ ์ค์ ํฉ๋๋ค.
๋ง์ง๋ง์ผ๋ก ํ๊ฒฝ์์ ์ฌ์ฉํ๊ธฐ ์ ์ GKE Gateway Controller ์ ํ์ฌํญ ๋ฐ ์๋ ค์ง ๋ฌธ์ ๋ฅผ ๊ฒํ ํฉ๋๋ค.
๋ฉํฐ ํด๋ฌ์คํฐ, ๋ฉํฐ ๋ฆฌ์ , ์ธ๋ถ ๊ฒ์ดํธ์จ์ด
์ด ํํ ๋ฆฌ์ผ์์๋ 2๊ฐ์ GKE ํด๋ฌ์คํฐ์์ ์คํ๋๋ ์ ํ๋ฆฌ์ผ์ด์ ๊ฐ์ ์ธ๋ถ ํธ๋ํฝ์ ์ ๊ณตํ๋ ์ธ๋ถ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ฅผ ๋ง๋ญ๋๋ค.
๋ค์ ๋จ๊ณ์์ ๋ค์์ ์ํํฉ๋๋ค.
gke-west-1
๋ฐgke-east-1
ํด๋ฌ์คํฐ์ ์ํstore
์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฐฐํฌํฉ๋๋ค.- Fleet์ผ๋ก ๋ด๋ณด๋ผ ๊ฐ ํด๋ฌ์คํฐ์ ์๋น์ค๋ฅผ ๊ตฌ์ฑํฉ๋๋ค(๋ฉํฐ ํด๋ฌ์คํฐ ์๋น์ค).
- ๊ตฌ์ฑ ํด๋ฌ์คํฐ(
gke-west-1
)์ ์ธ๋ถ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด ๋ฐ HTTPRoute๋ฅผ ๋ฐฐํฌํฉ๋๋ค.
์ ํ๋ฆฌ์ผ์ด์ ๋ฐ ๊ฒ์ดํธ์จ์ด ๋ฆฌ์์ค๊ฐ ๋ฐฐํฌ๋ ํ ๊ฒฝ๋ก ๊ธฐ๋ฐ ๋ผ์ฐํ ์ ์ฌ์ฉํ์ฌ 2๊ฐ์ GKE ํด๋ฌ์คํฐ ๊ฐ์ ํธ๋ํฝ์ ์ ์ดํ ์ ์์ต๋๋ค.
/west
์ ๋ํ ์์ฒญ์gke-west-1
ํด๋ฌ์คํฐ์store
ํฌ๋์ ๋ผ์ฐํ ๋ฉ๋๋ค./east
์ ๋ํ ์์ฒญ์gke-east-1
ํด๋ฌ์คํฐ์store
ํฌ๋์ ๋ผ์ฐํ ๋ฉ๋๋ค.- ๋ค๋ฅธ ๊ฒฝ๋ก์ ๋ํ ์์ฒญ์ ์์ฒญ ํด๋ผ์ด์ธํธ์ ๋ํ ํด๋น ์ํ, ์ฉ๋, ๊ทผ์ ์ฑ์ ๋ฐ๋ผ ๊ฐ ํด๋ฌ์คํฐ์ ๋ผ์ฐํ ๋ฉ๋๋ค.
๋ฐ๋ชจ ์ ํ๋ฆฌ์ผ์ด์ ๋ฐฐํฌ
๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด ์ฌ์ฉ ์ค์ ์ ๋ฐฐํฌ๋ ํด๋ฌ์คํฐ 3๊ฐ ๋ชจ๋์
store
๋ฐฐํฌ ๋ฐ ๋ค์์คํ์ด์ค๋ฅผ ๋ง๋ญ๋๋ค.kubectl apply --context gke-west-1 -f https://raw.githubusercontent.com/GoogleCloudPlatform/gke-networking-recipes/main/gateway/gke-gateway-controller/multi-cluster-gateway/store.yaml kubectl apply --context gke-west-2 -f https://raw.githubusercontent.com/GoogleCloudPlatform/gke-networking-recipes/main/gateway/gke-gateway-controller/multi-cluster-gateway/store.yaml kubectl apply --context gke-east-1 -f https://raw.githubusercontent.com/GoogleCloudPlatform/gke-networking-recipes/main/gateway/gke-gateway-controller/multi-cluster-gateway/store.yaml
๊ฐ ํด๋ฌ์คํฐ์ ๋ค์ ๋ฆฌ์์ค๋ฅผ ๋ฐฐํฌํฉ๋๋ค.
namespace/store created deployment.apps/store created
์ด ํ์ด์ง์ ๋ชจ๋ ์์์๋ ์ด ๋จ๊ณ์์ ๋ฐฐํฌ๋ ์ฑ์ด ์ฌ์ฉ๋ฉ๋๋ค. ๋จ์ ๋จ๊ณ๋ฅผ ์๋ํ๊ธฐ ์ 3๊ฐ ํด๋ฌ์คํฐ ๋ชจ๋์ ์ฑ์ด ๋ฐฐํฌ๋์๋์ง ํ์ธํฉ๋๋ค. ์ด ์์์์๋
gke-west-1
๋ฐgke-east-1
ํด๋ฌ์คํฐ๋ง ์ฌ์ฉ๋๊ณgke-west-2
๋ ๋ค๋ฅธ ์์์์ ์ฌ์ฉ๋ฉ๋๋ค.
๋ฉํฐ ํด๋ฌ์คํฐ ์๋น์ค
์๋น์ค๋ ํฌ๋๊ฐ ํด๋ผ์ด์ธํธ์ ๋ ธ์ถ๋๋ ๋ฐฉ๋ฒ์ ์ ์ดํฉ๋๋ค. GKE Gateway Controller์ ์ปจํ ์ด๋ ๊ธฐ๋ฐ ๋ถํ ๋ถ์ฐ์ด ์ฌ์ฉ๋๊ธฐ ๋๋ฌธ์ ํฌ๋ ์ฐ๊ฒฐ์ ์ํด ClusterIP ๋๋ Kubernetes ๋ถํ ๋ถ์ฐ์ ์ฌ์ฉํ์ง ์์ต๋๋ค. ํธ๋ํฝ์ ๋ถํ ๋ถ์ฐ๊ธฐ์์ ํฌ๋ IP ์ฃผ์๋ก ์ง์ ์ ์ก๋ฉ๋๋ค. ํ์ง๋ง ์๋น์ค๋ ์ฌ์ ํ ํฌ๋ ๊ทธ๋ฃนํ์ ๋ํ ๋ ผ๋ฆฌ์ ์๋ณ์๋ก์ ์ค์ํ ์ญํ ์ ์ํํฉ๋๋ค.
๋ฉํฐ ํด๋ฌ์คํฐ ์๋น์ค(MCS)๋ ํด๋ฌ์คํฐ์ ๊ฑธ์ณ์ง ์๋น์ค์ API ํ์ค์ด๊ธฐ๋ ํ๊ณ GKE ํด๋ฌ์คํฐ ๊ฐ์ ์๋น์ค ๊ฒ์์ ์ ๊ณตํ๋ GKE ์ปจํธ๋กค๋ฌ์ด๊ธฐ๋ ํฉ๋๋ค. ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด ์ปจํธ๋กค๋ฌ๋ MCS API ๋ฆฌ์์ค๋ฅผ ์ฌ์ฉํ์ฌ ์ฌ๋ฌ ํด๋ฌ์คํฐ ๊ฐ์ ์ฃผ์ ์ง์ ๋๊ฑฐ๋ ๊ฑธ์ณ ์๋ ์๋น์ค๋ก ํฌ๋๋ฅผ ๊ทธ๋ฃนํํฉ๋๋ค.
๋ฉํฐ ํด๋ฌ์คํฐ Services API๋ ๋ค์ ์ปค์คํ ๋ฆฌ์์ค๋ฅผ ์ ์ํฉ๋๋ค.
- ServiceExports๋ Kubernetes ์๋น์ค์ ๋งคํ๋๋ฉฐ, ํด๋น ์๋น์ค์ ์๋ํฌ์ธํธ๋ฅผ Fleet์ ๋ฑ๋ก๋ ๋ชจ๋ ํด๋ฌ์คํฐ๋ก ๋ด๋ณด๋ ๋๋ค. ์๋น์ค์ ํด๋น ServiceExport๊ฐ ์์ผ๋ฉด ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๊ฐ ์๋น์ค์ ์ฃผ์ ์ง์ ํ ์ ์์์ ์๋ฏธํฉ๋๋ค.
- ServiceImports๋ ๋ฉํฐ ํด๋ฌ์คํฐ ์๋น์ค ์ปจํธ๋กค๋ฌ์์ ์๋์ผ๋ก ์์ฑ๋ฉ๋๋ค. ServiceExport ๋ฐ ServiceImport๋ ์์ผ๋ก ์ ๊ณต๋ฉ๋๋ค. ServiceExport๊ฐ Fleet์ ์กด์ฌํ ๊ฒฝ์ฐ ServiceExport์ ๋งคํ๋ ์๋น์ค๋ฅผ ํด๋ฌ์คํฐ ๊ฐ์ ์ฃผ์ ์ง์ ํ ์ ์๋๋ก ํด๋น ServiceImport๊ฐ ์์ฑ๋ฉ๋๋ค.
์๋น์ค ๋ด๋ณด๋ด๊ธฐ๋ ๋ค์ ๋ฐฉ๋ฒ์ผ๋ก ์๋ํฉ๋๋ค. ๋งค์ฅ ์๋น์ค๋ ํด๋น ํด๋ฌ์คํฐ์์ ํฌ๋ ๊ทธ๋ฃน์ ์ ํํ๋ gke-west-1
์ ์กด์ฌํฉ๋๋ค. ServiceExport๋ Fleet์ ๋ค๋ฅธ ํด๋ฌ์คํฐ์์ gke-west-1
์ ํฌ๋์ ์ก์ธ์คํ ์ ์๊ฒ ํด์ฃผ๋ ํด๋ฌ์คํฐ์ ์์ฑ๋ฉ๋๋ค. ServiceExport๋ ServiceExport ๋ฆฌ์์ค์ ์ด๋ฆ ๋ฐ ๋ค์์คํ์ด์ค๊ฐ ๋์ผํ ์๋น์ค๋ก ๋งคํ๋๋ฉฐ ์ด๋ฅผ ๋
ธ์ถํฉ๋๋ค.
apiVersion: v1
kind: Service
metadata:
name: store
namespace: store
spec:
selector:
app: store
ports:
- port: 8080
targetPort: 8080
---
kind: ServiceExport
apiVersion: net.gke.io/v1
metadata:
name: store
namespace: store
๋ค์ ๋ค์ด์ด๊ทธ๋จ์ ServiceExport๊ฐ ๋ฐฐํฌ๋ ํ์ ๋ฐ์ํ๋ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์ฌ์ค๋๋ค. ServiceExport ๋ฐ ์๋น์ค ์์ด ์กด์ฌํ ๊ฒฝ์ฐ ๋ฉํฐ ํด๋ฌ์คํฐ ์๋น์ค ์ปจํธ๋กค๋ฌ๊ฐ ํด๋น ServiceImport๋ฅผ Fleet์ ์๋ ๋ชจ๋ GKE ํด๋ฌ์คํฐ์ ๋ฐฐํฌํฉ๋๋ค. ServiceImport๋ ๋ชจ๋ ํด๋ฌ์คํฐ์ ์๋ store
์๋น์ค์ ๋ก์ปฌ ํํ์
๋๋ค. ์ด๋ฅผ ์ฌ์ฉํ๋ฉด gke-east-1
์ client
ํฌ๋๊ฐ ClusterIP ๋๋ ํค๋๋ฆฌ์ค ์๋น์ค๋ฅผ ์ฌ์ฉํ์ฌ gke-west-1
์ store
ํฌ๋์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. ์ด๋ฌํ ๋ฐฉ์์ผ๋ก ์ฌ์ฉํ๋ฉด ๋ฉํฐ ํด๋ฌ์คํฐ ์๋น์ค๊ฐ ๋ด๋ถ LoadBalancer ์๋น์ค ์์ด๋ ํด๋ฌ์คํฐ ๊ฐ์ east-west ๋ถํ ๋ถ์ฐ์ ์ ๊ณตํฉ๋๋ค.
ํด๋ฌ์คํฐ๊ฐ ๋ถํ ๋ถ์ฐ์ ์ํด ๋ฉํฐ ํด๋ฌ์คํฐ ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ๋ฉํฐ ํด๋ฌ์คํฐ ์๋น์ค ๊ตฌ์ฑ์ ์ฐธ์กฐํ์ธ์.
๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ ๋ํ ServiceImports๋ฅผ ์ฌ์ฉํ์ง๋ง ํด๋ฌ์คํฐ๊ฐ ๋ถํ ๋ถ์ฐ์ ์ฌ์ฉํ์ง ์์ต๋๋ค. ๋์ ๊ฒ์ดํธ์จ์ด๋ ๋ค๋ฅธ ํด๋ฌ์คํฐ์ ์๋ ์๋น์ค ๋๋ ์ฌ๋ฌ ํด๋ฌ์คํฐ ๊ฐ์ ๋ถ์ฐ๋ ์๋น์ค์ ๋ํ ๋ ผ๋ฆฌ์ ์๋ณ์๋ก ServiceImports๋ฅผ ์ฌ์ฉํฉ๋๋ค. ๋ค์ HTTPRoute๋ ์๋น์ค ๋ฆฌ์์ค ๋์ ServiceImport๋ฅผ ์ฐธ์กฐํฉ๋๋ค. ServiceImport๋ฅผ ์ฐธ์กฐํจ์ผ๋ก์จ ํ๋ ์ด์์ ํด๋ฌ์คํฐ์์ ์คํ๋๋ ๋ฐฑ์๋ ํฌ๋ ๊ทธ๋ฃน์ผ๋ก ํธ๋ํฝ์ ์ ๋ฌํฉ๋๋ค.
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1beta1
metadata:
name: store-route
namespace: store
labels:
gateway: multi-cluster-gateway
spec:
parentRefs:
- kind: Gateway
namespace: store
name: external-http
hostnames:
- "store.example.com"
rules:
- backendRefs:
- group: net.gke.io
kind: ServiceImport
name: store
port: 8080
๋ค์ ๋ค์ด์ด๊ทธ๋จ์ HTTPRoute๊ฐ store.example.com
ํธ๋ํฝ์ gke-west-1
๋ฐ gke-east-1
์ store
ํฌ๋๋ก ๋ผ์ฐํ
ํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค. ๋ถํ ๋ถ์ฐ๊ธฐ๋ ์ด๋ฅผ ๋ฐฑ์๋ ์ค ํ๋์ ํ๋ก ์ทจ๊ธํฉ๋๋ค. ํด๋ฌ์คํฐ ์ค ํ๋์ ํฌ๋๊ฐ ๋น์ ์ ๋๋ ์ฐ๊ฒฐํ ์ ์๋ ์ํ๊ฐ ๋๊ฑฐ๋ ํธ๋ํฝ ์ฉ๋์ด ์์ผ๋ฉด ๋ค๋ฅธ ํด๋ฌ์คํฐ์ ๋จ์ ํฌ๋๋ก ํธ๋ํฝ ๋ก๋๊ฐ ๋ถ์ฐ๋ฉ๋๋ค. store
์๋น์ค ๋ฐ ServiceExport๋ก ์ ํด๋ฌ์คํฐ๋ฅผ ์ถ๊ฐํ๊ฑฐ๋ ์ญ์ ํ ์ ์์ต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ๋ช
์์ ์ธ ๋ผ์ฐํ
๊ตฌ์ฑ ๋ณ๊ฒฝ ์์ด ๋ฐฑ์๋ ํฌ๋๋ฅผ ํฌ๋ช
ํ๊ฒ ์ถ๊ฐํ๊ฑฐ๋ ์ญ์ ํ ์ ์์ต๋๋ค.
์๋น์ค ๋ด๋ณด๋ด๊ธฐ
์ด์ ์ ํ๋ฆฌ์ผ์ด์ ์ด ๋ ํด๋ฌ์คํฐ ๊ฐ์ ์คํ๋ฉ๋๋ค. ์ด์ ์๋น์ค ๋ฐ ServiceExports๋ฅผ ๊ฐ ํด๋ฌ์คํฐ์ ๋ฐฐํฌํ์ฌ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ ธ์ถํ๊ณ ๋ด๋ณด๋ ๋๋ค.
gke-west-1
ํด๋ฌ์คํฐ์ ๋ค์ ๋งค๋ํ์คํธ๋ฅผ ์ ์ฉํ์ฌstore
๋ฐstore-west-1
Service์ ServiceExport๋ฅผ ๋ง๋ญ๋๋ค.cat << EOF | kubectl apply --context gke-west-1 -f - apiVersion: v1 kind: Service metadata: name: store namespace: store spec: selector: app: store ports: - port: 8080 targetPort: 8080 --- kind: ServiceExport apiVersion: net.gke.io/v1 metadata: name: store namespace: store --- apiVersion: v1 kind: Service metadata: name: store-west-1 namespace: store spec: selector: app: store ports: - port: 8080 targetPort: 8080 --- kind: ServiceExport apiVersion: net.gke.io/v1 metadata: name: store-west-1 namespace: store EOF
gke-east-1
ํด๋ฌ์คํฐ์ ๋ค์ ๋งค๋ํ์คํธ๋ฅผ ์ ์ฉํ์ฌstore
๋ฐstore-east-1
Service์ ServiceExport๋ฅผ ๋ง๋ญ๋๋ค.cat << EOF | kubectl apply --context gke-east-1 -f - apiVersion: v1 kind: Service metadata: name: store namespace: store spec: selector: app: store ports: - port: 8080 targetPort: 8080 --- kind: ServiceExport apiVersion: net.gke.io/v1 metadata: name: store namespace: store --- apiVersion: v1 kind: Service metadata: name: store-east-1 namespace: store spec: selector: app: store ports: - port: 8080 targetPort: 8080 --- kind: ServiceExport apiVersion: net.gke.io/v1 metadata: name: store-east-1 namespace: store EOF
ํด๋ฌ์คํฐ์ ์ฌ๋ฐ๋ฅธ ServiceExport๊ฐ ์์ฑ๋์๋์ง ํ์ธํฉ๋๋ค.
kubectl get serviceexports --context CLUSTER_NAME --namespace store
CLUSTER_NAME์
gke-west-1
๋ฐgke-east-1
๋ก ๋ฐ๊ฟ๋๋ค. ์ถ๋ ฅ์ ๋ค์๊ณผ ๋น์ทํ๊ฒ ํ์๋ฉ๋๋ค.# gke-west-1 NAME AGE store 2m40s store-west-1 2m40s # gke-east-1 NAME AGE store 2m25s store-east-1 2m25s
์ด๊ฒ์
store
์๋น์ค์ ๋ ํด๋ฌ์คํฐ ๊ฐ์store
ํฌ๋๊ฐ ํฌํจ๋ ๊ฒ์ ๋ณด์ฌ์ฃผ๋ฉฐstore-west-1
๋ฐstore-east-1
์๋น์ค๋ ํด๋น ํด๋ฌ์คํฐ์store
ํฌ๋๋ง ํฌํจํฉ๋๋ค. ์ด๋ฌํ ๊ฒน์ณ์ง ์๋น์ค๋ ์ฌ๋ฌ ํด๋ฌ์คํฐ ๊ฐ์ ํฌ๋ ๋๋ ๋จ์ผ ํด๋ฌ์คํฐ์ ํฌ๋ ํ์ ์งํฉ์ ๋์์ผ๋ก ์ง์ ํ๊ธฐ ์ํด ์ฌ์ฉ๋ฉ๋๋ค.๋ช ๋ถ ํ ํจ๊ป ์ ๊ณต๋
ServiceImports
๊ฐ Fleet์ ๋ชจ๋ ํด๋ฌ์คํฐ ๊ฐ์ ๋ฉํฐ ํด๋ฌ์คํฐ ์๋น์ค ์ปจํธ๋กค๋ฌ๋ฅผ ํตํด ์๋์ผ๋ก ์์ฑ๋์๋์ง ํ์ธํฉ๋๋ค.kubectl get serviceimports --context CLUSTER_NAME --namespace store
CLUSTER_NAME์
gke-west-1
๋ฐgke-east-1
๋ก ๋ฐ๊ฟ๋๋ค. ์ถ๋ ฅ์ ๋ค์๊ณผ ๋น์ทํ๊ฒ ํ์๋ฉ๋๋ค.# gke-west-1 NAME TYPE IP AGE store ClusterSetIP ["10.112.31.15"] 6m54s store-east-1 ClusterSetIP ["10.112.26.235"] 5m49s store-west-1 ClusterSetIP ["10.112.16.112"] 6m54s # gke-east-1 NAME TYPE IP AGE store ClusterSetIP ["10.72.28.226"] 5d10h store-east-1 ClusterSetIP ["10.72.19.177"] 5d10h store-west-1 ClusterSetIP ["10.72.28.68"] 4h32m
์ด๊ฒ์ Fleet์ ๋ ํด๋ฌ์คํฐ ๋ชจ๋์์ 3๊ฐ์ ์๋น์ค ๋ชจ๋์ ์ก์ธ์คํ ์ ์์์ ๋ณด์ฌ์ค๋๋ค. ํ์ง๋ง Fleet๋น ํ์ฑ ๊ตฌ์ฑ ํด๋ฌ์คํฐ๊ฐ ํ๋๋ง ์์ผ๋ฏ๋ก
gke-west-1
์์ ServiceImports๋ฅผ ์ฐธ์กฐํ๋ Gateways and HTTPRoutes๋ง ๋ฐฐํฌํ ์ ์์ต๋๋ค. ๊ตฌ์ฑ ํด๋ฌ์คํฐ์ HTTPRoute๊ฐ ์ด๋ฌํ ServiceImports๋ฅผ ๋ฐฑ์๋๋ก ์ฐธ์กฐํ ๋ ๊ฒ์ดํธ์จ์ด๋ ๋ด๋ณด๋ธ ํด๋ฌ์คํฐ๊ฐ ๋ฌด์์ด๋ ๊ฐ์ ์ด๋ฌํ ์๋น์ค๋ก ํธ๋ํฝ์ ์ ๋ฌํ ์ ์์ต๋๋ค.
๊ฒ์ดํธ์จ์ด ๋ฐ HTTPRoute ๋ฐฐํฌ
์ ํ๋ฆฌ์ผ์ด์
์ด ๋ฐฐํฌ๋ ํ gke-l7-global-external-managed-mc
GatewayClass๋ฅผ ์ฌ์ฉํ์ฌ ๊ฒ์ดํธ์จ์ด๋ฅผ ๊ตฌ์ฑํ ์ ์์ต๋๋ค. ์ด ๊ฒ์ดํธ์จ์ด๋ ๋์ ํด๋ฌ์คํฐ ๊ฐ์ ํธ๋ํฝ์ ๋ถ์ฐํ๋๋ก ๊ตฌ์ฑ๋ ์ธ๋ถ ์ ํ๋ฆฌ์ผ์ด์
๋ถํ ๋ถ์ฐ๊ธฐ๋ฅผ ๋ง๋ญ๋๋ค.
๋ค์
Gateway
๋งค๋ํ์คํธ๋ฅผ ๊ตฌ์ฑ ํด๋ฌ์คํฐ(์ด ์์์์๋gke-west-1
)์ ์ ์ฉํฉ๋๋ค.cat << EOF | kubectl apply --context gke-west-1 -f - kind: Gateway apiVersion: gateway.networking.k8s.io/v1beta1 metadata: name: external-http namespace: store spec: gatewayClassName: gke-l7-global-external-managed-mc listeners: - name: http protocol: HTTP port: 80 allowedRoutes: kinds: - kind: HTTPRoute EOF
์ด ๊ฒ์ดํธ์จ์ด ๊ตฌ์ฑ์
gkemcg1-NAMESPACE-GATEWAY_NAME-HASH
์ด๋ฆ ์ง์ ๊ท์น์ ์ฌ์ฉํ์ฌ ์ธ๋ถ ์ ํ๋ฆฌ์ผ์ด์ ๋ถํ ๋ถ์ฐ๊ธฐ ๋ฆฌ์์ค๋ฅผ ๋ฐฐํฌํฉ๋๋ค.์ด ๊ตฌ์ฑ์ผ๋ก ์์ฑ๋ ๊ธฐ๋ณธ ๋ฆฌ์์ค๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
- ๋ถํ ๋ถ์ฐ๊ธฐ 1๊ฐ:
gkemcg1-store-external-http-HASH
- ๊ณต๊ฐ IP ์ฃผ์ 1๊ฐ:
gkemcg1-store-external-http-HASH
- ์ ๋ฌ ๊ท์น 1๊ฐ:
gkemcg1-store-external-http-HASH
- ๋ฐฑ์๋ ์๋น์ค 2๊ฐ:
- ๊ธฐ๋ณธ 404 ๋ฐฑ์๋ ์๋น์ค:
gkemcg1-store-gw-serve404-HASH
- ๊ธฐ๋ณธ 500 ๋ฐฑ์๋ ์๋น์ค:
gkemcg1-store-gw-serve500-HASH
- ๊ธฐ๋ณธ 404 ๋ฐฑ์๋ ์๋น์ค:
- ์ํ ์ ๊ฒ 1๊ฐ:
- ๊ธฐ๋ณธ 404 ์ํ ์ ๊ฒ:
gkemcg1-store-gw-serve404-HASH
- ๊ธฐ๋ณธ 404 ์ํ ์ ๊ฒ:
- ๋ผ์ฐํ ๊ท์น 0๊ฐ(URLmap ๋น์ด ์์)
์ด ๋จ๊ณ์์ GATEWAY_IP:80์ ์์ฒญํ๋ฉด
fault filter abort
๋ฉ์์ง๊ฐ ๊ธฐ๋ณธ ํ์ด์ง์ ํ์๋ฉ๋๋ค.- ๋ถํ ๋ถ์ฐ๊ธฐ 1๊ฐ:
๋ค์
HTTPRoute
๋งค๋ํ์คํธ๋ฅผ ๊ตฌ์ฑ ํด๋ฌ์คํฐ(์ด ์์์์๋gke-west-1
)์ ์ ์ฉํฉ๋๋ค.cat << EOF | kubectl apply --context gke-west-1 -f - kind: HTTPRoute apiVersion: gateway.networking.k8s.io/v1beta1 metadata: name: public-store-route namespace: store labels: gateway: external-http spec: hostnames: - "store.example.com" parentRefs: - name: external-http rules: - matches: - path: type: PathPrefix value: /west backendRefs: - group: net.gke.io kind: ServiceImport name: store-west-1 port: 8080 - matches: - path: type: PathPrefix value: /east backendRefs: - group: net.gke.io kind: ServiceImport name: store-east-1 port: 8080 - backendRefs: - group: net.gke.io kind: ServiceImport name: store port: 8080 EOF
์ด ๋จ๊ณ์์ GATEWAY_IP:80์ ์์ฒญํ๋ฉด
fault filter abort
๋ฉ์์ง๊ฐ ๊ธฐ๋ณธ ํ์ด์ง์ ํ์๋ฉ๋๋ค.๋ฐฐํฌ๋ ๋ค์์๋ ์ด HTTPRoute๊ฐ ๋ค์ ๋ผ์ฐํ ๋์์ ๊ตฌ์ฑํฉ๋๋ค.
store-west-1
ServiceExport์์ ์ ํํ ํฌ๋๊ฐgke-west-1
ํด๋ฌ์คํฐ์๋ง ์กด์ฌํ๋ฏ๋ก/west
์ ๋ํ ์์ฒญ์ดgke-west-1
ํด๋ฌ์คํฐ์store
ํฌ๋๋ก ๋ผ์ฐํ ๋ฉ๋๋ค.store-east-1
ServiceExport์์ ์ ํํ ํฌ๋๊ฐgke-east-1
ํด๋ฌ์คํฐ์๋ง ์กด์ฌํ๋ฏ๋ก/east
์ ๋ํ ์์ฒญ์ดgke-east-1
ํด๋ฌ์คํฐ์store
ํฌ๋๋ก ๋ผ์ฐํ ๋ฉ๋๋ค.- ๋ค๋ฅธ ๊ฒฝ๋ก์ ๋ํ ์์ฒญ์ ์์ฒญ ํด๋ผ์ด์ธํธ์ ๋ํ ํด๋น ์ํ, ์ฉ๋, ๊ทผ์ ์ฑ์ ๋ฐ๋ผ ๊ฐ ํด๋ฌ์คํฐ์
store
ํฌ๋๋ก ๋ผ์ฐํ ๋ฉ๋๋ค. - GATEWAY_IP:80์ ์์ฒญํ๋ฉด ๊ธฐ๋ณธ ํ์ด์ง์
fault filter abort
๋ฉ์์ง๊ฐ ํ์๋ฉ๋๋ค.
์ง์ ๋ ํด๋ฌ์คํฐ์ ๋ชจ๋ ํฌ๋๊ฐ ์ ์์ด ์๋๋ฉด(๋๋ ์กด์ฌํ์ง ์์ผ๋ฉด) ์ค์
store
ํฌ๋๋ฅผ ๊ฐ๊ณ ์๋ ํด๋ฌ์คํฐ๋ก๋งstore
์๋น์ค๊ฐ ์ ์ก๋ฉ๋๋ค. ์ง์ ๋ ํด๋ฌ์คํฐ์ ServiceExport ๋ฐ ์๋น์ค๊ฐ ์กด์ฌํ๋ค๊ณ ํด์ ํธ๋ํฝ์ด ํด๋น ํด๋ฌ์คํฐ๋ก ๋ฐ๋์ ์ ์ก๋์ง๋ ์์ต๋๋ค. ํฌ๋๊ฐ ์กด์ฌํ๊ณ ๋ถํ ๋ถ์ฐ๊ธฐ ์ํ ํ์ธ์ ์ ์ ํ๊ฒ ๋ฐ์ํด์ผ ํฉ๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด ๋ถํ ๋ถ์ฐ๊ธฐ๊ฐ ๋ค๋ฅธ ํด๋ฌ์คํฐ์ ์๋ ์ ์store
ํฌ๋๋ก ํธ๋ํฝ์ ์ ์กํฉ๋๋ค.๋ค์ ๊ตฌ์ฑ์ผ๋ก ์ ๋ฆฌ์์ค๊ฐ ์์ฑ๋ฉ๋๋ค.
- ๋ฐฑ์๋ ์๋น์ค 3๊ฐ:
store
๋ฐฑ์๋ ์๋น์ค:gkemcg1-store-store-8080-HASH
store-east-1
๋ฐฑ์๋ ์๋น์ค:gkemcg1-store-store-east-1-8080-HASH
store-west-1
๋ฐฑ์๋ ์๋น์ค:gkemcg1-store-store-west-1-8080-HASH
- ์ํ ์ ๊ฒ 3๊ฐ:
store
์ํ ์ ๊ฒ:gkemcg1-store-store-8080-HASH
store-east-1
์ํ ์ ๊ฒ:gkemcg1-store-store-east-1-8080-HASH
store-west-1
์ํ ์ ๊ฒ:gkemcg1-store-store-west-1-8080-HASH
- URLmap์ ๋ผ์ฐํ
๊ท์น 1๊ฐ:
store.example.com
๋ผ์ฐํ ๊ท์น:- ํธ์คํธ 1๊ฐ:
store.example.com
- ์ ๋ฐฑ์๋ ์๋น์ค๋ก ๋ผ์ฐํ
ํ๋ ์ฌ๋ฌ
matchRules
๋ค์ ๋ค์ด์ด๊ทธ๋จ์ ๋ ํด๋ฌ์คํฐ ๊ฐ์ ๋ฐฐํฌํ ๋ฆฌ์์ค๋ฅผ ๋ณด์ฌ์ค๋๋ค.
gke-west-1
์ ๊ฒ์ดํธ์จ์ด ๊ตฌ์ฑ ํด๋ฌ์คํฐ์ด๊ธฐ ๋๋ฌธ์ ๊ฒ์ดํธ์จ์ด, HTTPRoutes, ServiceImports๊ฐ ๊ฒ์ดํธ์จ์ด ์ปจํธ๋กค๋ฌ์์ ๊ฐ์๋๋ ํด๋ฌ์คํฐ์
๋๋ค. ๊ฐ ํด๋ฌ์คํฐ์๋ store
ServiceImport ๋ฐ ํด๋น ํด๋ฌ์คํฐ์ ๊ด๋ จ๋ ๋ ๋ค๋ฅธ ServiceImport๊ฐ ํฌํจ๋์ด ์์ต๋๋ค. ๋ ๋ค ๋์ผํ ํฌ๋๋ฅผ ๊ฐ๋ฆฌํต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด HTTPRoute๊ฐ ํน์ ํด๋ฌ์คํฐ์ store
ํฌ๋ ๋๋ ๋ชจ๋ ํด๋ฌ์คํฐ ๊ฐ์ store
ํฌ๋์ ๊ฐ์ ํธ๋ํฝ์ ์ ํํ ์ ์ก ์์น๋ฅผ ์ง์ ํ ์ ์์ต๋๋ค.
์ด๋ ํธ๋ํฝ ํ๋ฆ์ ๋ณด์ฌ์ฃผ๋ ๊ฒ์ด ์๋ ๋ ผ๋ฆฌ์ ์ธ ๋ฆฌ์์ค ๋ชจ๋ธ์ ๋๋ค. ํธ๋ํฝ ๊ฒฝ๋ก๋ ๋ถํ ๋ถ์ฐ๊ธฐ์์ ๋ฐฑ์๋ ํฌ๋๋ก ์ง์ ์ด๋ํ๋ฉฐ ๊ตฌ์ฑ ํด๋ฌ์คํฐ๊ฐ ๋ฌด์์ด๋ ์ง์ ์ ์ธ ๊ด๋ จ์ ์์ต๋๋ค.
๋ฐฐํฌ ๊ฒ์ฆ
์ด์ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด์ ์์ฒญ์ ์คํํ๊ณ ๋ GKE ํด๋ฌ์คํฐ ๊ฐ์ ํธ๋ํฝ์ ๋ถ์ฐํ ์ ์์ต๋๋ค.
๊ฒ์ดํธ์จ์ด ์ํ์ ์ด๋ฒคํธ๋ฅผ ์กฐ์ฌํ์ฌ ๊ฒ์ดํธ์จ์ด ๋ฐ HTTPRoute๊ฐ ์ฑ๊ณต์ ์ผ๋ก ๋ฐฐํฌ๋์๋์ง ๊ฒ์ฆํฉ๋๋ค.
kubectl describe gateways.gateway.networking.k8s.io external-http --context gke-west-1 --namespace store
์ถ๋ ฅ์ ๋ค์๊ณผ ๋น์ทํ๊ฒ ํ์๋ฉ๋๋ค.
Name: external-http Namespace: store Labels: <none> Annotations: networking.gke.io/addresses: /projects/PROJECT_NUMBER/global/addresses/gkemcg1-store-external-http-laup24msshu4 networking.gke.io/backend-services: /projects/PROJECT_NUMBER/global/backendServices/gkemcg1-store-gw-serve404-80-n65xmts4xvw2, /projects/PROJECT_NUMBER/global/backendServices/gke... networking.gke.io/firewalls: /projects/PROJECT_NUMBER/global/firewalls/gkemcg1-l7-default-global networking.gke.io/forwarding-rules: /projects/PROJECT_NUMBER/global/forwardingRules/gkemcg1-store-external-http-a5et3e3itxsv networking.gke.io/health-checks: /projects/PROJECT_NUMBER/global/healthChecks/gkemcg1-store-gw-serve404-80-n65xmts4xvw2, /projects/PROJECT_NUMBER/global/healthChecks/gkemcg1-s... networking.gke.io/last-reconcile-time: 2023-10-12T17:54:24Z networking.gke.io/ssl-certificates: networking.gke.io/target-http-proxies: /projects/PROJECT_NUMBER/global/targetHttpProxies/gkemcg1-store-external-http-94oqhkftu5yz networking.gke.io/target-https-proxies: networking.gke.io/url-maps: /projects/PROJECT_NUMBER/global/urlMaps/gkemcg1-store-external-http-94oqhkftu5yz API Version: gateway.networking.k8s.io/v1beta1 Kind: Gateway Metadata: Creation Timestamp: 2023-10-12T06:59:32Z Finalizers: gateway.finalizer.networking.gke.io Generation: 1 Resource Version: 467057 UID: 1dcb188e-2917-404f-9945-5f3c2e907b4c Spec: Gateway Class Name: gke-l7-global-external-managed-mc Listeners: Allowed Routes: Kinds: Group: gateway.networking.k8s.io Kind: HTTPRoute Namespaces: From: Same Name: http Port: 80 Protocol: HTTP Status: Addresses: Type: IPAddress Value: 34.36.127.249 Conditions: Last Transition Time: 2023-10-12T07:00:41Z Message: The OSS Gateway API has deprecated this condition, do not depend on it. Observed Generation: 1 Reason: Scheduled Status: True Type: Scheduled Last Transition Time: 2023-10-12T07:00:41Z Message: Observed Generation: 1 Reason: Accepted Status: True Type: Accepted Last Transition Time: 2023-10-12T07:00:41Z Message: Observed Generation: 1 Reason: Programmed Status: True Type: Programmed Last Transition Time: 2023-10-12T07:00:41Z Message: The OSS Gateway API has altered the "Ready" condition semantics and reservedit for future use. GKE Gateway will stop emitting it in a future update, use "Programmed" instead. Observed Generation: 1 Reason: Ready Status: True Type: Ready Listeners: Attached Routes: 1 Conditions: Last Transition Time: 2023-10-12T07:00:41Z Message: Observed Generation: 1 Reason: Programmed Status: True Type: Programmed Last Transition Time: 2023-10-12T07:00:41Z Message: The OSS Gateway API has altered the "Ready" condition semantics and reservedit for future use. GKE Gateway will stop emitting it in a future update, use "Programmed" instead. Observed Generation: 1 Reason: Ready Status: True Type: Ready Name: http Supported Kinds: Group: gateway.networking.k8s.io Kind: HTTPRoute Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal UPDATE 35m (x4 over 10h) mc-gateway-controller store/external-http Normal SYNC 4m22s (x216 over 10h) mc-gateway-controller SYNC on store/external-http was a success
๊ฒ์ดํธ์จ์ด๊ฐ ์ฑ๊ณต์ ์ผ๋ก ๋ฐฐํฌ๋์์ผ๋ฉด
external-http
๊ฒ์ดํธ์จ์ด์์ ์ธ๋ถ IP ์ฃผ์๋ฅผ ๊ฒ์ํฉ๋๋ค.kubectl get gateways.gateway.networking.k8s.io external-http -o=jsonpath="{.status.addresses[0].value}" --context gke-west-1 --namespace store
๋ค์ ๋จ๊ณ์์
VIP
๋ฅผ ์ถ๋ ฅ์ผ๋ก ์์ ๋๋ IP ์ฃผ์๋ก ๋ฐ๊ฟ๋๋ค.๋๋ฉ์ธ์ ๋ฃจํธ ๊ฒฝ๋ก๋ก ํธ๋ํฝ์ ์ ์กํฉ๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด
gke-west-1
๋ฐgke-east-1
ํด๋ฌ์คํฐ ๊ฐ์ ์๋store
ServiceImport๋ก ํธ๋ํฝ์ ๋ถํ ๋ถ์ฐํฉ๋๋ค. ๋ถํ ๋ถ์ฐ๊ธฐ๊ฐ ๊ฐ์ฅ ๊ฐ๊น์ด ๋ฆฌ์ ์ผ๋ก ํธ๋ํฝ์ ์ ์กํ๋ฉฐ, ๋ค๋ฅธ ๋ฆฌ์ ์ ์๋ต์ ํ์๋์ง ์์ ์ ์์ต๋๋ค.curl -H "host: store.example.com" http://VIP
์ด ์ถ๋ ฅ์ ์์ฒญ์ด
gke-east-1
ํด๋ฌ์คํฐ์ ํฌ๋์์ ์ ๊ณต๋์๋์ง ํ์ธํฉ๋๋ค.{ "cluster_name": "gke-east-1", "zone": "us-east1-b", "host_header": "store.example.com", "node_name": "gke-gke-east-1-default-pool-7aa30992-t2lp.c.agmsb-k8s.internal", "pod_name": "store-5f5b954888-dg22z", "pod_name_emoji": "โญ", "project_id": "agmsb-k8s", "timestamp": "2021-06-01T17:32:51" }
๊ทธ๋ฐ ํ
/west
๊ฒฝ๋ก๋ก ํธ๋ํฝ์ ์ ์กํฉ๋๋ค. ์ด๊ฒ์gke-west-1
ํด๋ฌ์คํฐ์์ ์คํ๋๋ ํฌ๋๋ง ์๋store-west-1
ServiceImport๋ก ํธ๋ํฝ์ ๋ผ์ฐํ ํฉ๋๋ค.store-west-1
๊ณผ ๊ฐ์ ํด๋ฌ์คํฐ ํน์ ServiceImport๋ ๋ถํ ๋ถ์ฐ๊ธฐ๊ฐ ๊ฒฐ์ ์ ๋ด๋ฆฌ๋๋ก ํ์ฉํ๋ ๋์ ์ ํ๋ฆฌ์ผ์ด์ ์์ ์๊ฐ ํน์ ํด๋ฌ์คํฐ๋ก ํธ๋ํฝ์ ๋ช ์์ ์ผ๋ก ์ ์กํ ์ ์๊ฒ ํด์ค๋๋ค.curl -H "host: store.example.com" http://VIP/west
์ด ์ถ๋ ฅ์ ์์ฒญ์ด
gke-west-1
ํด๋ฌ์คํฐ์ ํฌ๋์์ ์ ๊ณต๋์๋์ง ํ์ธํฉ๋๋ค.{ "cluster_name": "gke-west-1", "zone": "us-west1-a", "host_header": "store.example.com", "node_name": "gke-gke-west-1-default-pool-65059399-2f41.c.agmsb-k8s.internal", "pod_name": "store-5f5b954888-d25m5", "pod_name_emoji": "๐พ", "project_id": "agmsb-k8s", "timestamp": "2021-06-01T17:39:15", }
๋ง์ง๋ง์ผ๋ก
/east
๊ฒฝ๋ก๋ก ํธ๋ํฝ์ ์ ์กํฉ๋๋ค.curl -H "host: store.example.com" http://VIP/east
์ด ์ถ๋ ฅ์ ์์ฒญ์ด
gke-east-1
ํด๋ฌ์คํฐ์ ํฌ๋์์ ์ ๊ณต๋์๋์ง ํ์ธํฉ๋๋ค.{ "cluster_name": "gke-east-1", "zone": "us-east1-b", "host_header": "store.example.com", "node_name": "gke-gke-east-1-default-pool-7aa30992-7j7z.c.agmsb-k8s.internal", "pod_name": "store-5f5b954888-hz6mw", "pod_name_emoji": "๐ง๐พ", "project_id": "agmsb-k8s", "timestamp": "2021-06-01T17:40:48" }
๊ฒ์ดํธ์จ์ด๋ฅผ ์ฌ์ฉํ ๋ธ๋ฃจ-๊ทธ๋ฆฐ ๋ฉํฐ ํด๋ฌ์คํฐ ๋ผ์ฐํ
gke-l7-global-external-managed-*
, gke-l7-regional-external-managed-*
, gke-l7-rilb-*
GatewayClass์๋ ํธ๋ํฝ ๋ถํ , ํค๋ ์ผ์น, ํค๋ ์กฐ์, ํธ๋ํฝ ๋ฏธ๋ฌ๋ง ๋ฑ์ ํฌํจํ์ฌ ๋ง์ ๊ณ ๊ธ ํธ๋ํฝ ๋ผ์ฐํ
๊ธฐ๋ฅ์ด ํฌํจ๋์ด ์์ต๋๋ค. ์ด ์์์์๋ ๊ฐ์ค์น์ ๊ธฐ๋ฐํ ํธ๋ํฝ ๋ถํ ์ ์ฌ์ฉํ์ฌ GKE ํด๋ฌ์คํฐ 2๊ฐ ๊ฐ์ ํธ๋ํฝ ๋น์จ์ ๋ช
์์ ์ผ๋ก ์ ์ดํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค.
์ด ์์์์๋ ์๋น์ค ์์ ์๊ฐ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ GKE ํด๋ฌ์คํฐ๋ก ์ด๋ํ๊ฑฐ๋ ํ์ฅํ ๋ ์ํํ๋ ๋ช ๊ฐ์ง ์ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค. ๋ธ๋ฃจ-๊ทธ๋ฆฐ ๋ฐฐํฌ์ ๋ชฉ์ ์ ์ ํด๋ฌ์คํฐ๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ์๋ํ๋์ง ํ์ธํ๋ ์ฌ๋ฌ ๊ฒ์ฆ ๋จ๊ณ๋ฅผ ํตํด ์ํ์ ์ค์ด๊ธฐ ์ํ ๊ฒ์ ๋๋ค. ์ด ์์๋ ๋ฐฐํฌ์ 4๋จ๊ณ๋ฅผ ํต๊ณผํฉ๋๋ค.
- 100%-ํค๋ ๊ธฐ๋ฐ ์นด๋๋ฆฌ์: HTTP ํค๋ ๋ผ์ฐํ ์ ์ฌ์ฉํ์ฌ ํ ์คํธ ๋๋ ํฉ์ฑ ํธ๋ํฝ๋ง ์ ํด๋ฌ์คํฐ๋ก ์ ์กํฉ๋๋ค.
- 100%-ํธ๋ํฝ ๋ฏธ๋ฌ๋ง: ์นด๋๋ฆฌ์ ํด๋ฌ์คํฐ๋ก ์ฌ์ฉ์ ํธ๋ํฝ์ ๋ฏธ๋ฌ๋งํฉ๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ์ฌ์ฉ์ ํธ๋ํฝ์ 100% ์ด ํด๋ฌ์คํฐ๋ก ๋ณต์ฌํ์ฌ ์นด๋๋ฆฌ์ ํด๋ฌ์คํฐ์ ์ฉ๋์ ํ ์คํธํฉ๋๋ค.
- 90%-10%: 10%์ ๋ถํ ํธ๋ํฝ์ ์นด๋๋ฆฌ์๋ก ํ ์คํธํ์ฌ ์ ํด๋ฌ์คํฐ๋ฅผ ๋ผ์ด๋ธ ํธ๋ํฝ์ ๋๋ฆฌ๊ฒ ๋ ธ์ถ์ํต๋๋ค.
- 0%-100%: ์ค๋ฅ๊ฐ ๊ด์ธก๋ ๊ฒฝ์ฐ ๋ค์ ์ ํํ ์ ์๋ ์ต์ ๊ณผ ํจ๊ป ์ ํด๋ฌ์คํฐ๋ก ์์ ํ ์ปท์ค๋ฒํฉ๋๋ค.
์ด ์์๋ ์ด์ ์์์ ๋น์ทํ์ง๋ง ๋์ ๋ด๋ถ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ฅผ ๋ฐฐํฌํฉ๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด VPC ๋ด์์ ๋น๊ณต๊ฐ๋ก ์ก์ธ์คํ ์ ์๋ ๋ด๋ถ ์ ํ๋ฆฌ์ผ์ด์ ๋ถํ ๋ถ์ฐ๊ธฐ๋ฅผ ๋ฐฐํฌํฉ๋๋ค. ์ด์ ๋จ๊ณ์์ ๋ฐฐํฌํ ๊ฒ๊ณผ ๋์ผํ ์ ํ๋ฆฌ์ผ์ด์ ๋ฐ ํด๋ฌ์คํฐ๋ฅผ ์ฌ์ฉํ์ง๋ง, ๋ค๋ฅธ ๊ฒ์ดํธ์จ์ด๋ฅผ ํตํด ์ด๋ฅผ ๋ฐฐํฌํฉ๋๋ค.
๊ธฐ๋ณธ ์๊ฑด
๋ค์ ์์๋ ์ธ๋ถ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด ๋ฐฐํฌ์ ๋จ๊ณ ์ค ์ผ๋ถ์ ๋ฐ๋ผ ๋น๋๋ฉ๋๋ค. ์ด ์์๋ฅผ ์งํํ๊ธฐ ์ ์ ๋ค์ ๋จ๊ณ๋ฅผ ์๋ฃํ๋์ง ํ์ธํ์ธ์.
๋ฐ๋ชจ ์ ํ๋ฆฌ์ผ์ด์ ๋ฐฐํฌ
์ด ์์์์๋ ์ด๋ฏธ ์ค์ ๋ ์ํ์
gke-west-1
๋ฐgke-west-2
ํด๋ฌ์คํฐ๊ฐ ์ฌ์ฉ๋ฉ๋๋ค. ์ด๋ฌํ ํด๋ฌ์คํฐ๋gke-l7-rilb-mc
GatewayClass๊ฐ ๋ฆฌ์ ๋ณ ํด๋์ค์ด๊ณ ๋์ผํ ๋ฆฌ์ ์ ํด๋ฌ์คํฐ ๋ฐฑ์๋๋ง ์ง์ํ๊ธฐ ๋๋ฌธ์ ๋์ผํ ๋ฆฌ์ ์ ์์ต๋๋ค.๊ฐ ํด๋ฌ์คํฐ์ ํ์ํ ์๋น์ค ๋ฐ ServiceExports๋ฅผ ๋ฐฐํฌํฉ๋๋ค. ์ด์ ์์์์ Service ๋ฐ ServiceExport๋ฅผ ๋ฐฐํฌํ ๊ฒฝ์ฐ ์ด๋ฏธ ์ผ๋ถ๊ฐ ๋ฐฐํฌ๋์ด ์์ต๋๋ค.
kubectl apply --context gke-west-1 -f https://raw.githubusercontent.com/GoogleCloudPlatform/gke-networking-recipes/main/gateway/gke-gateway-controller/multi-cluster-gateway/store-west-1-service.yaml kubectl apply --context gke-west-2 -f https://raw.githubusercontent.com/GoogleCloudPlatform/gke-networking-recipes/main/gateway/gke-gateway-controller/multi-cluster-gateway/store-west-2-service.yaml
๋น์ทํ ๋ฆฌ์์ค ์งํฉ์ ๊ฐ ํด๋ฌ์คํฐ์ ๋ฐฐํฌํฉ๋๋ค.
service/store created serviceexport.net.gke.io/store created service/store-west-2 created serviceexport.net.gke.io/store-west-2 created
ํ๋ก์ ์ ์ฉ ์๋ธ๋ท ๊ตฌ์ฑ
์์ง ์ํํ์ง ์์์ผ๋ฉด ๋ด๋ถ ๊ฒ์ดํธ์จ์ด๋ฅผ ๋ฐฐํฌํ๋ ค๋ ๊ฐ ๋ฆฌ์ ์์ ํ๋ก์ ์ ์ฉ ์๋ธ๋ท์ ๊ตฌ์ฑํฉ๋๋ค. ์ด ์๋ธ๋ท์ ๋ถํ ๋ถ์ฐ๊ธฐ ํ๋ก์์ ๋ด๋ถ IP ์ฃผ์๋ฅผ ์ ๊ณตํ๋ ๋ฐ ์ฌ์ฉ๋๋ฉฐ --purpose
๊ฐ REGIONAL_MANAGED_PROXY
๋ก๋ง ์ค์ ๋ ์ํ๋ก ๊ตฌ์ฑ๋์ด์ผ ํฉ๋๋ค.
๋ด๋ถ ์ ํ๋ฆฌ์ผ์ด์ ๋ถํ ๋ถ์ฐ๊ธฐ๋ฅผ ๊ด๋ฆฌํ๋ ๊ฒ์ดํธ์จ์ด๋ฅผ ๋ง๋ค๊ธฐ ์ ์ ํ๋ก์ ์ ์ฉ ์๋ธ๋ท์ ๋ง๋ค์ด์ผ ํฉ๋๋ค. ๋ด๋ถ ์ ํ๋ฆฌ์ผ์ด์ ๋ถํ ๋ถ์ฐ๊ธฐ๋ฅผ ์ฌ์ฉํ๋ Virtual Private Cloud(VPC) ๋คํธ์ํฌ์ ๊ฐ ๋ฆฌ์ ์๋ ํ๋ก์ ์ ์ฉ ์๋ธ๋ท์ด ์์ด์ผ ํฉ๋๋ค.
gcloud compute networks subnets create
๋ช
๋ น์ด๋ ํ๋ก์ ์ ์ฉ ์๋ธ๋ท์ ๋ง๋ญ๋๋ค.
gcloud compute networks subnets create SUBNET_NAME \
--purpose=REGIONAL_MANAGED_PROXY \
--role=ACTIVE \
--region=REGION \
--network=VPC_NETWORK_NAME \
--range=CIDR_RANGE
๋ค์์ ๋ฐ๊ฟ๋๋ค.
SUBNET_NAME
: ํ๋ก์ ์ ์ฉ ์๋ธ๋ท์ ์ด๋ฆ์ ๋๋ค.REGION
: ํ๋ก์ ์ ์ฉ ์๋ธ๋ท์ ๋ฆฌ์ ์ ๋๋ค.VPC_NETWORK_NAME
: ์๋ธ๋ท์ด ํฌํจ๋ VPC ๋คํธ์ํฌ์ ์ด๋ฆ์ ๋๋ค.CIDR_RANGE
: ์๋ธ๋ท์ ๊ธฐ๋ณธ IP ์ฃผ์ ๋ฒ์์ ๋๋ค. ๋ฆฌ์ ์ ํ๋ก์์์ 64๊ฐ ์ด์์ IP ์ฃผ์๋ฅผ ์ฌ์ฉํ ์ ์๋๋ก/26
์ด์์ ์๋ธ๋ท ๋ง์คํฌ๋ฅผ ์ฌ์ฉํด์ผ ํฉ๋๋ค. ๊ถ์ฅ ์๋ธ๋ท ๋ง์คํฌ๋/23
์ ๋๋ค.
๊ฒ์ดํธ์จ์ด ๋ฐฐํฌ
๋ค์ ๊ฒ์ดํธ์จ์ด๋ gke-l7-rilb-mc
GatewayClass์์ ์์ฑ๋ฉ๋๋ค. ์ด๊ฒ์ ๋์ผํ ๋ฆฌ์ ์ GKE ํด๋ฌ์คํฐ๋ง ๋์์ผ๋ก ์ง์ ํ ์ ์๋ ๋ฆฌ์ ๋ณ ๋ด๋ถ ๊ฒ์ดํธ์จ์ด์
๋๋ค.
๋ค์
Gateway
๋งค๋ํ์คํธ๋ฅผ ๊ตฌ์ฑ ํด๋ฌ์คํฐ(์ด ์์์์๋gke-west-1
)์ ์ ์ฉํฉ๋๋ค.cat << EOF | kubectl apply --context gke-west-1 -f - kind: Gateway apiVersion: gateway.networking.k8s.io/v1beta1 metadata: name: internal-http namespace: store spec: gatewayClassName: gke-l7-rilb-mc listeners: - name: http protocol: HTTP port: 80 allowedRoutes: kinds: - kind: HTTPRoute EOF
๊ฒ์ดํธ์จ์ด๊ฐ ์ฑ๊ณต์ ์ผ๋ก ๋ฐฐํฌ๋์๋์ง ํ์ธํฉ๋๋ค. ๋ค์ ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํ์ฌ ์ด ๊ฒ์ดํธ์จ์ด์์ ์ด๋ฒคํธ๋ฅผ ํํฐ๋งํ ์ ์์ต๋๋ค.
kubectl get events --field-selector involvedObject.kind=Gateway,involvedObject.name=internal-http --context=gke-west-1 --namespace store
์ถ๋ ฅ์ด ๋ค์๊ณผ ์ ์ฌํ๋ฉด ๊ฒ์ดํธ์จ์ด ๋ฐฐํฌ๊ฐ ์ฑ๊ณตํ ๊ฒ์ ๋๋ค.
LAST SEEN TYPE REASON OBJECT MESSAGE 5m18s Normal ADD gateway/internal-http store/internal-http 3m44s Normal UPDATE gateway/internal-http store/internal-http 3m9s Normal SYNC gateway/internal-http SYNC on store/internal-http was a success
ํค๋ ๊ธฐ๋ฐ ์นด๋๋ฆฌ์
ํค๋ ๊ธฐ๋ฐ ์นด๋๋ฆฌ์๋ฅผ ํตํด ์๋น์ค ์์ ์๋ ์ค์ ์ฌ์ฉ์๋ก๋ถํฐ ์ ๊ณต๋์ง ์๋ ํฉ์ฑ ํ ์คํธ ํธ๋ํฝ์ ์ฐพ์ ์ ์์ต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ์ฌ์ฉ์๋ฅผ ์ง์ ๋ ธ์ถ์ํค์ง ์๊ณ ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ ๊ธฐ๋ณธ ๋คํธ์ํน์ด ์๋ํ๋์ง ์ฝ๊ฒ ํ์ธํ ์ ์์ต๋๋ค.
๋ค์
HTTPRoute
๋งค๋ํ์คํธ๋ฅผ ๊ตฌ์ฑ ํด๋ฌ์คํฐ(์ด ์์์์๋gke-west-1
)์ ์ ์ฉํฉ๋๋ค.cat << EOF | kubectl apply --context gke-west-1 -f - kind: HTTPRoute apiVersion: gateway.networking.k8s.io/v1beta1 metadata: name: internal-store-route namespace: store labels: gateway: internal-http spec: parentRefs: - kind: Gateway namespace: store name: internal-http hostnames: - "store.example.internal" rules: # Matches for env=canary and sends it to store-west-2 ServiceImport - matches: - headers: - name: env value: canary backendRefs: - group: net.gke.io kind: ServiceImport name: store-west-2 port: 8080 # All other traffic goes to store-west-1 ServiceImport - backendRefs: - group: net.gke.io kind: ServiceImport name: store-west-1 port: 8080 EOF
๋ฐฐํฌ๋ ๋ค์์๋ ์ด HTTPRoute๊ฐ ๋ค์ ๋ผ์ฐํ ๋์์ ๊ตฌ์ฑํฉ๋๋ค.
env: canary
HTTP ํค๋๊ฐ ์๋store.example.internal
ํค๋์ ๋ํ ๋ด๋ถ ์์ฒญ์gke-west-1
ํด๋ฌ์คํฐ์store
ํฌ๋๋ก ๋ผ์ฐํ ๋ฉ๋๋ค.env: canary
HTTP ํค๋๊ฐ ์๋store.example.internal
์ ๋ํ ๋ด๋ถ ์์ฒญ์gke-west-2
ํด๋ฌ์คํฐ์store
ํฌ๋๋ก ๋ผ์ฐํ ๋ฉ๋๋ค.
๊ฒ์ดํธ์จ์ด IP ์ฃผ์๋ก ํธ๋ํฝ์ ์ ์กํ์ฌ HTTPRoute๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ์๋ํ๋์ง ํ์ธํฉ๋๋ค.
internal-http
์์ ๋ด๋ถ IP ์ฃผ์๋ฅผ ๊ฒ์ํฉ๋๋ค.kubectl get gateways.gateway.networking.k8s.io internal-http -o=jsonpath="{.status.addresses[0].value}" --context gke-west-1 --namespace store
๋ค์ ๋จ๊ณ์์ VIP๋ฅผ ์ถ๋ ฅ์ผ๋ก ์์ ๋๋ IP ์ฃผ์๋ก ๋ฐ๊ฟ๋๋ค.
env: canary
HTTP ํค๋๋ฅผ ์ฌ์ฉํ์ฌ ์์ฒญ์ ๊ฒ์ดํธ์จ์ด๋ก ์ ์กํฉ๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ํธ๋ํฝ์ดgke-west-2
๋ก ๋ผ์ฐํ ๋๋์ง ํ์ธํฉ๋๋ค. GKE ํด๋ฌ์คํฐ์ ๋์ผํ VPC์์ ๋น๊ณต๊ฐ ํด๋ผ์ด์ธํธ๋ฅผ ์ฌ์ฉํ์ฌ ์์ฒญ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๋ผ์ฐํ ๋๋์ง ํ์ธํฉ๋๋ค. ๋ค์ ๋ช ๋ น์ด๋ ๊ฒ์ดํธ์จ์ด IP ์ฃผ์์ ๋ํด ๋น๊ณต๊ฐ ์ก์ธ์ค ๊ถํ์ด ์๋ ๋จธ์ ์์ ์คํ๋์ด์ผ ํ๋ฉฐ, ๊ทธ๋ ์ง ์์ผ๋ฉด ์๋ํ์ง ์์ต๋๋ค.curl -H "host: store.example.internal" -H "env: canary" http://VIP
์ด ์ถ๋ ฅ์ ์์ฒญ์ด
gke-west-2
ํด๋ฌ์คํฐ์ ํฌ๋์์ ์ ๊ณต๋์๋์ง ํ์ธํฉ๋๋ค.{ "cluster_name": "gke-west-2", "host_header": "store.example.internal", "node_name": "gke-gke-west-2-default-pool-4cde1f72-m82p.c.agmsb-k8s.internal", "pod_name": "store-5f5b954888-9kdb5", "pod_name_emoji": "๐", "project_id": "agmsb-k8s", "timestamp": "2021-05-31T01:21:55", "zone": "us-west1-a" }
ํธ๋ํฝ ๋ฏธ๋ฌ๋ง
์ด ๋จ๊ณ์์๋ ์๋๋ ํด๋ฌ์คํฐ๋ก ํธ๋ํฝ์ ์ ์กํ์ง๋ง ๋ํ ์นด๋๋ฆฌ์ ํด๋ฌ์คํฐ๋ก ํธ๋ํฝ์ ๋ฏธ๋ฌ๋งํฉ๋๋ค.
๋ฏธ๋ฌ๋ง ์ฌ์ฉ์ ์ด๋ค ๋ฐฉ์์ผ๋ก๋ ํด๋ผ์ด์ธํธ์ ๋ํ ์๋ต์ ์ํฅ์ ์ฃผ์ง ์๊ณ ํธ๋ํฝ ๋ก๋๊ฐ ์ ํ๋ฆฌ์ผ์ด์ ์ฑ๋ฅ์ ๋ฏธ์น๋ ์ํฅ์ ํ์ธํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค. ๋ชจ๋ ์ข ๋ฅ์ ์ถ์์ ํ์ํ์ง๋ ์์ ์ ์์ง๋ง ์ฑ๋ฅ ๋๋ ๋ก๋์ ์ํฅ์ ์ค ์ ์๋ ๋๊ท๋ชจ ๋ณ๊ฒฝ์ฌํญ์ ์ถ์ํ ๋ ์ ์ฉํ ์ ์์ต๋๋ค.
๋ค์
HTTPRoute
๋งค๋ํ์คํธ๋ฅผ ๊ตฌ์ฑ ํด๋ฌ์คํฐ(์ด ์์์์๋gke-west-1
)์ ์ ์ฉํฉ๋๋ค.cat << EOF | kubectl apply --context gke-west-1 -f - kind: HTTPRoute apiVersion: gateway.networking.k8s.io/v1beta1 metadata: name: internal-store-route namespace: store labels: gateway: internal-http spec: parentRefs: - kind: Gateway namespace: store name: internal-http hostnames: - "store.example.internal" rules: # Sends all traffic to store-west-1 ServiceImport - backendRefs: - name: store-west-1 group: net.gke.io kind: ServiceImport port: 8080 # Also mirrors all traffic to store-west-2 ServiceImport filters: - type: RequestMirror requestMirror: backendRef: group: net.gke.io kind: ServiceImport name: store-west-2 port: 8080 EOF
๋น๊ณต๊ฐ ํด๋ผ์ด์ธํธ๋ฅผ ์ฌ์ฉํ์ฌ ์์ฒญ์
internal-http
๊ฒ์ดํธ์จ์ด๋ก ์ ์กํฉ๋๋ค. ์ดํ ๋จ๊ณ์์ ์ ํ๋ฆฌ์ผ์ด์ ๋ก๊ทธ์์ ์ด ์์ฒญ์ ๊ณ ์ ํ๊ฒ ์๋ณํ ์ ์๋๋ก/mirror
๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํฉ๋๋ค.curl -H "host: store.example.internal" http://VIP/mirror
์ถ๋ ฅ์ ํตํด ํด๋ผ์ด์ธํธ๊ฐ
gke-west-1
ํด๋ฌ์คํฐ์ ํฌ๋์์ ์๋ต์ ์์ ํ์์ด ํ์ธ๋ฉ๋๋ค.{ "cluster_name": "gke-west-1", "host_header": "store.example.internal", "node_name": "gke-gke-west-1-default-pool-65059399-ssfq.c.agmsb-k8s.internal", "pod_name": "store-5f5b954888-brg5w", "pod_name_emoji": "๐", "project_id": "agmsb-k8s", "timestamp": "2021-05-31T01:24:51", "zone": "us-west1-a" }
์ฆ, ๊ธฐ๋ณธ ํด๋ฌ์คํฐ๊ฐ ํธ๋ํฝ์ ์๋ตํ๊ณ ์์ต๋๋ค. ๋ง์ด๊ทธ๋ ์ด์ ์ค์ธ ํด๋ฌ์คํฐ๊ฐ ๋ฏธ๋ฌ๋ง๋ ํธ๋ํฝ์ ์์ ํ๋์ง ํ์ธํด์ผ ํฉ๋๋ค.
gke-west-2
ํด๋ฌ์คํฐ์์store
ํฌ๋์ ์ ํ๋ฆฌ์ผ์ด์ ๋ก๊ทธ๋ฅผ ํ์ธํฉ๋๋ค. ์ด ๋ก๊ทธ๋ก ํฌ๋๊ฐ ๋ถํ ๋ถ์ฐ๊ธฐ์์ ๋ฏธ๋ฌ๋ง๋ ํธ๋ํฝ์ ์์ ํ๋์ง ํ์ธ๋ฉ๋๋ค.kubectl logs deployment/store --context gke-west-2 -n store | grep /mirror
์ด ์ถ๋ ฅ์
gke-west-2
ํด๋ฌ์คํฐ์ ํฌ๋๊ฐ ๋์ผํ ์์ฒญ์ ์์ ํ๋์ง ํ์ธํฉ๋๋ค. ํ์ง๋ง ์ด๋ฌํ ์์ฒญ์ ๋ํ ์๋ต์ ํด๋ผ์ด์ธํธ๋ก ๋ค์ ์ ์ก๋์ง ์์ต๋๋ค. ๋ก๊ทธ์ ํ์๋ IP ์ฃผ์๋ ํด๋น ํฌ๋์ ํต์ ํ๋ ๋ถํ ๋ถ์ฐ๊ธฐ์ ๋ด๋ถ IP ์ฃผ์์ ๋๋ค.Found 2 pods, using pod/store-5c65bdf74f-vpqbs [2023-10-12 21:05:20,805] INFO in _internal: 192.168.21.3 - - [12/Oct/2023 21:05:20] "GET /mirror HTTP/1.1" 200 - [2023-10-12 21:05:27,158] INFO in _internal: 192.168.21.3 - - [12/Oct/2023 21:05:27] "GET /mirror HTTP/1.1" 200 - [2023-10-12 21:05:27,805] INFO in _internal: 192.168.21.3 - - [12/Oct/2023 21:05:27] "GET /mirror HTTP/1.1" 200 -
ํธ๋ํฝ ๋ถํ
ํธ๋ํฝ ๋ถํ ์ ์ ์ฝ๋๋ฅผ ์ถ์ํ๊ฑฐ๋ ์ ํ๊ฒฝ์ ์์ ํ๊ฒ ๋ฐฐํฌํ๊ธฐ ์ํ ๊ฐ์ฅ ์ผ๋ฐ์ ์ธ ๋ฐฉ๋ฒ ์ค ํ๋์ ๋๋ค. ์๋น์ค ์์ ์๋ ์ค์ ์ฌ์ฉ์ ์์ฒญ์ ๋ํด ์๋ฝ๋๋ ์ํ ์์ค์ ๋ฐ๋ผ ์ถ์ ์ฑ๊ณต์ ํ์ธํ ์ ์๋๋ก ์ผ๋ฐ์ ์ผ๋ก ์ ์ฒด ํธ๋ํฝ์ ๊ทน์๋์ ํด๋นํ๋ ์นด๋๋ฆฌ์ ๋ฐฑ์๋๋ก ์ ์ก๋๋ ๋ช ์์ ์ธ ํธ๋ํฝ ๋ฐฑ๋ถ์จ์ ์ค์ ํฉ๋๋ค.
ํธ๋ํฝ์ ์๋์ ํธ๋ํฝ ๋ถํ ์ ์ํํ๋ฉด ์๋น์ค ์์ ์๊ฐ ์ ํ๋ฆฌ์ผ์ด์ ๋ฐ ์๋ต ์ํ๋ฅผ ์กฐ์ฌํ ์ ์์ต๋๋ค. ๋ชจ๋ ์ ํธ๊ฐ ์ ์ ์ํ๋ก ๋ณด์ด๋ฉด ์ ์ฒด ์ปท์ค๋ฒ๋ก ์งํํ ์ ์์ต๋๋ค.
๋ค์
HTTPRoute
๋งค๋ํ์คํธ๋ฅผ ๊ตฌ์ฑ ํด๋ฌ์คํฐ(์ด ์์์์๋gke-west-1
)์ ์ ์ฉํฉ๋๋ค.cat << EOF | kubectl apply --context gke-west-1 -f - kind: HTTPRoute apiVersion: gateway.networking.k8s.io/v1beta1 metadata: name: internal-store-route namespace: store labels: gateway: internal-http spec: parentRefs: - kind: Gateway namespace: store name: internal-http hostnames: - "store.example.internal" rules: - backendRefs: # 90% of traffic to store-west-1 ServiceImport - name: store-west-1 group: net.gke.io kind: ServiceImport port: 8080 weight: 90 # 10% of traffic to store-west-2 ServiceImport - name: store-west-2 group: net.gke.io kind: ServiceImport port: 8080 weight: 10 EOF
๋น๊ณต๊ฐ ํด๋ผ์ด์ธํธ๋ฅผ ์ฌ์ฉํ์ฌ ์ง์์ ์ธ curl ์์ฒญ์
internal- http
๊ฒ์ดํธ์จ์ด๋ก ์ ์กํฉ๋๋ค.while true; do curl -H "host: store.example.internal" -s VIP | grep "cluster_name"; sleep 1; done
์ถ๋ ฅ์ ์ด์ ๋น์ทํ๋ฉฐ, 90/10 ํธ๋ํฝ ๋ถํ ์ด ์ํ๋จ์ ๋ํ๋ ๋๋ค.
"cluster_name": "gke-west-1", "cluster_name": "gke-west-1", "cluster_name": "gke-west-1", "cluster_name": "gke-west-1", "cluster_name": "gke-west-1", "cluster_name": "gke-west-1", "cluster_name": "gke-west-1", "cluster_name": "gke-west-1", "cluster_name": "gke-west-2", "cluster_name": "gke-west-1", "cluster_name": "gke-west-1", ...
ํธ๋ํฝ ์ปท์ค๋ฒ
๋ธ๋ฃจ-๊ทธ๋ฆฐ ๋ง์ด๊ทธ๋ ์ด์
์ ๋ง์ง๋ง ๋จ๊ณ๋ ์ ํด๋ฌ์คํฐ๋ก ์์ ํ ์ปท์ค๋ฒํ๊ณ ์ด์ ํด๋ฌ์คํฐ๋ฅผ ์ญ์ ํ๋ ๊ฒ์
๋๋ค. ์๋น์ค ์์ ์๊ฐ ์ค์ ๋ก ๋ ๋ฒ์งธ ํด๋ฌ์คํฐ๋ฅผ ๊ธฐ์กด ํด๋ฌ์คํฐ๋ก ์จ๋ณด๋ฉํ๊ณ ์์๋ ๊ฒฝ์ฐ์๋ ์ต์ข
๋จ๊ณ๋ก ํธ๋ํฝ์ด ๋ ํด๋ฌ์คํฐ ๋ชจ๋๋ก ์ ์ก๋๋ฏ๋ก, ์ด ๋ง์ง๋ง ๋จ๊ณ๊ฐ ๋ฌ๋ผ์ง๋๋ค. ์ด ์๋๋ฆฌ์ค์์๋ gke-west-1
๋ฐ gke-west-2
ํด๋ฌ์คํฐ ๋ชจ๋์ ํฌ๋๊ฐ ํฌํจ๋ ๋จ์ผ store
ServiceImport๊ฐ ๊ถ์ฅ๋ฉ๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ๋ถํ ๋ถ์ฐ๊ธฐ๊ฐ ๊ทผ์ ์ฑ, ์ํ, ์ฉ๋์ ๊ธฐ์ค์ผ๋ก ํ์ฑ-ํ์ฑ ์ ํ๋ฆฌ์ผ์ด์
์ ๋ํด ํธ๋ํฝ์ด ์ ์ก๋ ์์น๋ฅผ ๊ฒฐ์ ํ ์ ์์ต๋๋ค.
๋ค์
HTTPRoute
๋งค๋ํ์คํธ๋ฅผ ๊ตฌ์ฑ ํด๋ฌ์คํฐ(์ด ์์์์๋gke-west-1
)์ ์ ์ฉํฉ๋๋ค.cat << EOF | kubectl apply --context gke-west-1 -f - kind: HTTPRoute apiVersion: gateway.networking.k8s.io/v1beta1 metadata: name: internal-store-route namespace: store labels: gateway: internal-http spec: parentRefs: - kind: Gateway namespace: store name: internal-http hostnames: - "store.example.internal" rules: - backendRefs: # No traffic to the store-west-1 ServiceImport - name: store-west-1 group: net.gke.io kind: ServiceImport port: 8080 weight: 0 # All traffic to the store-west-2 ServiceImport - name: store-west-2 group: net.gke.io kind: ServiceImport port: 8080 weight: 100 EOF
๋น๊ณต๊ฐ ํด๋ผ์ด์ธํธ๋ฅผ ์ฌ์ฉํ์ฌ ์ง์์ ์ธ curl ์์ฒญ์
internal- http
๊ฒ์ดํธ์จ์ด๋ก ์ ์กํฉ๋๋ค.while true; do curl -H "host: store.example.internal" -s VIP | grep "cluster_name"; sleep 1; done
์ถ๋ ฅ์ ๋ค์๊ณผ ๋น์ทํฉ๋๋ค. ์ด์ ๋ชจ๋ ํธ๋ํฝ์ด
gke-west-2
๋ก ์ ์ก๋ฉ๋๋ค."cluster_name": "gke-west-2", "cluster_name": "gke-west-2", "cluster_name": "gke-west-2", "cluster_name": "gke-west-2", ...
์ด ๋ง์ง๋ง ๋จ๊ณ์์๋ ํ๋์ GKE ํด๋ฌ์คํฐ์์ ๋ค๋ฅธ GKE ํด๋ฌ์คํฐ๋ก ์ ์ฒด ๋ธ๋ฃจ-๊ทธ๋ฆฐ ์ ํ๋ฆฌ์ผ์ด์ ๋ง์ด๊ทธ๋ ์ด์ ์ ์๋ฃํฉ๋๋ค.
์ฉ๋ ๊ธฐ๋ฐ ๋ถํ ๋ถ์ฐ ๋ฐฐํฌ
์ด ์น์ ์ ์ฐ์ต์์๋ ์๋ก ๋ค๋ฅธ ๋ฆฌ์ ์์ 2๊ฐ์ GKE ํด๋ฌ์คํฐ ๊ฐ์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฐฐํฌํ์ฌ ์ ์ญ ๋ถํ ๋ถ์ฐ ๋ฐ ์๋น์ค ์ฉ๋ ๊ฐ๋ ์ ์ค๋ช ํฉ๋๋ค. ํด๋ฌ์คํฐ ๋ฐ ๋ฆฌ์ ๊ฐ์ ํธ๋ํฝ์ด ๋ถํ ๋ถ์ฐ๋๋ ๋ฐฉ์์ ๋ณด์ฌ์ฃผ๊ธฐ ์ํด ์ฌ๋ฌ ์ด๋น ์์ฒญ ์(RPS) ์์ค์ผ๋ก ์์ฑ๋ ํธ๋ํฝ์ด ์ ์ก๋ฉ๋๋ค.
๋ค์ ๋ค์ด์ด๊ทธ๋จ์ ๋ฐฐํฌํ ํ ํด๋ก์ง์ ํธ๋ํฝ์ด ์๋น์ค ์ฉ๋์ ์ด๊ณผํ ๋ ํด๋ฌ์คํฐ ๋ฐ ๋ฆฌ์ ๊ฐ์ ํธ๋ํฝ์ด ์ค๋ฒํ๋ก๋๋ ๋ฐฉ์์ ๋ณด์ฌ์ค๋๋ค.
ํธ๋ํฝ ๊ด๋ฆฌ์ ๋ํด ์์ธํ ์์๋ณด๋ ค๋ฉด GKE ํธ๋ํฝ ๊ด๋ฆฌ๋ฅผ ์ฐธ์กฐํ์ธ์.
๊ฐ๋ฐ ํ๊ฒฝ ์ค๋น
๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด ์ฌ์ฉ ์ค์ ์ ๋ฐ๋ผ ํ๊ฒฝ์ ์ค๋นํฉ๋๋ค.
GatewayClass ๋ฆฌ์์ค๊ฐ ๊ตฌ์ฑ ํด๋ฌ์คํฐ์ ์ค์น๋์๋์ง ํ์ธํ์ธ์.
kubectl get gatewayclasses --context=gke-west-1
์ถ๋ ฅ์ ๋ค์๊ณผ ๋น์ทํฉ๋๋ค.
NAME CONTROLLER ACCEPTED AGE gke-l7-global-external-managed networking.gke.io/gateway True 16h gke-l7-global-external-managed-mc networking.gke.io/gateway True 14h gke-l7-gxlb networking.gke.io/gateway True 16h gke-l7-gxlb-mc networking.gke.io/gateway True 14h gke-l7-regional-external-managed networking.gke.io/gateway True 16h gke-l7-regional-external-managed-mc networking.gke.io/gateway True 14h gke-l7-rilb networking.gke.io/gateway True 16h gke-l7-rilb-mc networking.gke.io/gateway True 14h
์ ํ๋ฆฌ์ผ์ด์ ๋ฐฐํฌ
๋ ํด๋ฌ์คํฐ ๋ชจ๋์ ์ํ ์น ์ ํ๋ฆฌ์ผ์ด์ ์๋ฒ๋ฅผ ๋ฐฐํฌํฉ๋๋ค.
kubectl apply --context gke-west-1 -f https://raw.githubusercontent.com/GoogleCloudPlatform/gke-networking-recipes/master/gateway/docs/store-traffic-deploy.yaml
kubectl apply --context gke-east-1 -f https://raw.githubusercontent.com/GoogleCloudPlatform/gke-networking-recipes/master/gateway/docs/store-traffic-deploy.yaml
์ถ๋ ฅ์ ๋ค์๊ณผ ๋น์ทํฉ๋๋ค.
namespace/store created
deployment.apps/store created
์๋น์ค, ๊ฒ์ดํธ์จ์ด, HTTPRoute ๋ฐฐํฌ
๋ค์
Service
๋งค๋ํ์คํธ๋ฅผgke-west-1
๋ฐgke-east-1
ํด๋ฌ์คํฐ ๋ชจ๋์ ์ ์ฉํฉ๋๋ค.cat << EOF | kubectl apply --context gke-west-1 -f - apiVersion: v1 kind: Service metadata: name: store namespace: traffic-test annotations: networking.gke.io/max-rate-per-endpoint: "10" spec: ports: - port: 8080 targetPort: 8080 name: http selector: app: store type: ClusterIP --- kind: ServiceExport apiVersion: net.gke.io/v1 metadata: name: store namespace: traffic-test EOF
cat << EOF | kubectl apply --context gke-east-1 -f - apiVersion: v1 kind: Service metadata: name: store namespace: traffic-test annotations: networking.gke.io/max-rate-per-endpoint: "10" spec: ports: - port: 8080 targetPort: 8080 name: http selector: app: store type: ClusterIP --- kind: ServiceExport apiVersion: net.gke.io/v1 metadata: name: store namespace: traffic-test EOF
์๋น์ค์ ์ด๋น ์์ฒญ 10๊ฐ๋ก ์ค์ ๋
max-rate-per-endpoint
์ฃผ์์ด ์ถ๊ฐ๋ฉ๋๋ค. ๋ณต์ ๋ณธ์ด ํด๋ฌ์คํฐ๋น 2๊ฐ ์๋ ๊ฐ ์๋น์ค์ ์ฉ๋์ ํด๋ฌ์คํฐ๋น 20RPS์ ๋๋ค.์๋น์ค์ ์๋น์ค ์ฉ๋ ์์ค์ ์ ํํ๋ ๋ฐฉ๋ฒ์ ์๋น์ค ์ฉ๋ ๊ฒฐ์ ์ ์ฐธ์กฐํ์ธ์.
๋ค์
Gateway
๋งค๋ํ์คํธ๋ฅผ ๊ตฌ์ฑ ํด๋ฌ์คํฐ(์ด ์์์์๋gke-west-1
)์ ์ ์ฉํฉ๋๋ค.cat << EOF | kubectl apply --context gke-west-1 -f - kind: Gateway apiVersion: gateway.networking.k8s.io/v1beta1 metadata: name: store namespace: traffic-test spec: gatewayClassName: gke-l7-global-external-managed-mc listeners: - name: http protocol: HTTP port: 80 allowedRoutes: kinds: - kind: HTTPRoute EOF
์ด ๋งค๋ํ์คํธ๋ ๊ณต๊ฐ์ ์ผ๋ก ์ก์ธ์ค ๊ฐ๋ฅํ IP ์ฃผ์๋ฅผ ์ฌ์ฉํด์ ์ธ๋ถ ์ ํ๋ฆฌ์ผ์ด์ ๋ถํ ๋ถ์ฐ๊ธฐ๋ฅผ ๋ฐฐํฌํ๋ ์ธ๋ถ์ ์ ์ญ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ฅผ ๊ธฐ์ ํฉ๋๋ค.
๋ค์
HTTPRoute
๋งค๋ํ์คํธ๋ฅผ ๊ตฌ์ฑ ํด๋ฌ์คํฐ(์ด ์์์์๋gke-west-1
)์ ์ ์ฉํฉ๋๋ค.cat << EOF | kubectl apply --context gke-west-1 -f - kind: HTTPRoute apiVersion: gateway.networking.k8s.io/v1beta1 metadata: name: store namespace: traffic-test labels: gateway: store spec: parentRefs: - kind: Gateway namespace: traffic-test name: store rules: - backendRefs: - name: store group: net.gke.io kind: ServiceImport port: 8080 EOF
์ด ๋งค๋ํ์คํธ๋ ๋ชจ๋ ํธ๋ํฝ์ ์ ์ฅ์ ServiceImport๋ก ์ ๋ฌํ๋ ๋ผ์ฐํ ๊ท์น์ ์ฌ์ฉํด์ ๊ฒ์ดํธ์จ์ด๋ฅผ ๊ตฌ์ฑํ๋ HTTPRoute๋ฅผ ๊ธฐ์ ํฉ๋๋ค.
store
ServiceImport๋ ๋ ํด๋ฌ์คํฐ ๊ฐ์store
์๋น์ค ํฌ๋๋ฅผ ๊ทธ๋ฃน์ผ๋ก ๋ฌถ๊ณ ๋ถํ ๋ถ์ฐ๊ธฐ์์ ๋จ์ผ ์๋น์ค๋ก ์ฒ๋ฆฌ๋๋๋ก ํ์ฉํฉ๋๋ค.๋ช ๋ถ ํ ๊ฒ์ดํธ์จ์ด ์ด๋ฒคํธ๋ฅผ ๊ฒ์ฌํ์ฌ ๋ฐฐํฌ๊ฐ ์๋ฃ๋์๋์ง ํ์ธํ ์ ์์ต๋๋ค.
kubectl describe gateway store -n traffic-test --context gke-west-1
์ถ๋ ฅ์ ๋ค์๊ณผ ๋น์ทํฉ๋๋ค.
... Status: Addresses: Type: IPAddress Value: 34.102.159.147 Conditions: Last Transition Time: 2023-10-12T21:40:59Z Message: The OSS Gateway API has deprecated this condition, do not depend on it. Observed Generation: 1 Reason: Scheduled Status: True Type: Scheduled Last Transition Time: 2023-10-12T21:40:59Z Message: Observed Generation: 1 Reason: Accepted Status: True Type: Accepted Last Transition Time: 2023-10-12T21:40:59Z Message: Observed Generation: 1 Reason: Programmed Status: True Type: Programmed Last Transition Time: 2023-10-12T21:40:59Z Message: The OSS Gateway API has altered the "Ready" condition semantics and reservedit for future use. GKE Gateway will stop emitting it in a future update, use "Programmed" instead. Observed Generation: 1 Reason: Ready Status: True Type: Ready Listeners: Attached Routes: 1 Conditions: Last Transition Time: 2023-10-12T21:40:59Z Message: Observed Generation: 1 Reason: Programmed Status: True Type: Programmed Last Transition Time: 2023-10-12T21:40:59Z Message: The OSS Gateway API has altered the "Ready" condition semantics and reservedit for future use. GKE Gateway will stop emitting it in a future update, use "Programmed" instead. Observed Generation: 1 Reason: Ready Status: True Type: Ready Name: http Supported Kinds: Group: gateway.networking.k8s.io Kind: HTTPRoute Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal ADD 12m mc-gateway-controller traffic-test/store Normal SYNC 6m43s mc-gateway-controller traffic-test/store Normal UPDATE 5m40s (x4 over 12m) mc-gateway-controller traffic-test/store Normal SYNC 118s (x6 over 10m) mc-gateway-controller SYNC on traffic-test/store was a success
์ด ์ถ๋ ฅ์ ๊ฒ์ดํธ์จ์ด๊ฐ ์ฑ๊ณต์ ์ผ๋ก ๋ฐฐํฌ๋์์์ ๋ณด์ฌ์ค๋๋ค. ๊ฒ์ดํธ์จ์ด๊ฐ ๋ฐฐํฌ๋ ํ ํธ๋ํฝ ์ ๋ฌ์ด ์์๋๋ ค๋ฉด ์ฌ์ ํ ๋ช ๋ถ ์ ๋ ๊ธฐ๋ค๋ ค์ผ ํ ์ ์์ต๋๋ค. ๋ค์ ๋จ๊ณ์์ ์ฌ์ฉ๋๋ฏ๋ก, ์ด ์ถ๋ ฅ์์ IP ์ฃผ์๋ฅผ ๊ธฐ๋กํด ๋ก๋๋ค.
ํธ๋ํฝ ํ์ธ
curl ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํด์ ๊ฒ์ดํธ์จ์ด IP ์ฃผ์๋ฅผ ํ ์คํธํ์ฌ ํธ๋ํฝ์ด ์ ํ๋ฆฌ์ผ์ด์ ์ ์ ๋ฌ๋๋์ง ํ์ธํฉ๋๋ค.
curl GATEWAY_IP_ADDRESS
์ถ๋ ฅ์ ๋ค์๊ณผ ๋น์ทํฉ๋๋ค.
{
"cluster_name": "gke-west-1",
"host_header": "34.117.182.69",
"pod_name": "store-54785664b5-mxstv",
"pod_name_emoji": "๐ณ๐ฟ",
"project_id": "project",
"timestamp": "2021-11-01T14:06:38",
"zone": "us-west1-a"
}
์ด ์ถ๋ ฅ์ ์์ฒญ์ด ์ฒ๋ฆฌ๋ ๋ฆฌ์ ์ ๋ํ๋ด๋ ํฌ๋ ๋ฉํ๋ฐ์ดํฐ๋ฅผ ๋ณด์ฌ์ค๋๋ค.
๋ถํ ํ ์คํธ๋ฅผ ์ฌ์ฉํ์ฌ ํธ๋ํฝ ํ์ธ
๋ถํ ๋ถ์ฐ๊ธฐ๊ฐ ์๋ํ๋์ง ํ์ธํ๋ ค๋ฉด gke-west-1
ํด๋ฌ์คํฐ์์ ํธ๋ํฝ ์์ฑ๊ธฐ๋ฅผ ๋ฐฐํฌํ ์ ์์ต๋๋ค. ํธ๋ํฝ ์์ฑ๊ธฐ๋ ๋ถํ ๋ถ์ฐ๊ธฐ์ ์ฉ๋ ๋ฐ ์ค๋ฒํ๋ก ์ฑ๋ฅ์ ํ์ํ๊ธฐ ์ํด ์ฌ๋ฌ ๋ถํ ์์ค์ผ๋ก ํธ๋ํฝ์ ์์ฑํฉ๋๋ค. ๋ค์ ๋จ๊ณ์์๋ ์ธ ๊ฐ์ง ๋ถํ ์์ค์ ๋ณด์ฌ์ค๋๋ค.
- 10 RPS๋
gke-west-1
์์ ์ ์ฅ์ ์๋น์ค ์ฉ๋ ์๋์ ์์ต๋๋ค. - 30 RPS๋
gke-west-1
์ ์ฅ์ ์๋น์ค ์ฉ๋์ ์ด๊ณผํ๊ณ ํธ๋ํฝ์ดgke-east-1
๋ก ์ค๋ฒํ๋ก๋๋๋ก ํฉ๋๋ค. - 60 RPS๋ ๋ ํด๋ฌ์คํฐ ๋ชจ๋ ์๋น์ค์ ์ฉ๋์ ์ด๊ณผํฉ๋๋ค.
๋์๋ณด๋ ๊ตฌ์ฑ
๊ฒ์ดํธ์จ์ด์ ๋ํด ๊ธฐ๋ณธ URLmap ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
kubectl get gateway store -n traffic-test --context=gke-west-1 -o=jsonpath="{.metadata.annotations.networking\.gke\.io/url-maps}"
์ถ๋ ฅ์ ๋ค์๊ณผ ๋น์ทํฉ๋๋ค.
/projects/PROJECT_NUMBER/global/urlMaps/gkemcg1-traffic-test-store-armvfyupay1t
Google Cloud ์ฝ์์์ ์ธก์ ํญ๋ชฉ ํ์๊ธฐ ํ์ด์ง๋ก ์ด๋ํฉ๋๋ค.
์ธก์ ํญ๋ชฉ ์ ํ์์ ์ฝ๋: MQL์ ํด๋ฆญํฉ๋๋ค.
๋ ํด๋ฌ์คํฐ ๊ฐ์ ์ ์ฅ์ ์๋น์ค์ ํธ๋ํฝ ์ธก์ ํญ๋ชฉ์ ๊ด์ธกํ๊ธฐ ์ํด ๋ค์ ์ฟผ๋ฆฌ๋ฅผ ์ ๋ ฅํฉ๋๋ค.
fetch https_lb_rule | metric 'loadbalancing.googleapis.com/https/backend_request_count' | filter (resource.url_map_name == 'GATEWAY_URL_MAP') | align rate(1m) | every 1m | group_by [resource.backend_scope], [value_backend_request_count_aggregate: aggregate(value.backend_request_count)]
GATEWAY_URL_MAP
์ ์ด์ ๋จ๊ณ์ URLmap ์ด๋ฆ์ผ๋ก ๋ฐ๊ฟ๋๋ค.์ฟผ๋ฆฌ ์คํ์ ํด๋ฆญํฉ๋๋ค. ์ธก์ ํญ๋ชฉ์ด ์ฐจํธ์ ํ์๋๋๋ก ๋ค์ ์น์ ์์ ๋ก๋ ์์ฑ๊ธฐ๋ฅผ ๋ฐฐํฌํ ํ ์ต์ 5๋ถ ์ด์ ๊ธฐ๋ค๋ฆฝ๋๋ค.
10 RPS ํ ์คํธ
ํฌ๋๋ฅผ
gke-west-1
ํด๋ฌ์คํฐ์ ๋ฐฐํฌํฉ๋๋ค.kubectl run --context gke-west-1 -i --tty --rm loadgen \ --image=cyrilbkr/httperf \ --restart=Never \ -- /bin/sh -c 'httperf \ --server=GATEWAY_IP_ADDRESS \ --hog --uri="/zone" --port 80 --wsess=100000,1,1 --rate 10'
GATEWAY_IP_ADDRESS
๋ฅผ ์ด์ ๋จ๊ณ์ ๊ฒ์ดํธ์จ์ด IP ์ฃผ์๋ก ๋ฐ๊ฟ๋๋ค.์ถ๋ ฅ์ ๋ค์๊ณผ ๋น์ทํ๋ฉฐ, ํธ๋ํฝ ์์ฑ๊ธฐ๊ฐ ํธ๋ํฝ์ ์ ์กํ๊ณ ์์์ ๋ํ๋ ๋๋ค.
If you don't see a command prompt, try pressing enter.
๋ถํ ์์ฑ๊ธฐ๋ ๊ฒ์ดํธ์จ์ด๋ก ๊ณ์ 10 RPS๋ฅผ ์ ์กํฉ๋๋ค. ํธ๋ํฝ์ด Google Cloud ๋ฆฌ์ ๋ด๋ถ์์ ์์๋์ง๋ง ๋ถํ ๋ถ์ฐ๊ธฐ๋ ์ด๊ฒ์ ๋ฏธ๊ตญ ์๋ถ ํด์์์ ์์๋๋ ํด๋ผ์ด์ธํธ ํธ๋ํฝ์ผ๋ก ์ทจ๊ธํฉ๋๋ค. ์ค์ ์ ๊ฐ์ ํด๋ผ์ด์ธํธ ๋ค์์ฑ์ ์๋ฎฌ๋ ์ด์ ํ๊ธฐ ์ํด ๋ถํ ๋ถ์ฐ๊ธฐ๋ ๊ฐ HTTP ์์ฒญ์ ์๋ก์ด TCP ์ฐ๊ฒฐ๋ก ์ ์กํฉ๋๋ค. ์ฆ, ํธ๋ํฝ์ด ๋ฐฑ์๋ ํฌ๋ ๊ฐ์ ๋ณด๋ค ๊ณ ๋ฅด๊ฒ ๋ถ์ฐ๋ฉ๋๋ค.
์์ฑ๊ธฐ๊ฐ ๋์๋ณด๋์ ๋ํด ํธ๋ํฝ์ ์์ฑํ๋ ค๋ฉด ์ต๋ 5๋ถ๊น์ง ๊ฑธ๋ฆฝ๋๋ค.
์ธก์ ํญ๋ชฉ ํ์๊ธฐ ๋์๋ณด๋๋ฅผ ํ์ธํฉ๋๋ค. ๊ฐ ํด๋ฌ์คํฐ์ ๋ํด ํธ๋ํฝ์ด ๋ถํ ๋ถ์ฐ๋ ์ ๋๋ฅผ ๋ํ๋ด๋ 2๊ฐ ์ค์ด ํ์๋ฉ๋๋ค.
us-east1-b
๊ฐ ํธ๋ํฝ์ ์์ ํ์ง ์๋ ๋์us-west1-a
์์ ์ฝ 10 RPS ํธ๋ํฝ์ ์์ ํ๋ ๊ฒ์ด ํ์ธ๋ฉ๋๋ค. ํธ๋ํฝ ์์ฑ๊ธฐ๊ฐus-west1
์์ ์คํ๋๋ฏ๋ก, ๋ชจ๋ ํธ๋ํฝ์ดgke-west-1
ํด๋ฌ์คํฐ์ ์๋น์ค๋ก ์ ์ก๋ฉ๋๋ค.Ctrl+C๋ฅผ ์ฌ์ฉํด์ ๋ถํ ์์ฑ๊ธฐ๋ฅผ ์ค์งํ๊ณ ํฌ๋๋ฅผ ์ญ์ ํฉ๋๋ค.
kubectl delete pod loadgen --context gke-west-1
30 RPS ํ ์คํธ
30 RPS๋ฅผ ์ ์กํ๋๋ก ๊ตฌ์ฑํด์ ๋ถํ ์์ฑ๊ธฐ๋ฅผ ๋ค์ ๋ฐฐํฌํฉ๋๋ค.
kubectl run --context gke-west-1 -i --tty --rm loadgen \ --image=cyrilbkr/httperf \ --restart=Never \ -- /bin/sh -c 'httperf \ --server=GATEWAY_IP_ADDRESS \ --hog --uri="/zone" --port 80 --wsess=100000,1,1 --rate 30'
์์ฑ๊ธฐ๊ฐ ๋์๋ณด๋์ ๋ํด ํธ๋ํฝ์ ์์ฑํ๋ ค๋ฉด ์ต๋ 5๋ถ๊น์ง ๊ฑธ๋ฆฝ๋๋ค.
Cloud ์์ ๋์๋ณด๋๋ฅผ ํ์ธํฉ๋๋ค.
์ฝ 20 RPS๊ฐ
us-west1-a
๋ก ์ ์ก๋๊ณ 10 RPS๊ฐus-east1-b
๋ก ์ ์ก๋๋ ๊ฒ์ผ๋ก ํ์ธ๋ฉ๋๋ค. ์ด๊ฒ์gke-west-1
์ ์๋น์ค๊ฐ ์์ ํ ์ฌ์ฉ๋๊ณ ์๊ณ ํธ๋ํฝ์ 10 RPS๋ฅผgke-east-1
์ ์๋น์ค๋ก ์ค๋ฒํ๋กํ๊ณ ์์์ ๋ํ๋ ๋๋ค.Ctrl+C๋ฅผ ์ฌ์ฉํด์ ๋ถํ ์์ฑ๊ธฐ๋ฅผ ์ค์งํ๊ณ ํฌ๋๋ฅผ ์ญ์ ํฉ๋๋ค.
kubectl delete pod loadgen --context gke-west-1
60 RPS ํ ์คํธ
60 RPS๋ฅผ ์ ์กํ๋๋ก ๊ตฌ์ฑ๋ ๋ถํ ์์ฑ๊ธฐ๋ฅผ ๋ฐฐํฌํฉ๋๋ค.
kubectl run --context gke-west-1 -i --tty --rm loadgen \ --image=cyrilbkr/httperf \ --restart=Never \ -- /bin/sh -c 'httperf \ --server=GATEWAY_IP_ADDRESS \ --hog --uri="/zone" --port 80 --wsess=100000,1,1 --rate 60'
5๋ถ ์ ๋ ๊ธฐ๋ค๋ฆฌ๊ณ Cloud ์์ ๋์๋ณด๋๋ฅผ ํ์ธํฉ๋๋ค. ์ด์ ๋ ํด๋ฌ์คํฐ ๋ชจ๋ ์ฝ 30 RPS๋ฅผ ์์ ํ๋ ๊ฒ์ผ๋ก ํ์๋ฉ๋๋ค. ๋ชจ๋ ์๋น์ค๊ฐ ์ ๋ฐ์ ์ผ๋ก ์ด๊ณผ ์ฌ์ฉ๋๊ณ ์๊ธฐ ๋๋ฌธ์ ํธ๋ํฝ ์คํ์ค๋ฒ๊ฐ ์ํ๋์ง ์์ผ๋ฉฐ, ์๋น์ค๊ฐ ๊ฐ๋ฅํ ๋ชจ๋ ํธ๋ํฝ์ ํก์ํฉ๋๋ค.
Ctrl+C๋ฅผ ์ฌ์ฉํด์ ๋ถํ ์์ฑ๊ธฐ๋ฅผ ์ค์งํ๊ณ ํฌ๋๋ฅผ ์ญ์ ํฉ๋๋ค.
kubectl delete pod loadgen --context gke-west-1
์ญ์
์ด ํ์ด์ง์ ์ฐ์ต์ ์๋ฃํ ํ์๋ ๋ค์ ๋จ๊ณ์ ๋ฐ๋ผ ์์ ์ ๊ณ์ ์ ์์น ์๋ ๋น์ฉ์ด ๋ฐ์ํ์ง ์๋๋ก ๋ฆฌ์์ค๋ฅผ ์ญ์ ํฉ๋๋ค.
๋ค๋ฅธ ๋ชฉ์ ์ผ๋ก ๋ฑ๋กํ ํ์๊ฐ ์์ผ๋ฉด Fleet์์ ํด๋ฌ์คํฐ๋ฅผ ๋ฑ๋ก ์ทจ์ํฉ๋๋ค.
multiclusterservicediscovery
๊ธฐ๋ฅ์ ์ฌ์ฉ ์ค์งํฉ๋๋ค.gcloud container fleet multi-cluster-services disable
๋ฉํฐ ํด๋ฌ์คํฐ ์ธ๊ทธ๋ ์ค ์ฌ์ฉ ์ค์ง
gcloud container fleet ingress disable
API๋ฅผ ์ฌ์ฉ ์ค์งํฉ๋๋ค.
gcloud services disable \ multiclusterservicediscovery.googleapis.com \ multiclusteringress.googleapis.com \ trafficdirector.googleapis.com \ --project=PROJECT_ID
๊ณต์ VPC์ ํจ๊ป ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด ์ฌ์ฉ
์ฌ์ฉ ์ฌ๋ก์ ๋ฐ๋ผ ๋ค๋ฅธ ํ ํด๋ก์ง๋ฅผ ์ฌ์ฉํด์ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ฅผ ๊ณต์ VPC ํ๊ฒฝ์ ๋ฐฐํฌํ ์๋ ์์ต๋๋ค.
๋ค์ ํ์์๋ ๊ณต์ VPC ํ๊ฒฝ ๋ด์์ ์ง์๋๋ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด ํ ํด๋ก์ง๋ฅผ ์ค๋ช ํฉ๋๋ค.
์๋๋ฆฌ์ค | Fleet ํธ์คํธ ํ๋ก์ ํธ | ๊ตฌ์ฑ ํด๋ฌ์คํฐ | ์ํฌ๋ก๋ ํด๋ฌ์คํฐ |
---|---|---|---|
1 | ๊ณต์ VPC ํธ์คํธ ํ๋ก์ ํธ | ๊ณต์ VPC ํธ์คํธ ํ๋ก์ ํธ | ๊ณต์ VPC ํธ์คํธ ํ๋ก์ ํธ |
2 | ๊ณต์ VPC ์๋น์ค ํ๋ก์ ํธ | ๊ณต์ VPC ์๋น์ค ํ๋ก์ ํธ (Fleet ์๋น์ค ํ๋ก์ ํธ์ ๋์ผ) |
๊ณต์ VPC ์๋น์ค ํ๋ก์ ํธ (Fleet ์๋น์ค ํ๋ก์ ํธ์ ๋์ผ) |
๊ณต์ VPC ํ๊ฒฝ์์ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ฒ์ดํธ์จ์ด๋ฅผ ๋ง๋ค๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค.
๊ณต์ VPC๋ฅผ ์ฌ์ฉํ์ฌ ๋ฉํฐ ํด๋ฌ์คํฐ ์๋น์ค๋ฅผ ์ค์ ํ๋ ๋จ๊ณ๋ฅผ ๋ฐ๋ฆ ๋๋ค.
์๋น์ค๋ฅผ ๋ง๋ค์ด ๊ตฌ์ฑ ํด๋ฌ์คํฐ๋ก ๋ด๋ณด๋ ๋๋ค.
๋ฉํฐ ํด๋ฌ์คํฐ ๋ด๋ถ ๊ฒ์ดํธ์จ์ด๋ฅผ ์ฌ์ฉํ๋ ค๋ ๊ฒฝ์ฐ ํ๋ก์ ์ ์ฉ ์๋ธ๋ท์ ๋ง๋ญ๋๋ค.
๋ฉํฐ ํด๋ฌ์คํฐ ์ธ๋ถ ๋๋ ๋ด๋ถ ๊ฒ์ดํธ์จ์ด ๋ฐ HTTPRoute๋ฅผ ๋ง๋ญ๋๋ค.
์ด ๋จ๊ณ๋ฅผ ์๋ฃํ๋ฉด ํ ํด๋ก์ง์ ๋ฐ๋ผ ๋ฐฐํฌ๋ฅผ ๊ฒ์ฆํ ์ ์์ต๋๋ค.
๋ฌธ์ ํด๊ฒฐ
๋ด๋ถ ๊ฒ์ดํธ์จ์ด์ ํ๋ก์ ์ ์ฉ ์๋ธ๋ท์ด ์์
๋ด๋ถ ๊ฒ์ดํธ์จ์ด์ ๋ค์ ์ด๋ฒคํธ๊ฐ ํ์๋๋ฉด ํ๋ก์ ์ ์ฉ ์๋ธ๋ท์ด ํด๋น ๋ฆฌ์ ์ ์์ต๋๋ค. ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด ํ๋ก์ ์ ์ฉ ์๋ธ๋ท์ ๋ฐฐํฌํฉ๋๋ค.
generic::invalid_argument: error ensuring load balancer: Insert: Invalid value for field 'resource.target': 'regions/us-west1/targetHttpProxies/gkegw-x5vt-default-internal-http-2jzr7e3xclhj'. A reserved and active subnetwork is required in the same region and VPC as the forwarding rule.
์ ์ ์ ์คํธ๋ฆผ ์์
์ฆ์:
๊ฒ์ดํธ์จ์ด๋ฅผ ๋ง๋ค ๋ ๋ฐฑ์๋ ์๋น์ค์ ์ก์ธ์คํ ์ ์๋ ๊ฒฝ์ฐ ๋ค์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค(503 ์๋ต ์ฝ๋).
no healthy upstream
์ด์ :
์ด ์ค๋ฅ ๋ฉ์์ง๋ ์ํ ์ ๊ฒ ํ๋ก๋ฒ๊ฐ ์ ์ ๋ฐฑ์๋ ์๋น์ค๋ฅผ ์ฐพ์ ์ ์์์ ๋ํ๋ ๋๋ค. ๋ฐฑ์๋ ์๋น์ค๊ฐ ์ ์์ผ ์ ์์ง๋ง ์ํ ์ ๊ฒ์ ๋ง์ถค์ค์ ํด์ผ ํ ์๋ ์์ต๋๋ค.
ํด๊ฒฐ ๋ฐฉ๋ฒ:
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด HealthCheckPolicy
๋ฅผ ์ฌ์ฉํ์ฌ ์ ํ๋ฆฌ์ผ์ด์
์๊ตฌ์ฌํญ(์: /health
)์ ๋ฐ๋ผ ์ํ ์ ๊ฒ์ ๋ง์ถค์ค์ ํฉ๋๋ค.
๋ค์ ๋จ๊ณ
- ๊ฒ์ดํธ์จ์ด ์ปจํธ๋กค๋ฌ ์์ธํ ์์๋ณด๊ธฐ