Creating GKE cluster using command line
- 1 minThis post is guide for creating a kubernetes cluster in a GCP project.
-
Enable the Kubernetes Engine API for your GCP project from https://console.cloud.google.com
-
Install the Google Cloud SDK which includes gcloud command line tools.
-
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/
-
Set default GCP project:
gcloud config set project <YOUR-GCP-PROJECT-ID>
-
Set default compute zone:
gcloud config set compute/zone <COMPUTE-ZONE>
-
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
-
Get authentication credentials for the cluster to configure
kubectl
to use the created cluster:gcloud container clusters get-credentials <CLUSTER-NAME>
-
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