Google Cloud Associate Certified Engineer — 100daysoflearning (Part 15)

Saiyam Pathak
100daysoflearning
Published in
4 min readMay 2, 2019

DAY 100

In continuation to the course for Google Cloud Associate Certified engineer lets move on with next set of learning topics.

In this section I will discuss about managing Google Kubernetes Engine using gcloud container clusters commands and the kubectl command.

Managing Google Kubernetes Engine: After provisioning of the cluster you can scale up or down based on the need from the UI as well as from the Google cloud sdk . Lets see both of them in action .

First creating of the cluster is simple , more focus here is on managing the cluster so to simply create a cluster run the following command :
gcloud container clusters create saiyamgke — zone us-central1b

Cluster Created

Lets scale the cluster from the UI first: will change the cluster size from 3 to 2

edit and save

you will be able to see the cluster size changing , it will take some time.

resizing the cluster

Now lets resize the cluster from 2 to 1 from the gcloud command:
gcloud container clusters resize saisal --num-nodes=1 --zone us-central1-b

resizing the cluster done

Kubectl commands: For resizing or interacting with the cluster resources we use the gcloud container clusters command but for interacting with the its resources we use the kubectl command (I pronounce it as kube control) . In order to setup kubectl for the cluster, click on connect and copy the gcloud commend that will generate the kubeconfig file so that when you run kubectl command it knows which cluster to send the request to .

copy and run the above command

Lets see few of the kubectl commands.

Command : kubectl get nodes : to get the nodes from the cluster

Command: kubectl describe node<nodename> : gives the detailed information about the node like its label , annotation, conditions, cpu usage, memory , kubernetes version , namespace and its pods etc

Command: kubectl get pods : gives the list of pods in default namespace

Command: kubectl get pods — all-namespaces : gives the list of pods in all namespaces.

Commands: kubectl describe pods <podname> : gives the detailed info about the pods like its port, volumes attached, node, ip address etc.

Command: kubectl run nginx — image=nginx this is the command to create a pod and when a pod is created its deployment gets created automatically . if you try to delete a pod now it will again spin it up until you delete its deployment as the deployment defines the current and desired state means if the pod gets deleted then the cluster will spin up the pod again to meet the desired state of the deployment. But in the latest version this command will be deprecated and you will have to use the following command to create a pod and this command will not create any deployment automatically.
kubectl run sam --image=ubuntu --generator=run-pod/v1

So in this article you learnt about managing kubernetes cluster using the gcloud container clusters commands and how to interact with the resources of the cluster using the kubectl commands.

Happy Learning & Happy Coding
Saiyam Pathak
https://www.linkedin.com/in/saiyam-pathak-97685a64/
https://twitter.com/SaiyamPathak

--

--

Saiyam Pathak
100daysoflearning

l CNCF Ambassador | CKA | CKAD | Influx ACE | Multi-cloud certified | Rancher Ranch Hands member