• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

load balancer

GCP Backend Services Health Status

February 14, 2023

Here’s how to get health status of a GCP Load Balancer Backend Services.

For all load balancers except target pool.

gcloud compute backend-services get-health BACKEND_SERVICE_NAME \
--region us-central1 \
--project project-id

gcloud compute backend-services get-health BACKEND_SERVICE_NAME \ --region us-central1 \ --project project-id

For target pool load balancers, use this command.

gcloud compute target-pools get-health TARGET_POOL_NAME \
--region us-central1 \
--project project-id

gcloud compute target-pools get-health TARGET_POOL_NAME \ --region us-central1 \ --project project-id

Filed Under: Cloud Tagged With: backend-service, gcp, health, load balancer, status

AWS List of Auto Scaling Groups

January 27, 2023

Here’s a script to list Auto Scaling Groups from multiple AWS accounts. Accounts are in your AWS profiles.

#!/bin/bash
file='results-aws-asg.txt'
> $file
declare -a account=("default" "account-1" "account-2" "account-3" "account-4" "account-5")
declare -a region=("us-east-1" "us-east-2" "us-west-1" "us-west-2")
for i in "${account[@]}"
do
    echo '----------------------' >> $file
    echo 'Account: '$i >> $file
    for j in "${region[@]}"
    do
        echo 'Region: '$j >> $file
        aws autoscaling describe-auto-scaling-groups \
        --query "AutoScalingGroups[].[AutoScalingGroupName,LaunchConfigurationName]" \
        --profile $i \
        --region $j \
        --output text >> $file
    done
done

#!/bin/bash file='results-aws-asg.txt' > $file declare -a account=("default" "account-1" "account-2" "account-3" "account-4" "account-5") declare -a region=("us-east-1" "us-east-2" "us-west-1" "us-west-2") for i in "${account[@]}" do echo '----------------------' >> $file echo 'Account: '$i >> $file for j in "${region[@]}" do echo 'Region: '$j >> $file aws autoscaling describe-auto-scaling-groups \ --query "AutoScalingGroups[].[AutoScalingGroupName,LaunchConfigurationName]" \ --profile $i \ --region $j \ --output text >> $file done done

Filed Under: Cloud Tagged With: auto scaling, aws, groups, list, load balancer

AWS List of Application LB

August 17, 2020

Here’s how to display a list of application load balancers.

aws elbv2 describe-load-balancers --profile --region us-east-1

aws elbv2 describe-load-balancers --profile --region us-east-1

Here’s how to display classic load balancers.

aws elb describe-load-balancers --profile --region us-east-1

aws elb describe-load-balancers --profile --region us-east-1

Filed Under: Cloud Tagged With: application, aws cli, elb, elbv2, load balancer

GCP Display Forwarding Rules

June 1, 2020

Here’s how to display a list of Google Cloud forwarding rules.

gcloud compute forwarding-rules list

gcloud compute forwarding-rules list

If you want global only.

gcloud compute forwarding-rules --global

gcloud compute forwarding-rules --global

Or just local regions only.

gcloud compute forwarding-rules --filter="region:( us-central us-west1 )"

gcloud compute forwarding-rules --filter="region:( us-central us-west1 )"

Filed Under: Cloud Tagged With: compute, forwarding-rules, gcloud, gcp, load balancer

AWS Register Instances with Load Balancer

February 19, 2020

Here’s the AWS CLI to register instances to a load balancer.

aws elb register-instances-with-load-balancer \
--load-balancer-name my-load-balancer \
--instances i-xxxxxxxxxxx i-xxxxxxxxxxx i-xxxxxxxxxxx

aws elb register-instances-with-load-balancer \ --load-balancer-name my-load-balancer \ --instances i-xxxxxxxxxxx i-xxxxxxxxxxx i-xxxxxxxxxxx

Filed Under: Cloud Tagged With: aws, cli, instances, load balancer, register

GCP ILB Issue Targets Not Healthy

January 14, 2020

I ran into an issue with Google Compute Engine TCP internal load balancer. The targets are unhealthy although all configs were correct installed. At one time the targets were working, but somehow they became unhealthy. In the end, 3 things needed to be checked.

  1. Make sure GCP’s guest environment is installed.
  2. Add the internal load balancer VIP address to the network properties.
  3. Add route via cmd. “route ADD VIP MASK 255.255.255.255”

You will need to change the server’s IP from DHCP to static to add ILB VIP.

Filed Under: Cloud Tagged With: add, cmd, environment, gcp, guest, internal, load balancer, network, properties, route, vip

GCP Setup NLB

December 23, 2019

Here’s how to setup a Network Load Balancer in GCP.

Setup your instances.

