DigitalOcean is a unique and straightforward cloud hosting provider. It offers cloud computing services to customers to deploy and develop applications that need to be run across multiple cloud servers. DigitalOcean infrastructure is one of the leading cloud service providers based in the USA. Even though the headquarters of DigitalOcean is located in New York City, their data centers are widespread in every corner of the world to offer seamless cloud services across the globe. In addition, DigitalOcean provides a simple interface and set-up along with a very affordable price.
DigitalOcean Kubernetes (DOKS) is a managed Kubernetes service offered by DigitalOcean that lets users deploy clusters without the complexities of handling the control panel and containerized infrastructure. Kubernetes clusters are compatible with standard Kubernetes toolchains and integrate natively with DigitalOcean block storage volumes and load balancers. The users are charged for a Kubernetes cluster based on the cluster’s resources. Users can view all charges for Kubernetes clusters in the Kubernetes section of monthly invoices. At least one data center in every region supports Kubernetes in DigitalOcean. Note that Kubernetes is not offered in the AMS2, NYC2, or SFO1 region.
Users can upgrade Kubernetes clusters to new minor versions (e.g. 1.12.1 to 1.13.1) as well as newer patch versions (e.g. 1.13.1 to 1.13.2) using Control Panel, command-line interface (CLI) tool, or doctl. There are two ways to upgrade DigitalOcean Kubernetes clusters:
- On-demand: Users can manually trigger the upgrade process when an upgrade becomes available for DigitalOcean Kubernetes. Users can upgrade to a new minor version using the manual process, provided they first perform all available patch-level upgrades for their current minor version.
- Automatically: Users can enable automatic upgrades for a cluster that happen within a maintenance window they specify. Automatic updates trigger new patch versions of Kubernetes and new point releases of DigitalOcean Kubernetes subsystems, like the DigitalOcean Container Storage Interface or DigitalOcean Cloud Controller Manager. However, the user cluster will not be automatically upgraded to new minor Kubernetes versions (e.g. 1.12.1 to 1.13.1).
In this tutorial, we will learn the steps to upgrade the Kubernetes cluster in DigitalOcean to a newer version using CLI.
The Upgrade Process
>> Note: To avoid downtime during the upgrade and for a faster upgrade, we recommend enabling surge upgrade on existing clusters.
During an upgrade, the control panel (Kubernetes master) is replaced with a new control panel running the latest version of Kubernetes. This process will take a few minutes to complete, during which Application Programming Interface (API) access to the cluster is unavailable, but workloads are not impacted.
Once the control panel is replaced, the worker nodes are replaced in a rolling fashion, one worker pool at a time. Kubernetes reschedules each worker node’s workload, replaces the node with a new node running the new version, and reattaches any block storage volumes to the new nodes. The new worker nodes have unique IP addresses.
Warning: Users will lose any data stored on the local disks of the worker nodes in the upgrade process. We recommend using persistent volumes (PV) for data storage and not relying on local disks for anything other than temporary data.
During this process, workloads running on Kubernetes clusters with a single worker node will experience downtime because there is no extra capacity to host the node’s workload during the replacement.
We may need to force cluster upgrades even on clusters with automatic upgrades disabled if security-related issues occur. We work to upgrade during specified maintenance windows with advance notification via email, control panel notifications, and our status page when this is the situation.
By default, surge upgrades are enabled when the user creates a new Kubernetes cluster. It is recommended to enable surge upgrades when upgrading an existing cluster. Surge upgrades ensure more stability and a faster upgrade. Surge upgrades will create duplicate nodes, up to a maximum of ten nodes. After creating the upgraded nodes, workloads are drained from the old nodes to the latest nodes before deleting the old nodes. It is because that the maximum number of nodes created during an upgrade is ten, and larger cluster nodes are only upgraded ten at a time.
To enable surge upgrades, go to the Surge upgrades section of the Settings tab of the user’s cluster and click the Edit button. Then, choose the Enable surge upgrades option and click the Save button.
To use surge upgrades for the entire upgrade duration, the user’s Droplet limit must be at least n + min(10, num_nodes), where num_nodes is the number of nodes in the user’s Kubernetes cluster and n is the user’s current Droplet count. For example, if the user has a 12-node cluster and 5 Droplets, their Droplet limit must at least be 15. Users can request a Droplet limit increase at any time.
Suppose an upgrade begins with less than the required number of Droplets or reaches the limit during the upgrade. In that case, a partial upgrade is completed using the available Droplets, and the remaining upgrade happens without enabling the surge.
Surge upgrades can have some added cost, and this cost depends on how much time to drain workloads from their old nodes. Depending on the length of the upgrade, the estimated cost can range from $0 to one hour of cluster cost. For example, if the user cluster costs $0.19/hr, their surge upgrade range can be $0 – $0.19/hr per upgrade. To help drain the user’s nodes smoothly and minimize the cost of the upgrade, they can Enable disruption-free upgrades.
Upgrading Via Command-Line Interface
Upgrade to the Latest Version:
First, obtain the cluster-ID by executing the following command:
doctl Kubernetes cluster list
Then, execute the following command to upgrade to the latest version. In the below command, replace <cluster-id> with the Kubernetes cluster-ID.
doctl kubernetes cluster upgrade <cluster-id>
Upgrade to a Specific Version
To upgrade to a specific Kubernetes version, rather than just automatically upgrading to the latest version, users must first use their cluster ID to get a list of available upgrades for that cluster by executing the following command:
doctl kubernetes cluster get-upgrades <cluster-id>
Then, use the slug value returned by the above command to perform the upgrade:
doctl kubernetes cluster upgrade <cluster-id> --version 1.20.2-do.0
This tutorial presents the steps to upgrade the DigitalOcean Kubernetes cluster to a newer version using the command-line interface. Hope this tutorial was helpful, and do reach out to us if you have any query or suggestions.