How to deploy a Kubernetes cluster using gcloud command

Find out how to deploy a Kubernetes cluster to the Google Cloud Platform using the gcloud command.

If your cloud solution runs through the Google Cloud Platform and you happen to prefer managing everything from the command line, you might have installed the Google Cloud SDK on Linux. This software development kit includes the gcloud command, which allows you to interact with your Google Cloud Platform account. 

By way of that interaction, you can deploy a complete Kubernetes cluster. And that’s exactly what I’m going to show you. 

SEE: Hybrid cloud: A guide for IT pros (TechRepublic download)

What you’ll need

The only things you’ll need to make this work are:

  • A Google Cloud Platform account
  • The Google Cloud SDK installed on a Linux machine

Some terms

Before we get to the commands, there are a few terms to understand.

  • Compute zones are locations within a region. For example, you can deploy in us-east1, us-east1-b, us-east1-c, or us-east1-d. For a complete list of zones, see this page. 
  • Types of clusters: Zonal clusters run in one or more compute zones within a region. Regional clusters run three cluster masters across three compute zones and runs nodes in two or more compute zones. Private clusters are either a zonal or regional cluster which hides both master and nodes from the public. Alpha clusters are an experimental zonal or regional cluster that run with Kubernetes alpha features enabled.
  • Cluster templates are templates that make deploying clusters easier. You can select from standard cluster, Your First Cluster, CPU-Intensive applications, Memory-Intensive applications, GPU Accelerated Computing, and Highly Available. 

How to deploy your first cluster

We’re going to deploy a zonal cluster (in us-central1-a) using the Standard template, which is the default. The command for this would be:

gcloud container clusters create NAME --zone us-central1-a

Where NAME is a lower case, human-readable name for the cluster. You may or may not see warnings as the cluster is being deployed (Figure A).

Figure A

Our cluster is being deployed.

When the command completes, it will report to you that the cluster has been created and include information like the master IP, machine type, and more (Figure B)

Figure B

The cluster has been deployed.

There are, of course, a very large number of options that can be used with the gcloud command such as –additional-zones, –default-max-pods-per-node, –disk-size, –node-locations, –enable-autoscaling, and much more. For a complete list of options, take a look at the clusters create information page. 

How to delete a cluster

You might have deployed a cluster for testing purposes or have no need for a particular cluster. If that’s the case, you can always delete a cluster with the command:

gcloud container clusters delete NAME --zone ZONE

Where NAME is the name of the deployed cluster and ZONE is the name of the zone.

If you’re not sure of the cluster name, issue the command:

gcloud container clusters list

The above command will list out all clusters you have deployed (Figure C).

Figure C

Our cluster list.

Upon issuing the command, you must confirm the deletion (Figure D).

Figure D


The action will take some time. Once the action completes, your cluster is gone and you can start all over, if necessary.

And that’s the gist of deploying a cluster using the gcloud command.

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x