Deploy Application on Kubernetes Using Jenkins Multicloud-GCP Infra

Aniket Kumavat
5 min readMar 31, 2023

--

Organizations can escape being reliant on a single cloud vendor by adopting a multi-cloud strategy. It also makes it easier for customers to negotiate with service providers for better rates and service level agreements. Data centers for various cloud service companies are spread across various regions. Through the use of a multi-cloud approach, businesses can split up their tasks among various service providers, cutting down on latency and enhancing the user experience for clients in various geographies.

Figure: Architecture diagram for the implementation of the proposed solution

In this Architecture, we’ve specified how quickly we can deploy our application to multiple clouds using Jenkins, and today’s businesses are switching from monolithic to microservice architectures to improve their operations.

High-level Steps-

  1. AWS and GCP infra by Aniket Kumavat
  2. EKS creation and Jenkins pipeline setup in AWS by Bhavesh Dhande (here).
  3. Jenkins pipeline setup in GCP by Siddhesh Patil (here)
  4. GKE creation and Route traffic using Route53 GKE and EKS by Rushabh Mahale

Note- Beginning with step number 1, I’ll create a Infrastructure in GCP.

Prerequisites-

  1. Need a GCP account.
  2. Basic knowledge of GCP services and linux.

GCP Infrastructure

After the completion AWS Infrastructure we are going to infra setup of GCP,
Go to the GCP console’s navigation menu, then VPC networks, and then create a new VPC network for our project, naming it gke-vpc.
Make gke-vpc regional and select region in Mumbai asia-south1 for high availability.
For more information on VPC networks follow the official document refer link.

gke-vpc

For subnets, we have to create two subnets named gke-subnet and jenkins-node-subnet.
Assigned private IP address to both subnets in same region

gke-subnet
jenkins-node-subnet

What is the Firewall Rule ?

  1. Firewall rules control the incoming and outgoing traffic to your virtual machine instances.
  2. By default the incoming traffic from outside your is blocked and the outgoing traffic is open to outside networks.
  3. In GCP, Incoming and outgoing traffic is known as ingress rule and egress rule.

To define protocols and ports for our network, we are using the following specific protocols and ports:

Here we completed the gke-vpc setup. Refer to this link for more information.
Create a virtual machine instance in gcp named jenkins-node-asia-south1 in mumbai asia-south1 region.

jenkins-node-asia-south1 vm

As shown below, vm is connected with gke-vpc.
Also, a boot disk of 10 GB is attached to our server and uses the Ubuntu operating system image.

jenkins-node-asia-south1 vm network and storage

Now SSH to your vm and then installed required packages and these packages are :

  1. Docker
  2. Java
  3. Git

Install these packages using link use in aws server.
Access the Jenkins web interface using the instance’s public IP address and port 8080.

The Jenkins home page is as follow:

For connecting the aws jenkins-master server, which is a master vm, and the gcp jenkins-node server, which is a slave vm . We will build a connection using a Jenkins node.

Configure the Jenkins Master to connect with the Jenkins Node:

In the Jenkins web interface, go to “Manage Jenkins” > “Manage Nodes and Clouds” > “New Node."

  • Provide a name for the new node and select “Permanent Agent” as the node type.
  • Enter the GCP vm’s work directory in the “Remote root directory” field.
  • Select “Launch the agent by connecting it to the controller” as the launch method.
  • Save the configuration and click on the newly created node to launch the connection.

To activate the connection run the agent command line

The connection progress through SSH is shown below

Now verify the connection between the jenkins Master and jenkins node. If the node is online and connected, you can start running builds on the GCP instance.

Here, as shown above the the gcp node connection is successfully established.

Note: You will need to ensure that the necessary ports are open and that the security settings on both the AWS and GCP instances allow traffic to pass between them. Additionally, you may need to configure any necessary firewall rules.

Conclusion-

By creating a VPC, you can isolate your resources and have complete control over the network configuration. This ensures that your resources are secure and only accessible to authorized users. Additionally, VPCs offer high scalability and can easily accommodate changes to your infrastructure. In this case, we used the Jenkins node on GCP to build CI/CD pipelines with GCR.

In case you have any questions regarding this article, please feel free to comment in the comments section or contact me via LinkedIn.

I’d like to give a shout-out to my team at Guysinthecloud for all the support.

Thank You

--

--