Google Cloud

How to Create & Deploy Kubernetes Engine in GCP

Hello Friends in this article i am gone to share How to Create & Deploy Kubernetes Engine in GCP with you..


Also visit:ย  How to Host Static Website on Google Cloud


 

How to Create & Deploy Kubernetes Engine in GCP

Follow these steps:

Task 1) Login & setup zone.

1) Login to your Google Cloud platform ( GCP ) Account. if you Not Have Create First.
2) After Login to your account open Cloud Shell and Setup your zone.

Note: our compute zone is an approximate regional location in which your clusters and their resources live. For example, us-central1-a is a zone in the us-central1 region</i >.

 

Copy this..

gcloud config set compute/zone us-central1-a

Task 2) Create a GKE cluster

1) A cluster consists of at least one cluster master machine and multiple worker machines called nodes. Nodes are Compute Engine virtual machine (VM) instances that run the Kubernetes processes necessary to make them part of the cluster.
Note: Cluster names must start with a letter and end with an alphanumeric, and cannot be longer than 40 characters</i >.

2) To create a cluster, run the following command, replacing [CLUSTER-NAME] with the name you choose for the cluster (for example:my-cluster).

Copy this..
gcloud container clusters create [CLUSTER-NAME]
  • You can ignore any warnings in the output.
  • Wait minutes to finish creating the cluster.
  • Check progress to verify the cluster is created successfullyย  or not.

Task 3) Authentication credentials for the cluster

After creating your cluster, you need authentication credentials to interact with it.
To authenticate the cluster, run the following command, replacing [CLUSTER-NAME] with the name of your cluster:

Copy this..

gcloud container clusters get-credentials [CLUSTER-NAME]

 

Task 4) Deploy an application

  • You can now deploy a containerized application to the cluster. For this lab, you’ll run hello-app in your cluster.
  • GKE uses Kubernetes objects to create and manage your cluster’s resources. Kubernetes provides the Deployment object for deploying stateless applications like web servers. Service objects define rules and load balancing for accessing your application from the internet.

 

1) To create a new Deployment hello-server from the hello-app container image, run the following kubectl create command:

Copy this..
kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:1.0

2) To create a Kubernetes Service, which is a Kubernetes resource that lets you expose your application to external traffic, run the following kubectl expose command:

Copy this..

kubectl expose deployment hello-server --type=LoadBalancer --port 8080

 

3) To inspect the hello-server Service, run kubectl get:
Copy this..
kubectl get service
4) Copy your IP and open in new Tab.
  • http://[EXTERNAL-IP]:8080

output:

Task 5: Deleting the cluster

To delete the cluster, run the following command:

Copy this..
gcloud container clusters delete [CLUSTER-NAME]

 

Note: When prompted, type Y to confirm.

  • Deleting the cluster can take a few minutes.
  • Check my progress

Congratulations:ย  you successfully Created or Deploy Kubernetes Engine in Google Cloud platform.