Google Kubernetes Engine (also known as GKE) is a managed, production-ready environment for running Docker containers in the Google cloud.
It allows you to create multiple-node clusters while also providing access to all Kubernetes features.
Create A Kubernetes Cluster using GCP console
Login into GCP console with your Gmail account. By default, it will create a project “My Project” for you. It is mandatory to complete the billing verification to use GCP services. Once Billing account verified you can use all services with $300 credit.
1. Click on left side menu bar, scroll down and click on Kubernetes Engine.
2. In the clusters page, Click on “Create cluster“
3. In the next page, choose cluster type and modify the details as per your requirement and click on the “Create” button. It will take 2 to 3 mins to create a cluster for you.
4. Once the cluster is created, click on the “connect” button. It will give you a command to run on a cloud shell. Copy the command and run in the cloud shell.
5. Kubectl is available in the cloud shell by default. To check the nodes, run the “kubectl get nodes” command in the cloud shell.
Now, you can deploy your containerized application on Google Kubernetes Engine.
Create a cluster using gcloud CLI commands
Connect to cloud shell using the cloud shell button and click on the new window icon to open in the new tab.
Step 1: Set the region to launch cluster nodes
$ gcloud config set compute/zone us-east1-b
Step 2: Create a network for your cluster, or you can use the default network.
$ gcloud compute networks create my-cluster-network
Step 3: Create a cluster with the required configuration
$ gcloud container clusters create my-cluster \ --enable-cloud-logging \ --enable-cloud-monitoring \ --num-nodes 3 \ --disk-size 30G \ --network my-cluster-network
The above command will create a new cluster for you.
Step 4: Get credentials for your cluster. Kubernetes Engine uses these credentials to access your newly provisioned cluster.
$ gcloud container clusters get-credentials my-cluster
Now check with kubectl
$ kubectl get nodes NAME STATUS ROLES AGE VERSION gke-my-cluster-default-pool-2d75839c-f1h3 Ready 5m v1.11.6-gke.2 gke-my-cluster-default-pool-2d75839c-m3j7 Ready 5m v1.11.6-gke.2 gke-my-cluster-default-pool-2d75839c-vx44 Ready 5m v1.11.6-gke.2
To delete the cluster, run the following command :
$ gcloud container clusters delete my-cluster
You can also delete the cluster from the console as well.