Day 29- Google Kubernetes Engine (GKE)

Day 29- Google Kubernetes Engine (GKE)

Welcome to Day 29 of #30DaysOfKubernetes! 🚀

Today, let’s unravel the wonders of GKE — Google Kubernetes Engine. 🌐✨

What is GKE?

GKE stands for Google Kubernetes Engine which is a managed Kubernetes service to deploy your application easily without worrying about Control Plane, Scaling, or updating to your Kubernetes Cluster.

One of the main advantages of GKE is that Kubernetes is developed by Google itself.

Features:

  1. Multi-Versions: GKE has the most available versions as Kubernetes developed Google itself.
  2. Auto Upgrades: The Control Plane and nodes will be automatically updated.
  3. Auto Health Repair: GKE provides automatic health repair for the nodes.
  4. Security Enhancement: GKE provides Containerized Optimised OS which will help you to enhance the security of your nodes.
  5. Monitoring: GKE provides monitoring support by integrating the monitoring services with GKE itself.
  6. Scalability: GKE provides scalability to your Kubernetes Clusters and Nodes according to the requirements.
  7. Multi-Cloud Support: You can run your applications anywhere without interruption using GKE on Google GKE, Azure AKS, or AWS EKS.

GKE Architecture- Source Google itself

Let’s Dive into the Demo! 🛠️

If you have never created Kubernetes Cluster on Google Cloud before then, you have to enable it first to use it.

Click on Enable.

Click on CREATE

Now, we will create the Standard Kubernetes Cluster. To do that, click on SWITCH TO STANDARD CLUSTER.

Provide the name to your cluster name and select the location type according to your credits remaining in the Google Cloud. Also, specify the node locations and click to expand default-pool which is showing on the left.

Select the configuration as given in the below screenshot to reduce some costs.

Provide the Root disk size of 15 GB because it will be sufficient according to our demonstration.

Click on the Networking and provide configurations as given below.

We don’t need to modify anything in Security and other things. So you can skip it and click on CREATE.

After clicking on CREATE. GCP will take some time to create the Kubernetes Cluster.

Once your Kubernetes Cluster is ready, then click on CONNECT.

You will get a command to configure it on your local machine. But there are two prerequisites that you have to follow which first is to configure gcloud-cli and install kubectl on your local machine. Let’s do this.

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg curl sudo
curl packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg - dearmor -o /usr/share/keyrings/cloud.google.gpg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

Update your local machine and install Google Cloud cli

sudo apt-get update && sudo apt-get install google-cloud-cli

After installing gcloud cli, now we have to configure it with our account. To do that, run the below command and it will open your browser and select your main GCP account.

gcloud init

Now, you need one plugin to complete the configuration.

gcloud components install gke-gcloud-auth-plugin

After configuring Google Cloud CLI our first prerequisite is completed.
Now, we have to install kubectl which is mandatory to perform the commands on the Google Kubernetes Cluster.

To install kubectl on your local machine follow the below commands.

curl -O s3.us-west-2.amazonaws.com/amazon-eks/1.28...

curl -O s3.us-west-2.amazonaws.com/amazon-eks/1.28...

sha256sum -c kubectl.sha256

openssl sha1 -sha256 kubectl

chmod +x ./kubectl
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$HOME/bin:$PATH
echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc

kubectl version --client

Now, copy the command that is given by GCP to connect to the Kubernetes Cluster and paste it into your local machine.

To validate whether your cluster is working or not, list the nodes.

kubectl get nodes

Now, let’s try to run the static application on nginx server with a GCP load balancer

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-app-deployment
labels:
app: nginx-app
spec:
replicas: 2
selector:
matchLabels:
app: nginx-app
template:
metadata:
labels:
app: nginx-app
spec:
containers:
- name: nginx-container
image: avian19/nginx-ne:latest-1.0
ports:
- containerPort: 80

kubectl apply -f deployment.yml

Now, host the application outside of the Kubernetes Cluster by creating a service for the nginx application and observe the Public IP in the EXTERNAL-IP Column.

apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
selector:
app: nginx-app
type: LoadBalancer
ports:
- protocol: TCP
port: 80

kubectl apply -f svc.yaml

Copy the Public IP and paste it into your favorite browser and see the magic.

You can also decrease the number of nodes that are running in the below screenshot.

After going to the Cluster, click on default-pool which is showing under Node Pools.

Click on edit

Replace 3 with the 1 to reduce the nodes then scroll down and click on Save.

Once you Save the configurations, then you will see the VM Instances will be deleted.

Don’t worry your application will still running

Conclusion

GKE, the brainchild of Google, simplifies Kubernetes management, ensuring a smooth sail for your applications. Leverage its robust features and multi-cloud support to take your container orchestration to new heights! 🚢💻

Want to Know About Challenge?

If you’re eager to learn more and join our challenge through the GitHub Repository, stay tuned for the upcoming posts. Follow for more exciting insights into the world of Kubernetes!

GitHub Repository: https://github.com/AmanPathak-DevOps/30DaysOfKubernetes

#Kubernetes #DaemonSet #StatefulSets #NetworkPolicy #Operators #ContainerOrchestration #DevOps #GKE #Google #GoogleCloud #K8sLearning

See you on Day 30 as we unravel more Kubernetes mysteries!

Stay connected on LinkedIn: LinkedIn Profile

Stay up-to-date with GitHub: GitHub Profile

Feel free to reach out to me, if you have any other queries.

Happy Learning