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

11/2/2019

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?

-- David Tong
google-cloud-platform
google-cloud-sdk
google-kubernetes-engine

1 Answer

11/2/2019

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 Kubernets-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:

-- robsiemb
Source: StackOverflow