What is GCP?
Google Cloud Platform, offered by Google, is a suite of cloud computing services that runs on the same infrastructure that Google uses internally for its end-user products, such as Google Search and YouTube. For more details, please refer: https://cloud.google.com/
What is Terraform?
Terraform is an open-source infrastructure as code software tool created by HashiCorp. It enables users to define and provision a datacenter infrastructure using a high-level configuration language known as Hashicorp Configuration Language, or optionally JSON. For more details, please refer: https://www.terraform.io/
What is CI/CD?
In software engineering, CI/CD or CICD generally refers to the combined practices of continuous integration and either continuous delivery or continuous deployment. For more details, Please refer: https://en.wikipedia.org/wiki/CI/CD
- Create keys (Public and Private) via Putty Keygen. The comment mentioned in Putty Keygen will be the user name
- While accessing VM which will be created in GCP through Putty use USERNAME@<Machine IP> and Private key
- To add key by Terraform to GCP for vm creation, the Public key should be saved as <pub_cert_name>.pub
– Specific format of Public Cert required. Sample:
=================cert’s content starts==================
==================cert’s content ends====================
Pointers regarding certs:
– “ssh-rsa” is the format name
– “user” at the end of cert, is the user name
- Create Utility Server VM via terraform. In GCP, make sure it has all the required port in the firewall. Also, create GKE cluster via terraform
- Access the Jenkins, http://<serverip>:8080 in the browser.
- Putty (SSH) to the Utility VM using the “user” SSH key.
find / -name initialAdminPassword
Copy this ^ output and paste it in the Jenkins web page (step 2) as an admin password
Setup user in Jenkins’s web page. After setup, verify below mentioned plugin is there or not
- Google Kubernetes Plugin
- Solarqube Plugin
- logstash Plugin
To verify go to, Manage Jenkins -> Manage Plugins -> Installed
- Add Google service account in Jenkins, Provide the details
Select the JSON file, and click ok.
- SonarQube Configurations
Add SonarQube tocken
SonarQube server configuration
Go to Manage Jenkins -> Configure System and look for SonarQube servers
- Logstash Configuration
Go to Manage Jenkins -> Configure System and look for Logstash
- Create Pipleline in Jenkins. Click “Open Blue Ocean”
Select as shared in the image
Open page to create pipeline -> Click on “Create a new Pipeline”
Click “Create Pipeline”
– This will kick a build to run
Sample application’s Jenkins Pipeline
Terraform file to create Utility Server VM
4 thoughts on “CI/CD in GCP with Terraform”
This was really helpful. Thanks
interesting for a very long time
thanks, interesting read