Google Kubernetes Engine (GKE) is the simplest and most common way of setting up a Kubernetes Cluster. You may be able to receive free credits for trying it out (though note that a free account comes with limitations). Either way, you will need to connect your credit card or other payment method to your google cloud account.
Note: Consider setting a cloud budget for your Google Cloud account in order to make sure you don’t accidentally spend more than you wish to.
Install gcloud CLI, kubectl
In this section, Install the required CLI’s in your local machine which will be used to connect to GKE clusters once deployed.
- Download and install the
gcloudcommand line tool at its install page. It will help you create and communicate with a Kubernetes cluster.
- Install kubectl (reads kube control), it is a tool for controlling Kubernetes clusters in general or using command:
- Go to console.cloud.google.com and log in.
- Navigate Kubernetes Engine API and enable the same
- GKE clusters can be created from cloud console or via terminal. In this demo, I will cover the steps to deploy the cluster through cloud console and terminal (computer terminal)
Create GKE cluster through console
- In Google cloud console, navigate to Compute > Kubernetes Engine > Clusters
- Click on CREATE
- You will be asked to select between GKE Standard and GKE Autopilot, for this demo I will go with GKE Standard – Configure
- Cluster basics:
- Name: Give a Name
- Location type: select Zonal or Regional, # I have selected Zonal in order to specify exact zone
- Control Plane version: Leave to default
- Node Pools
- Name: Give node pool a name
- Size: Num of nodes # These are total num of vm instances to be deployed
- Nodes: You can change the Series, Machine type, Boot disk type, Boot disk size, Max Pods per node
- Security: You can leave to default service account or select from drop down
- Metadata: Leave to default
- Cluster: You can leave to default, unless something to be changed
- click on CREATE
- Once the cluster is created and status turns green, click on the cluster > connect > command-line access
- Copy the command and execute in your local machine
Create GKE cluster through terminal
Note: This section is optional if you also want to deploy GKE cluster using terminal. If you have already deployed a cluster through console then jump to next section to deploy a test application.
<CLUSTERNAME>with a name that can be used to refer to this cluster in the future.
--machine-typespecifies the amount of CPU and RAM in each node within this default node pool. There is a variety of types to choose from.
--num-nodesspecifies how many nodes to spin up. You can change this later through the cloud console or using the
gcloudcommand line tool.
--zonespecifies the data center zone where your cluster will be created. You can pick something from this list that is not too far away from your users.
- A region in GCP is a geographical region with at least three zones, where each zone is representing a datacenter with servers etc.
- A regional cluster creates pods across zones in a region(three by default), distributing Kubernetes resources across multiple zones in the region. This is different from the default cluster, which has all its resources within a single zone(as shown above).
- A regional cluster has Highly Available (HA) kubernetes api-servers, this allows jupyterhub which uses them to have no downtime during upgrades of kubernetes itself.
- They also increase control plane uptime to 99.95%.
- To avoid tripling the number of nodes while still having HA kubernetes, the
--node-locationsflag can be used to specify a single zone to use.
Deploy an application
- In this demo, I will be using the images stored in gcr.io (google container registry).
- Access the external ip from browser: