Today we will launch instance using instance template and instance Group
Without Instance Template we can't launch Instance Group, So we will first create instance Template.
Step 1:- Expand services, Go to compute Engine and click on Instance Template.
Step 2:- Click on create Instance Template.
Step 3:- Name your instance template and choose your Machine type.
Step 4:- Scroll down Under firewall Allow HTTP traffic and Allow HTTPS traffic.
Step 5:- Expand Advanced Options under that click on Management and paste your script under startup script, Finally click on create.
#!/bin/bash
apt update
apt -y install apache2
echo "Hello world from $(hostname) $(hostname -I)" > /var/www/html/index.html
Step 6:- Your Instance template is ready.
Step 7:- On your left Scroll down and click on instance groups.
Step 8:- Click on create instance groups.
Step 9:- Choose New managed instance group (stateless).
Step 10:- Give a name for your instance group and choose your instance template.
Step 11:- Under location choose Multiple zone and Target distribution shape as Even.
Even here means Your Traffic will be distributed evenly to your instance.
Step 12:- Under Autoscaling, We are going to need Minimum number of instances as 2 for now and Maximum number of instances as 4.
Step 13:- Click on CPU utilization: 60% (default).
Step 14:- Metric Type will be CPU Utilization, Target CPU utilization as 75 and finally click done.
Step 15:- Click to create Instance group.
Step 16:- As you can see we got our two instance because we mentioned minimum 2 instance, Which will always runs if something happens to our instance, Instance group will make sure you will get your 2 instance up and running always.
Now if you copy, paste your External IP address it should work.
That's it, for now, we will continue further more in next blog.
Hope you liked it. Will see you on the next topic ๐