Creating a Kubernetes Cluster

This page shows how to run Kubernetes on Google Kubernetes Engine (GKE)

Installing Google Cloud SDK

To install gcloud and kubectl, perform the following steps:

  1. Install the Cloud SDK, which includes the gcloud command-line tool.

  2. Install the kubectl command-line tool

$ gcloud components install kubectl

Configure default settings

Here we set the project id that will be the home for our Kubernetes nodes and the primary geographic zone for the cluster.

PROJECT_ID=beaconchain

CLUSTER_NAME=cardano
CLUSTER_ZONE=us-central1-a

# Setting a default project ID
$ gcloud config set project $PROJECT_ID

# Setting a default compute zone or region
$ gcloud config set compute/zone $CLUSTER_ZONE

Creating a GKE cluster

Lets create a single zone cluster with two medium size nodes.

$ gcloud container clusters create $CLUSTER_NAME \
  --disk-size=32GB \
  --machine-type=e2-medium \
  --node-locations=$CLUSTER_ZONE \
  --zone=$CLUSTER_ZONE \
  --num-nodes=2

Creating cluster cardano in us-central1-a... Cluster is being health-checked (master is healthy)...done.                                                           

NAME     LOCATION       MASTER_VERSION    MASTER_IP       MACHINE_TYPE  NODE_VERSION      NUM_NODES  STATUS
cardano  us-central1-a  1.18.12-gke.1210  34.123.140.191  e2-medium     1.18.12-gke.1210  2          RUNNING

Great, to install Kubernetes on two nodes and network them together to form a cluster took about 1min.

Get credentials for the cluster

$ gcloud container clusters get-credentials $CLUSTER_NAME

Fetching cluster endpoint and auth data.
kubeconfig entry generated for cardano.

We should now be able to use the kubectl command

$ kubectl cluster-info

Kubernetes master is running at https://34.123.140.191
GLBCDefaultBackend is running at https://34.123.140.191/api/v1/namespaces/kube-system/services/default-http-backend:http/proxy
KubeDNS is running at https://34.123.140.191/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://34.123.140.191/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy

Last updated