Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

JINIers

Create an Internal Load Balancer 본문

GCP/Qwiklabs

Create an Internal Load Balancer

JINIers 2022. 3. 2. 16:11

※ 수정

220930 : 내용 수정


내부 로드밸런서 생성

목표

  • http 및 상태 확인 방화벽 규칙 만들기
  • 두 개의 인스턴스 템플릿 구성
  • 관리형 인스턴스 그룹 2개 만들기
  • 내부 부하 분산장치 구성 및 테스트

 


1. http 및 상태 확인 방화벽 규칙 구성


[my-internal-app 네트워크 탐색]

vpc network > vpc network > my-internal-app 있는지 확인


[http 방화벽 규칙 만들기]

gcloud compute firewall-rules create app-allow-http --direction=INGRESS --priority=1000 --network=my-internal-app --action=ALLOW --rules=tcp:80 --source-ranges=0.0.0.0/0 --target-tags=lb-backend
gcloud compute firewall-rules create app-allow-health-check --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp --source-ranges=130.211.0.0/22,35.191.0.0/16 --target-tags=lb-backend

 

2. 인스턴스 템플릿 구성 및 인스턴스 그룹 생성

[인스턴스 템플릿 구성]

 - name : instance-template-1
- machine-type=n1-standard-1
- network-interface : my-internal-app
- network-interface subnet=subnet-a
-metadata : startup-script-url=gs://cloud-training/gcpnet/ilb/startup.sh
- tags=lb-backend


create similar > 
- network-interface subnet=subnet-b

 


[관리형 인스턴스 그룹 만들기]

  • Name : instance-group-1
  • Location : Single-zone
  • Region : us-central1
  • Zone : us-central1-a
  • Instance template : instance-template-1
  • Autoscaling > Autoscaling policy > Click Pencil icon > Metric type : CPU utilization
  • Target CPU utilization : 80
  • Cool-down period : 45
  • Minimum number of instances : 1
  • Maximum number of instances : 5

  • Name : instance-group-2
  • Location : Single-zone
  • Region : us-central1
  • Zone : us-central1-b
  • Instance template : instance-template-2
  • Autoscaling > Autoscaling policy > Click Pencil icon > Metric type : CPU utilization
  • Target CPU utilization : 80
  • Cool-down period : 45
  • Minimum number of instances : 1
  • Maximum number of instances : 5

[백엔드 확인]

vm 인스턴스 생성

  • Name : utility-vm
  • Region : us-central1
  • Zone : us-central1-f
  • Series : N1
  • Machine type : f1-micro (1 shared vCPU)


network interfaces 조건

  • Network : my-internal-app
  • Subnetwork : subnet-a
  • Primary internal IP : Ephemeral (Custom)
  • Custom ephemeral IP address : 10.10.20.50

* 백엔드 internal ip : 10.10.20.2 / 10.10.30.2

utility-vm ssh > 
curl 10.10.20.2 / 10.10.30.2 로 연결확인

 


3. 내부 로드 밸런서 구성

 

두 백엔드 간 트래픽을 분산하도록 내부 로드 밸런서를 구성함

1. instance-group-1 / us-central1-a

2. instance-group-2 / us-central1-b

 

network service > LB > create > tcp 로드밸런싱 > Internet facing or internal only : Only between my VMs > 

  • name : my-ilb
  • region : us-central1
  • network : my-internal-app

[백엔드구성]

Instance group : instance-group-1 (us-central1-a)

> add backend 
Instance group : instance-group-2 (us-central1-b)

> Create a health check

  • Name my-ilb-health-check
  • Protocol TCP
  • Port 80


> save

[프론트엔드 구성]

Subnetwork subnet-b
Internal IP Under IP address select Create IP address

  • Name : my-ilb-ip
  • Static IP address : ​Let me choose
  • Custom IP address : ​10.10.30.5
  • Port : 80

4. 내부 부하분산 장치 테스트

utility-vm ssh >

반복

curl 10.10.30.5



그럼 zone이 변경되는 것을 확인할 수 있다.

4. test

 

 

Comments