GKE Clusters #
In Google Kubernetes Engine, a cluster consists of at least one cluster master and multiple worker machines called nodes. These master and node machines run the Kubernetes cluster orchestration system.
GKE Cluster Types #
Zonal clusters
A zonal cluster runs in one or more compute zones within a region. A multi-zone cluster runs its nodes across two or more compute zones within a single region. Zonal clusters run a single cluster master.
- Single Zone Clusters
gcloud container clusters create [CLUSTER_NAME] [--zone [COMPUTE_ZONE]]
- Multiple Zone Clusters
gcloud container clusters create [CLUSTER_NAME] \
--zone [COMPUTE_ZONE] \
--node-locations [COMPUTE_ZONE],[COMPUTE_ZONE],...]`
- For Example:
gcloud container clusters create demo-zonal-cluster --zone asia-southeast1-a \
--node-locations asia-southeast1-a,asia-southeast1-b, --num-nodes 2 \
--enable-autoupgrade --enable-autorepair \
--enable-cloud-logging --enable-cloud-monitoring
Regional cluster
A regional cluster runs three cluster masters across three compute zones, and runs nodes in two or more compute zones.
gcloud container clusters create [CLUSTER_NAME] --region [REGION] \
[--node-locations [COMPUTE_ZONE],[COMPUTE_ZONE]...]]
- For Example:
gcloud container clusters create demo-regional-cluster --region asia-southeast1 \
--node-locations asia-southeast1-b,asia-southeast1-c --num-nodes 2 \
--enable-autoupgrade --enable-autorepair \
--enable-cloud-logging --enable-cloud-monitoring
Private cluster
A private cluster is a zonal or regional cluster which hides its cluster master and nodes from the public Internet by default.
gcloud container clusters create private-cluster-0 \
--create-subnetwork name=my-subnet-0 \
--enable-master-authorized-networks \
--enable-ip-alias \
--enable-private-nodes \
--master-ipv4-cidr 172.16.0.0/28 \
--no-enable-basic-auth \
--no-issue-client-certificate
Public endpoint access disabled
--enable-ip-alias
--enable-private-nodes
--enable-private-endpoint
--enable-master-authorized-networks
Public endpoint access enabled,master authorized networks enabled
--enable-ip-alias
--enable-private-nodes
--enable-master-authorized-networks
Public endpoint access enabled,master authorized networks disabled
--enable-ip-alias
--enable-private-nodes
--no-enable-master-authorized-networks
Alpha cluster
An alpha cluster is an experimental zonal or regional cluster that runs with alpha Kubernetes features enabled. Alpha clusters expire after 30 days and are not recommended for production use.
gcloud container clusters create [CLUSTER_NAME] \
--enable-kubernetes-alpha [--zone [COMPUTE_ZONE]]
[--cluster-version [VERSION]]
Node Pools #
A node pool is simply a collection, or “pool,” of machines with the same configuration. Now instead of a uniform cluster where all the nodes are the same, you can have multiple node pools that better suit your needs. Imagine you created a cluster composed of n1-standard-2 machines, and realize that you need more CPU. You can now easily add a node pool to your existing cluster composed of n1-standard-4 (or bigger) machines
Adding a Node pool
gcloud container node-pools create [POOL_NAME] --cluster [CLUSTER_NAME]
Viewing node pools in a cluster
gcloud container node-pools list --cluster [CLUSTER_NAME]
Resizing a node pool
gcloud container clusters resize [CLUSTER_NAME] --node-pool [NODE_POOL] \ --size [SIZE]
Upgrading a node pool
gcloud container clusters upgrade [CLUSTER_NAME] --node-pool [POOL_NAME]
Deleting a node pool
gcloud container node-pools delete [POOL_NAME] --cluster [CLUSTER_NAME]