Introduction
This article will try to set up our first GKE cluster. We would also deploy .NET 6 service to GKE. In the end, we would explore Kubernetes features and deployments.
Prerequisites
Build custom images using Docker and Deploy them to the Google container registry.
https://www.c-sharpcorner.com/article/how-to-create-docker-image-of-net-6-workloads-and-push-it-to-google-container-r/
In this article, we will cover the following topics:
- What is GKE and its features
- Set up GKE cluster standard mode
- Create a deployment and expose it as a service.
Step 1. What is Google Kubernetes Engine
Kubernetes is the most popular open-source container orchestration service, and the Google Kubernetes Engine is a fully managed service offered by the Google Cloud platform.
Features
- Cluster management
- Auto Scaling
- Service Discovery
- Self-healing
- Zero downtime deployment
GKE Features
- Minimize operations with auto repair and Auto Upgrade
- POD and cluster auto-scaling
- It easily integrates with Cloud logging and cloud monitoring.
- Uses container optimized OS Hardened OS built by Google.
Step 2. Create your first GKE Cluster
Search for Google Kubernetes Engine and enable GKE API
Click on Create Cluster. The below screen would Pop up. Cluster creation experience varies over a period of time.
Auto Pilot is a new mode where GKE manages node. It helps to save on operational costs. In this article, we will create a cluster with standard mode.
Specify the cluster name and select the default configuration for your cluster.
The cluster is up and running.
Step 3. Create a Deployment and a service
The default configuration creates a cluster with 3 Nodes, 6 vCPUS, and 12 GB Memory.
Connect to GKE Cluster
gcloud container clusters get-credentials gkedev --zone us-central1-c --project buildcustomimage
Create a Deployment
We have already built custom image and deployed them to the Google container registry
https://www.c-sharpcorner.com/article/how-to-create-docker-image-of-net-6-workloads-and-push-it-to-google-container-r/
kubectl create deployment gkenetservice --image gcr.io/buildcustomimage/custom-image:0.1
Get Deployments
kubectl get deployments
Expose Deployments as Services
kubectl expose deployment gkenetservice --type=LoadBalancer --port=8080 --target-port=80
The container is exposed on port 80
Exposing a Deployment would create service. In this example, we have exposed deployment as Load Balancer Service on port 8080.
Get Services
kubectl get services
In the browser window, type 35;232;168.66:8080, and the application should be accessible.
Summary
In this article, we have learned how to work with GKE.
In the upcoming articles, we will explore Google Cloud Functions and Cloud build.
Thanks a lot for reading. I hope you liked this article. Please share your valuable suggestions and feedback. Write in the comment box in case you have any questions. Have a good day!