You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Step-04: Create a firewall rule to allow health check probes to connect to your app
Health check probes come from addresses in the ranges 130.211.0.0/22 and 35.191.0.0/16, so make sure your firewall rules allow the health check to connect. For this example, the MIG uses the default network, and its VMs listen on port 80. If port 80 isn't already open on the default network, create a firewall rule.
Go to Compute Engine -> Instance Groups -> Click on mig-stateless
Review the following Tabs
Overview
Details
Monitoring
Errors
Go to Compute Engine -> VM Instances -> Verify VM created by Instance Group
Step-07: Create a Load Balancer
Go to Network Services -> Load Balancing -> Create Load Balancer -> HTTP(S) Load Balancing -> START CONFIGURATION
Internet facing or internal only: From internet to my VMs
Click on Continue
Name: lb-for-mig-stateless
Frontend Configuration
New Frontend IP and port
Name: fip-lb-mig-stateless
Protocol: HTTP
Network Service Tier: Premium
IP Version: IPV4
IP Address: Click on CREATE IP ADDRESS
NAME: sip-lb-mig-stateless
DESCRIPTION: sip-lb-mig-stateless
Port: 80
Click on DONE
CREATE A BACKEND SERVICE
Click on CREATE A BACKEND SERVICE
Name: lb-backend-for-mig-stateless
Description: lb-backend-for-mig-stateless
Backend Type: Instance Group
Protocol: HTTP
Naed Port: http
Timeout: 30
New backend: managed-instance-group-stateless
Port Numbers: 80 (select webserver-port named port from that instance group)
Balancing mode: Utilization
Maximum backend utilization: 80
Maximum RPS: leave empty (leave to defaults)
Scope: per instance (leave to defaults)
Capacity: 100
Click on DONE
Click on CREATE
Logging: leave unchecked (leave to defaults)
Security: leave unselected (leave to defaults)
Click on CREATE
Host and Path Rules
Mode: Simple host and path rule
Review and Finalize
Front End
Backend
Click on CREATE
It will take 3 to 5 minutes to create the load balancer.
Step-08: Verify Load Balancer Properties after creation
Go to Network Services -> Load Balancing -> lb-for-unmanaged-instance-group
Verify if Instances are Healthy
Step-09: Access Sample Application using LB IP
# Access Sample App
http:/;<LB-IP-ADDRESS>
http://34.149.43.103
Observation:
1. Keep refreshing to see the output from both Virtual Machines
2. You will see output from both VMs switching
# Curl with while loop runs every 1 secondwhile true; do curl http://35.209.128.93/; sleep 1; done
Step-10: Discuss about MANAGE SCHEDULES
Go to Compute Engine -> Instance Groups -> Click on mig-stateless
Click on DETAILS TAB
Click on MANAGE SCHEDULES -> CREATE SCHEDULE
Name: high-traffic-tuesday
Description: high-traffic-tuesday
Minimum Required Instances: 3 (Usually minimum is 2 but on tuesday we will have 3)
Go to Compute Engine -> Instance Groups -> Click on mig-stateless
Click on Edit
Go to Predictive Autoscaling -> Click on See if predictive autoscaling can optimize your availability
Step-11-02: Auto-healing
# Connect to one VM Instane
gcloud compute ssh --zone "us-central1-c""mig-stateless-2ztq" --project "gcplearn9"# Delete index.html
cd /var/www/html
sudo rm index.html
sudo rm index.nginx-debian.html
# Access App from Browser using VM public IP
http://EXTERNAL-IP
Observation:
1. HTTP 403 forbidden error from ngnix
## Auto-healing observation
1. A new vm instance should be re-created with same name
Step-12: Discuss about UPDATE VMs
Step-12-01: Create a new Instance Template
Here we are going to create a new Instance Template by cloning existing template named mig-it-stateless-v1
Change-1: change the machine type to e2-small
Change-2: change the Startup script to v2-webserver-install.sh
Go to Compute Engine -> VM Instances -> Instance Template -> mig-it-stateless-v1 -> CREATE SIMILAR
Step-12-02: How to UPDATE VMs setting in Instance Groups ? - UPDATE VMs
Go to Compute Engine -> Instance Groups -> Click on mig-stateless
Instance template & overrides
Instance Template: mig-it-stateless-v2
Update Type: Selective
Existing VMs are not updated automatically when instance configuration changes.
Changes will apply once existing VMs are replaced or restarted. (API name: OPPORTUNISTIC)
Update VMs in this group when they are replaced, refreshed, or restarted, except during auto-healing.
Updater will not actively replace instances, but when new instances are created by other means, you will deploy template "mig-it-stateless-v1" to 50% of instances and template "mig-it-stateless-v2" to 50% of instances in instance group "mig-stateless".
Update Type: Automatic
When instance configuration changes, updates to existing VMs will be applied automatically by MIG. (API name: PROACTIVE)
1. You are deploying template "mig-it-stateless-v1" to 50% of instances and template "mig-it-stateless-v2" to 50% of instances in instance group "mig-stateless".
2. 1 instance will be taken offline at a timeand 1 instance will be temporarily added to support the update.
Actions allowed to update VMs: only replace (Discuss all options)
When replacing keep VM names same: leave empty (leave to defaults - NOT CHECKED)
Observation: It will take few minutes (approximately 10 minutes) to complete the overall process and reach desired state
# Access Application using Load balancer
curl http://35.209.128.93/
http://35.209.128.93/
# In a while loopwhile true; do curl http://35.209.128.93/; sleep 1; done
Step-13: Explore DELETE INSTANCE setting
Go to Compute Engine -> Instance Groups -> Click on mig-stateless
Select one instance and DELETE the instance
Wait for couple of minutes
New instance will be recreated in few minutes
Step-14: Explore REMOVE FROM GROUP setting
Go to Compute Engine -> Instance Groups -> Click on mig-stateless
REMOVE Instance from group
Wait for couple of minutes
New instance will be created in few minutes
Go to Compute Engine -> VM Instances -> Delete the instance which was removed from Instance Group (WAIT FOR DELETE OPTION TO BE ENABLED)
Step-15: Explore RESTART / REPLACE VMs setting
Go to Compute Engine -> Instance Groups -> Click on mig-stateless
Step-15-01: Restart Option
Maximum unavailable: 1 Instance
Minimum wait time: 0 seconds
Click on RESTART
Step-15-02: Replace Option
Maximum surge: 1 instnace (Maximum number (or percentage) of temporary instances to add while replacing.)
Maximum unavailable: 1 Instance
Minimum wait time: 0 seconds
Click on REPLACE
Step-16: Review Monitoring Tab
Go to Compute Engine -> Instance Groups -> Click on mig-stateless
Click on MONITORING Tab
Primarily review Instances graph - How instances scaled-out and scaled-in
Step-17: Clean-Up - Delete Load Balancer
Go to Network Services -> Load Balancing -> lb-for-managed-instance-group
Click on DELETE
Select Backend services:lb-backend-for-mig-stateless for deletion
Leave Health Checks: lb-health-check-http unchecked to not to delete
Click on DELETE LOAD BALANCER AND SELECTED RESOURCES
Step-18: Clean-Up - Release External IP Address used for LB
Go to VPC Networks -> External IP Addresses
Select sip-lb-mig-stateless
click on RELEASE STATIC IP ADDRESS
Step-19: Clean-Up - Delete Instance Group
Go to Compute Engine -> Instance Groups -> Click on mig-stateless
Autoscaling Policy: CPU utilization 60% (Discuss other two Autoscaling Policies - HTTP Load Balancer Metrics and StackDriver or Cloud Monitoring Metric)
Predictive Autoscaling: Off
Cool down period: 60 seconds
Minimum Number of Instances: 3
Maximum Number of Instances: 9
Scale in Controls
Enable Scale In Controls: Checked (Enabled)
Don't scale in by more than: Number of Instances: 1 VMs
Over the course of: custom (5 minutes)
Autohealing:
Health check: No Health Check
Advanced creation options: leave to defaults and discuss
Click on CREATE
Step-21: Review Managed Instance Group Properties
Go to Compute Engine -> Instance Groups -> Click on mig-stateless-multiple-zones
Review the following Tabs
Overview
Details
Monitoring
Errors
Go to Compute Engine -> VM Instances -> Verify VM created by Instance Group and Verify its Zones
Step-22: Delete Managed Instance Group
Go to Compute Engine -> Instance Groups -> Click on mig-stateless-multiple-zones