# Instance 1
gcloud compute instances create www1 \
  --image-family debian-9 \
  --image-project debian-cloud \
  --zone us-central1-b \
  --tags network-lb-tag \
  --metadata startup-script="#! /bin/bash
    sudo apt-get update
    sudo apt-get install apache2 -y
    sudo service apache2 restart
    echo '<!doctype html><html><body><h1>www1</h1></body></html>' | tee /var/www/html/index.html
    EOF"
# Instance 2
gcloud compute instances create www2 \
  --image-family debian-9 \
  --image-project debian-cloud \
  --zone us-central1-b \
  --tags network-lb-tag \
  --metadata startup-script="#! /bin/bash
    sudo apt-get update
    sudo apt-get install apache2 -y
    sudo service apache2 restart
    echo '<!doctype html><html><body><h1>www2</h1></body></html>' | tee /var/www/html/index.html
    EOF"
# Instance 3
gcloud compute instances create www3 \
  --image-family debian-9 \
  --image-project debian-cloud \
  --zone us-central1-b \
  --tags network-lb-tag \
  --metadata startup-script="#! /bin/bash
    sudo apt-get update
    sudo apt-get install apache2 -y
    sudo service apache2 restart
    echo '<!doctype html><html><body><h1>www3</h1></body></html>' | tee /var/www/html/index.html
    EOF"

# Instance 1 gcloud compute instances create www1 \ --image-family debian-9 \ --image-project debian-cloud \ --zone us-central1-b \ --tags network-lb-tag \ --metadata startup-script="#! /bin/bash sudo apt-get update sudo apt-get install apache2 -y sudo service apache2 restart echo '<!doctype html><html><body><h1>www1</h1></body></html>' | tee /var/www/html/index.html EOF" # Instance 2 gcloud compute instances create www2 \ --image-family debian-9 \ --image-project debian-cloud \ --zone us-central1-b \ --tags network-lb-tag \ --metadata startup-script="#! /bin/bash sudo apt-get update sudo apt-get install apache2 -y sudo service apache2 restart echo '<!doctype html><html><body><h1>www2</h1></body></html>' | tee /var/www/html/index.html EOF" # Instance 3 gcloud compute instances create www3 \ --image-family debian-9 \ --image-project debian-cloud \ --zone us-central1-b \ --tags network-lb-tag \ --metadata startup-script="#! /bin/bash sudo apt-get update sudo apt-get install apache2 -y sudo service apache2 restart echo '<!doctype html><html><body><h1>www3</h1></body></html>' | tee /var/www/html/index.html EOF"

Create a firewall to allow external traffic to reach port 80.

gcloud compute firewall-rules create www-firewall-network-lb \
    --target-tags network-lb-tag --allow tcp:80

gcloud compute firewall-rules create www-firewall-network-lb \ --target-tags network-lb-tag --allow tcp:80

Configure your network load balancer.

# Create an external IP address.
gcloud compute addresses create network-lb-ip-1 \
    --region us-central1
# Add a legacy HTTP health check.
gcloud compute http-health-checks create basic-check
# Add a target pool.
gcloud compute target-pools add-instances www-pool \
    --instances www1,www2,www3 \
    --instances-zone us-central1-b
# Add a forwarding rule.
gcloud compute forwarding-rules create www-rule \
    --region us-central1 \
    --ports 80 \
    --address network-lb-ip-1 \
    --target-pool www-pool
# Lookup external IP address.
gcloud compute forwarding-rules describe www-rule \
    --region us-central1

# Create an external IP address. gcloud compute addresses create network-lb-ip-1 \ --region us-central1 # Add a legacy HTTP health check. gcloud compute http-health-checks create basic-check # Add a target pool. gcloud compute target-pools add-instances www-pool \ --instances www1,www2,www3 \ --instances-zone us-central1-b # Add a forwarding rule. gcloud compute forwarding-rules create www-rule \ --region us-central1 \ --ports 80 \ --address network-lb-ip-1 \ --target-pool www-pool # Lookup external IP address. gcloud compute forwarding-rules describe www-rule \ --region us-central1

Finally, use the curl command to send traffic to the NLB external IP address.

while true; do curl -m1 [IP_ADDRESS]; done

while true; do curl -m1 [IP_ADDRESS]; done

Filed Under: Cloud Tagged With: curl, firewall, forwarding, gcp, health check, instances, load balancer, network, nlb, pool

Use Curl on Load Balancers

December 18, 2019

You can use the curl command to test if your load balancer is working as expected. The curl command will alternately and randomly access several instances in your load balancer. If you have 3 instances behind your load balancer, it will be cycled across all 3. The -m1 command means max time is set to 1 second.

while true; do curl -m1 [IP_ADDRESS]; done

while true; do curl -m1 [IP_ADDRESS]; done

Filed Under: Cloud Tagged With: aws, curl, gcp, load balancer, test

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023