Practicing with Google Cloud Platform - Google Kubernetes Engine to deploy nginx
Introduction
This article provides simple step-by-step instructions for those who are new to Google Cloud Platform (GCP) and Google Kubernetes Engine (GKE).
I'll guide you through using GKE to create clusters and deploy nginx.
The instructions below will primarily use gcloud and kubectl to initialize the cluster, which is more convenient than manual management on the Google Cloud interface.
Prerequisites
First, you need to prepare the following:
- Have a GCP account with permission to use Cloud services. If you're new, you'll get a $300 free trial to use for 90 days.
- Create a new GCP project.
- Enable Compute Engine and Kubernetes Engine services.
Install Google Cloud SDK and kubectl
For this installation step, refer to the GCP documentation for instructions tailored to your operating system.
Once installed, execute the following commands to check if gcloud and kubectl are installed:
If you see the version result, we'll proceed to the next part.
Initialize Google Cloud SDK authentication
Please execute the following command to configure Google Cloud:
Next, you'll follow the instructions to log in with your Google Cloud account. Then, you'll be prompted to configure the default Compute Region and Zone. It's important to note that different regions have different pricing for machine types. You can check the prices on the Create VM instance UI. However, you should still choose the region that best suits your needs to ensure the best network speed.
Google Cloud Console |
Creating GKE Cluster
To create a GKE Cluster, simply execute the following command:
If you want to specify specific details for the cluster, use the following command:
Here, I'm using the machine type e2-micro, which has a simple configuration and a relatively cheap price, sufficient for you to follow along with this article.
After successfully initializing the cluster, execute the following command to list the instances currently available:
Use kubectl to deploy nginx
Execute the following command to deploy nginx using a Docker image:
Deploy service |
To check the pods currently available, execute the following command:
Next, I'll create a LoadBalancer Service to access the Pod from outside the Cluster as follows:
Expose service |
To check the LoadBalancer service, use the following command:
Service info |
If you run this command too early, the EXTERNAL-IP column will be <pending>. Please wait a few minutes until you see an IP address in the EXTERNAL-IP column to access it. The result will be as follows:
Nginx has been successfully deployed |
Cleaning Up Resources
After completing the steps outlined in the article to avoid any unwanted costs, delete the resources and services as follows:
Result after deleted service |
To check if the resources and services have been deleted, you can use the commands I provided earlier or directly check on the Google Cloud Console.
Nice blog, Thanks For Sharing This Informative Article.
ReplyDeleteBest Google Cloud Data Engineer Training
Google Cloud Data Engineer Online Course