GCE Quick Recap
- Lets create one ubuntu vm and one centos vm in the default vpc in regions us-central1 and us-east1
- While creating vm we select boot disk
- SSH keys for vm instances can be managed at the project level or at the instance level.
- If you dont want project level ssh keys to be applied to particular vm
Scenario:
- Your team is building a project which runs on tomcat 9 server, so whenver you need to deploy your application, we need tomcat 9 server to be installed
- Sol:
- One approach is create the vm and install the tomcat 9 server every time
- Create a vm where tomcat 9 is pre-installed
- To use tomcat 8 image created by others, we can search in market place
- When you go with marketplace images, there might be software costs incurred on the vm per hour
- In general, we will use market place for network scanning, firewall etc where organizations pay the costs
- In this we are expected to build our own image.
- Lets create a boot disk custom image with tomcat 9 installed.
- Login into ubuntu 20 server and execute the following commands
sudo apt update
sudo apt install tomcat9 tomcat9-admin tomcat9-common tomcat9-docs tomcat9-user -y
- tomcat works on port 8080, so we need to create a firewall rule to open port 8080, so create a firewall rule in default vpc to open port 8080
- Now we have a vm with tomcat 9 installed, if we can create a reusable boot disk (custom image) from this vm that would be easy for the project
- Now delete the created vm’s
- Now try creating a vm instance with tomcat 9 machine image created by you
Exercise: Create one more reusable machine image
- Refer Here
- In this documentation, skip mysql installation and firewall adjustments and execute rest of the steps
- Creation of VM Images can be automated using a tool called as packer Refer Here
