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
Steps
- 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==================ssh-rsa
AAAAB3NzaC1yc2EAAAABJQAAAQEAkOVqb9IZetNPA1rp70TNlfL1v4BYheMsTsStUlEKD9
NAcNRVfD2pwchFs2z2plHGIM8yNxngbSDwgPzndFhsrB1IghtQ9bn2KlY3KA/l8IXPHWsYk
EeKDpOYFZ3QGBsdB51ehbKx3/CCgo+LQnDgH6mBXB8QerlZgHXLSgqXX6SDe17XnGO4
if+9hpxsAn/ryzccyYkwmluk/C/rgIGCTijqmcH3ebLfUrMtBUxvtrq5hOmRD9ILIytB0Z8xY6e
mviPjFO9TI+tpdlTlbWV8mIitnZsOazYzjl9Q== user
==================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.
Execute command:
find / -name initialAdminPassword
Sample Output:
/var/lib/docker/volumes/jenkins-data/_data/secrets/initialAdminPassword
Execute command:
cat /var/lib/docker/volumes/jenkins-data/_data/secrets/initialAdminPassword
Sample Output:
4f7fe8a55b0d4da8853e2fe23b315968
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
![](https://www.volksinfotech.com/wp-content/uploads/2020/02/jenkins-1.jpg)
![](https://www.volksinfotech.com/wp-content/uploads/2020/02/plugin-1.jpg)
- Add Google service account in Jenkins, Provide the details
![](https://www.volksinfotech.com/wp-content/uploads/2020/02/gce_cred-1.jpg)
Select the JSON file, and click ok.
- SonarQube Configurations
Add SonarQube tocken
![](https://www.volksinfotech.com/wp-content/uploads/2020/02/sonar1-1.jpg)
SonarQube server configuration
Go to Manage Jenkins -> Configure System and look for SonarQube servers
![](https://www.volksinfotech.com/wp-content/uploads/2020/02/sonar2-1024x316.jpg)
- Logstash Configuration
Go to Manage Jenkins -> Configure System and look for Logstash
![aujIÄ_HIstQry.
Manage Jenkins
My Views
Open Blue Ocean
Credentials
Lockable Resources
New View](https://www.volksinfotech.com/wp-content/uploads/2020/02/logstash.jpg)
- Create Pipleline in Jenkins. Click “Open Blue Ocean”
Select as shared in the image
![](https://www.volksinfotech.com/wp-content/uploads/2020/02/blue_ocean-1.jpg)
Open page to create pipeline -> Click on “Create a new Pipeline”
![e
e
Where do you store your code?
Bitbucket Cloud
GitHub
Git
Connect to GitHub
Bitbucket Server
GitHub Enterprise
an accæs to with GitHub
token
Which organization does the repository belong to?
p pivota Iservices
Choose a repository
4
hello-app
simple-jm-m—app
Create
Complete](https://www.volksinfotech.com/wp-content/uploads/2020/02/pipe.jpg)
![](https://www.volksinfotech.com/wp-content/uploads/2020/02/src_code-1.jpg)
Click “Create Pipeline”
– This will kick a build to run
Sample application’s Jenkins Pipeline
![Start
Initialization
Initialization
SonarQube
Build
Test
Logstash
Test
Deploy
Cleanup
End](https://www.volksinfotech.com/wp-content/uploads/2020/02/sample_pipeline.jpg)
Terraform file to create Utility Server VM
This was really helpful. Thanks
Thank you!!1
interesting for a very long time
thanks, interesting read