My e-Notes about DataScience, Machine Learning, Python, Data Analytics, DataStage, DWH and ETL Concepts

Breaking

Monday, 11 January 2021

Step by Step Google Kubernetes Engine (GKE) - II

Continuing from last post STEP BY STEP GOOGLE KUBERNETES ENGINE (GKE) - I 
where have created a cluster "cluster-1", in this post, we will connect with GKE cluster from local machine and do some work. 

Connect from Local Machine: Though GKE provides multiple ways to connect to the cluster, today we are ahead with the easiest way. For that, you need to install gcloud SDK in your local machine which you can follow from here - Installing Google Cloud SDK , Google has pretty neat documentation for all OS types. Once the installation is done, Open the SDK shell and run the below command - 

gcloud auth login

This command will open your Gmail account in the browser window where you have to provide your credentials to access the GKE cluster. Remember you have to provide the same credentials which have created the GKE cluster.  

Now, you can run all the commands from the local machine whatever you can run from gcloud inbuili shell. But I prefer to use inbuilt cloud shell as it supports the linux command. Anyway, Use whatever suits you better. 

I am assuming you are using local Cloud Shell, In my case, It is Windows, Beware of the commands as variable declaration and usage are differ from OS to OS. 

Windows Client:
gcloud projects list
set PROJECT=gkelearn-123
gcloud config set project %PROJECT%
gcloud container clusters list

Linux Client:
gcloud projects list
export PROJECT=gkelearn-123
gcloud config set project $PROJECT
gcloud container clusters list

In the last post, we have scaled-down the GKS cluster cluster-1 to 0 which we can resize to default 3. 

kubectl get nodes
gcloud container clusters resize cluster-1 --num-nodes=0 --zone=us-central1-c

Now, I am moving to cloud shell cli :-) 
So now, Let's deploy a small application on our GKE cluster - 

kubectl run hello-server --image gcr.io/google-samples/node-hello:1.0 --port 8080
kubectl create svc loadbalancer hello-server --tcp=80:8080 
kubectl get svc
curl <External IP>:80








Your first Kubernets App is up and Running, Congratulations. Now, there are lots of things to do which we will cover one by one. Till then... Happy Learning !! 



Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Telegram Group



No comments:

Post a comment

Disclaimer

The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.