Cluster upgrades

Kubernetes is a fast-release project. GKE also keeps supporting new versions. It's not uncommon to have multiple minor version updates within a month. check the GKE console:

Upgrade available information in the GCP console

We see that an upgrade is available. 1.9.3-gke.1 in the screenshot has just been released and our cluster is able to upgrade:

Upgrade available to 1.9.3-gke.0

We can upgrade the cluster via the GKE console, or using gcloud command. We'll use the single zone (us-central1-a) cluster to demonstrate how to upgrade in the next example. When upgrading the cluster, the master is always the first citizen to do the upgrade. The desired node version cannot be greater than the current master version.

# gcloud container clusters upgrade my-k8s-cluster --zone us-central1-a --cluster-version 1.9.3-gke.0 –master
Master of cluster [my-k8s-cluster] will be upgraded from version
[1.9.2-gke.1] to version [1.9.3-gke.0]. This operation is long-running
and will block other operations on the cluster (including delete)
until it has run to completion.
Do you want to continue (Y/n)? y
Upgrading my-k8s-cluster...done.
Updated [https://container.googleapis.com/v1/projects/kubernetes-cookbook/zones/us-central1-a/clusters/my-k8s-cluster].

Let's check the master's version:

# kubectl version
...
Server Version: version.Info{Major:"1", Minor:"9+", GitVersion:"v1.9.3-gke.0", GitCommit:"a7b719f7d3463eb5431cf8a3caf5d485827b4210", GitTreeState:"clean", BuildDate:"2018-02-16T18:26:01Z", GoVersion:"go1.9.2b4", Compiler:"gc", Platform:"linux/amd64"}

Looks good. The master has been upgraded to v1.9.3-gke.0, but our nodes didn't get upgrade yet:

# kubectl get nodes
NAME STATUS ROLES AGE VERSION
gke-my-k8s-cluster-default-pool-978ca614-3jxx Ready <none> 8m v1.9.2-gke.1
gke-my-k8s-cluster-default-pool-978ca614-njrs Ready <none> 8m v1.9.2-gke.1
gke-my-k8s-cluster-default-pool-978ca614-xmlw Ready <none> 8m v1.9.2-gke.1

For the node upgrade, instead of upgrading them all at once, GKE performs rolling upgrade. It will first drain and deregister a node from the node pool, delete an old instance, and provision a new instance with the desired version, then add it back to the cluster:

// perform node upgrades.
# gcloud container clusters upgrade my-k8s-cluster --zone us-central1-a --cluster-version 1.9.3-gke.0
All nodes (3 nodes) of cluster [my-k8s-cluster] will be upgraded from
version [1.9.2-gke.1] to version [1.9.3-gke.0]. This operation is
long-running and will block other operations on the cluster (including
delete) until it has run to completion.
Do you want to continue (Y/n)? y
Upgrading my-k8s-cluster...done.
Updated [https://container.googleapis.com/v1/projects/kubernetes-cookbook/zones/us-central1-a/clusters/my-k8s-cluster].
The node pool can be configured to auto-upgrade via the --enable-autoupgrade flag during cluster creation, or using the gcloud container node-pools update command to update existing node pools. For more information, please refer to https://cloud.google.com/kubernetes-engine/docs/concepts/node-auto-upgrades.

It will take more than 10 minutes. After that, all the nodes in the cluster are upgraded to 1.9.3-gke.0.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.203.144