Creating GKE cluster using command line

- 1 min

This post is guide for creating a kubernetes cluster in a GCP project.

  1. Enable the Kubernetes Engine API for your GCP project from https://console.cloud.google.com

  2. Install the Google Cloud SDK which includes gcloud command line tools.

  3. Install kubectl which is a command line tool for controlling Kubernetes clusters. To install it as part of the Google Cloud SDK, use:

    gcloud components install kubectl
    

    otherwise, visit https://kubernetes.io/docs/tasks/tools/install-kubectl/

  4. Set default GCP project:

    gcloud config set project <YOUR-GCP-PROJECT-ID>
    
  5. Set default compute zone:

    gcloud config set compute/zone <COMPUTE-ZONE>
    
  6. Create a 3 node cluster with n1-standard-1 machine type:

    gcloud container clusters create <CLUSTER-NAME> \
       --num-nodes=3 \
       --machine-type=n1-standard-1 
    
  7. Get authentication credentials for the cluster to configure kubectl to use the created cluster:

    gcloud container clusters get-credentials <CLUSTER-NAME>
    
  8. Check if cluster is initialized:

    kubectl get node
    

    You will see output something like:

    NAME                                         STATUS   ROLES    AGE   VERSION
    gke-dev-cluster-default-pool-8206a99e-0shr   Ready    <none>   16h   v1.13.11-gke.23
    gke-dev-cluster-default-pool-8206a99e-d9f6   Ready    <none>   16h   v1.13.11-gke.23
    gke-dev-cluster-default-pool-8206a99e-fcfk   Ready    <none>   16h   v1.13.11-gke.23
    
Prashant Anand

Prashant Anand

Machine Learning Engineer

rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora googlescholar