Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "gcloud container clusters" and "kubectl" commands when using them to provision K8S cluster on GCP?

I see 2 commands which can operate K8S cluster on GCP. One is gcloud container clusters and the other is kubectl.

Can anyone tell me what is the difference between them?

like image 344
David Tong Avatar asked Nov 02 '19 18:11

David Tong


1 Answers

The main difference is that the gcloud container clusters command is primarily used for managing the allocation of resources for the cluster itself. E.g. it tells the Google Cloud Platform how to create, modify, and destroy the clusters supporting it. (Also important here are the gcloud container node-pools and gcloud container operations and gcloud container subnets commands).

It also has a key command: gcloud container clusters get-credentials which gives you the credentials you need to run the second command, kubectl.

kubectl, on the other hand, is the Kubernetes control command. It is used by all Kubernetes clusters, regardless of if they are on GCP, some other cloud provider, or manually set up on your own local hardware. It is primarily used for the manipulation of workloads (e.g. Pods, Deployments, StatefulSets, CronJobs etc) of the cluster itself, along with other configuration data (e.g. ConfigMaps, Secrets). It also allows for Kubernetes-native a administration of the cluster itself (e.g. granting cluster based roles to users, creating namespaces, etc).

Essentially, gcloud gives you the ability to provision and deprovision resources, whereas kubectl gives you the ability to use the clusters once provisioned.

More information:

  • gcloud container clusters reference and GKE Documentation.
  • kubectl reference and overview
like image 103
robsiemb Avatar answered Sep 21 '22 21:09

robsiemb