You can set up a Kubernetes cluster on GKE using the gcloud command. This needs to specify several parameters to determine some configurations. One important parameter is the network. Here, you have to specify which VPC and subnet you'll deploy. Although GKE supports multiple zones to deploy, you need to specify at least one zone for the Kubernetes master node. This time, it uses the following parameters to launch a GKE cluster:
Parameter |
Description |
Value |
--machine-type |
VM instance type for Kubernetes Node |
f1-micro |
--num-nodes |
Initial number of Kubernetes nodes |
3 |
--network |
Specify GCP VPC |
my-custom-network |
--subnetwork |
Specify GCP Subnet if VPC is a custom mode |
subnet-c |
--zone |
Specify a single zone |
asia-northeast1-a |
--tags |
Network tags that will be assigned to Kubernetes nodes |
private |
In this scenario, you need to type the following commands to launch a Kubernetes cluster on GCP. It may take a few minutes to complete because, behind the scenes, it'll launch several VM instances and set up the Kubernetes master and nodes. Note that the Kubernetes master and etcd will be fully managed by GCP. This means that the master node and etcd don't consume your VM instances:
$ gcloud container clusters create my-k8s-cluster --machine-type f1-micro --num-nodes 3 --network my-custom-network --subnetwork subnet-c --zone asia-northeast1-a --tags private
//after a few minutes, check node status
NAME STATUS ROLES AGE VERSION
gke-my-k8s-cluster-default-pool-bcae4a66-mlhw Ready <none> 2m v1.10.9-gke.5
gke-my-k8s-cluster-default-pool-bcae4a66-tn74 Ready <none> 2m v1.10.9-gke.5
gke-my-k8s-cluster-default-pool-bcae4a66-w5l6 Ready <none> 2m v1.10.9-gke.5
Note that we specify the --tags private option so that a Kubernetes node VM instance has a network tag of private. Therefore, it behaves the same as other regular VM instances that have private tags. Consequently, you can't SSH from the public internet and you can't HTTP from the internet either. However, you can ping and SSH from another VM instance that has a public network tag.