Containerization tools

Containerization has become a significant pattern in software improvement as another option or ally to virtualization. It includes typifying or bundling up software code and every one of its…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Kubernetes Engine And Terraform In Google Cloud

Basics on deploying your application in a regional Google Kubernetes Engine (GKE) Cluster using Terraform.

This is part 3 of my series on containers. Visit parts 1-2, and see how I built the app + the container we will be using today.

Part 1: Containerizing Your First Application

Part 2: Kubernetes In Google Cloud

To keep iterating in the subject of containers, today is all about automating the creation of all the required resources for our application followed by the deployment. All in a few commands.

Today the goal is to have a quick dive into Terraform, how a script works, and how services are tied together through a terraform script. Our task will be to:

Get the project from GitHub

Do not forget to point the Google SDK to the right project

Specifying a region instead of a zone makes the cluster regional.

The last bit of infrastructure we need is a Public IP for the load balancer. We can allow Kubernetes to take care of it, but I prefer to request and secure one myself.

In a nutshell, with the service, you specify how the app will be exposed to the world; in the deployment, you specify how pods will be managed, and what container image is going to be executed.

Here, the script is ready to create and deploy our application in one go. To make our life easy, I will add an output to get out App’s URL once everything is done deploying. Otherwise, you would have to go search for it within the public IP addresses.

Now that we finished analyzing the script, and we know what it is supposed to do - make sure to update the local variables to your desired region and project.

It is time to let terraform do its thing. Open the console in the same folder as main.tf and run:

If everything went as planned, you should get something like the following, otherwise, get yourself in debugging mode:

Here, let’s tell terraform to evaluate our desired configuration against what we currently have, It will come up with a plan on how to get to our desired state:

This will allow you to also see whats is going to happen to every service; Like existent services to recreate/modify.

Once we are happy with the plan:

After the creation of resources is done, Terraform will output the IP assigned to us, you can copy-paste it or use ctrl + left click if you are using VS Code.

I already disposed of this IP…

You will own this IP until you dispose of it. Even if you make changes to your infrastructure and run the apply. It is yours until you either run the destroy command or you remove it from your infrastructure.

Success!!

Let’s clean up our environment now.

For me, as a developer, the main advantage is being able to recreate the services in a few clicks, since I like to destroy and start from scratch very often.

This ability to reproduce an environment in a predictive way using just 2–3 commands can make me much more efficient when I want to quickly test something.

Add a comment

Related posts:

MATHEMATICS IN THE WAR

Both world Wars I and II are the deadliest and most costly skirmishes to ever happen on the globe. During these periods, we understand it was a gruesome period to the world as it led to the loss of…

The Happy End is not a Problem Anymore

The Happy End problem is a well-known mathematical problem that has been the subject of many studies in recent years. In this paper, we propose a new approach to the problem by analyzing it in the…

Embracing Generative AI to Drive Adoption for Digital Channels in Telcos

As the telco landscape continues to evolve, digital transformation is no longer a luxury but a necessity for companies looking to thrive. Generative AI offers a powerful toolset for…