
Answer-first summary for fast verification
Answer: gcloud compute firewall-rules create allow-lb --network load-balancer --allow tcp --source-ranges 130.211.0.0/22,35.191.0.0/16 --direction INGRESS
The health checks are failing because the firewall rules in the custom network do not allow traffic from Google's health check IP ranges (130.211.0.0/22 and 35.191.0.0/16). The correct solution is to create an ingress firewall rule allowing TCP traffic on port 80 from these ranges. Option C creates such a rule. Option B (adding http-server tag) would only help if a firewall rule targeting that tag exists, which is not the case here as the network is custom and lacks default rules. Options A and D are irrelevant as external IPs aren't required for health checks and egress rules don't affect incoming traffic.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You have deployed an HTTP(s) Load Balancer using the following gcloud commands:
export NAME=Load-balancer
# create network
gcloud compute networks create ${NAME}
# add instance
gcloud compute instances create ${NAME}-backend-instance-1 --subnet ${NAME} --no-address
# create the instance group
gcloud compute instance-groups unmanaged create ${NAME}-i
gcloud compute instance-groups unmanaged set-named-ports ${NAME}-i --named-ports http:80
gcloud compute instance-groups unmanaged add-instances ${NAME}-i --instances ${NAME}-backend-instance-1
# configure health checks
gcloud compute health-checks create http ${NAME}-http-hc --port 80
# create backend service
gcloud compute backend-services create ${NAME}-http-bes --health-checks ${NAME}-http-hc --protocol HTTP --port-name http --global
gcloud compute backend-services add-backend ${NAME}-http-bes --instance-group ${NAME}-i --balancing-mode RATE --max-rate 100000 --capacity-scaler 1.0 --global --instance-group-zone us-east1-d
# create url maps and forwarding rule
gcloud compute url-maps create ${NAME}-http-urlmap --default-service ${NAME}-http-bes
gcloud compute target-http-proxies create ${NAME}-http-proxy --url-map ${NAME}-http-urlmap
gcloud compute forwarding-rules create ${NAME}-http-fw --global --ip-protocol TCP --target-http-proxy ${NAME}-http-proxy --ports 80
export NAME=Load-balancer
# create network
gcloud compute networks create ${NAME}
# add instance
gcloud compute instances create ${NAME}-backend-instance-1 --subnet ${NAME} --no-address
# create the instance group
gcloud compute instance-groups unmanaged create ${NAME}-i
gcloud compute instance-groups unmanaged set-named-ports ${NAME}-i --named-ports http:80
gcloud compute instance-groups unmanaged add-instances ${NAME}-i --instances ${NAME}-backend-instance-1
# configure health checks
gcloud compute health-checks create http ${NAME}-http-hc --port 80
# create backend service
gcloud compute backend-services create ${NAME}-http-bes --health-checks ${NAME}-http-hc --protocol HTTP --port-name http --global
gcloud compute backend-services add-backend ${NAME}-http-bes --instance-group ${NAME}-i --balancing-mode RATE --max-rate 100000 --capacity-scaler 1.0 --global --instance-group-zone us-east1-d
# create url maps and forwarding rule
gcloud compute url-maps create ${NAME}-http-urlmap --default-service ${NAME}-http-bes
gcloud compute target-http-proxies create ${NAME}-http-proxy --url-map ${NAME}-http-urlmap
gcloud compute forwarding-rules create ${NAME}-http-fw --global --ip-protocol TCP --target-http-proxy ${NAME}-http-proxy --ports 80
Health checks to port 80 on the Compute Engine virtual machine instance are failing, and no traffic is being sent to your instances. You want to resolve the problem.
Which commands should you run?
A
gcloud compute instances add-access-config ${NAME}-backend-instance-1
B
gcloud compute instances add-tags ${NAME}-backend-instance-1 --tags http-server
C
gcloud compute firewall-rules create allow-lb --network load-balancer --allow tcp --source-ranges 130.211.0.0/22,35.191.0.0/16 --direction INGRESS
D
gcloud compute firewall-rules create allow-lb --network load-balancer --allow tcp --destination-ranges 130.211.0.0/22,35.191.0.0/16 --direction EGRESS
No comments yet.