Kubernetes is a platform for orchestrating containerized applications. This article shows you how to get started with DigitalOcean’s Managed Kubernetes service.
Why use Managed Kubernetes?
It is possible to install Kubernetes on your own hardware. Popular solutions to run Kubernetes yourself include MicroK8s and K3s.
Both projects aim to provide a lightweight solution that is easy to understand. Still, hosting your own Kubernetes installation can be time consuming and difficult to maintain. All major public cloud providers have now developed fully managed Kubernetes offerings that allow you to deploy apps quickly with minimal installation.
With DigitalOcean’s Managed Kubernetes service, you can create a Kubernetes cluster in minutes. It supports the full Kubernetes API, node autoscaling and automatic Kubernetes version upgrades.
DigitalOcean offers the Kubernetes control plane for free – you only pay for the nodes you add to the cluster. Nodes on DigitalOcean use the platform’s existing cloud computing instances, called “droplets”. These are available in a variety of sizes and start at $ 10 / month for a single vCPU with 2 GB of RAM.
A word of caution before proceeding, following the rest of this guide will generate charges on your DigitalOcean account. We recommend that you use small, low-cost nodes when working with a Kubernetes cluster created for experimental purposes.
Create your cluster
Start by logging into your DigitalOcean account. Click on the green “Create” button at the top right of the screen. Select “Kubernetes” from the menu that appears.
Start by choosing the Kubernetes version you want to use. At the time of writing, the major releases 1.17, 1.18 and 1.19 are available. It is recommended to use the latest release (1.19) unless you have a specific reason not to.
Then select a DigitalOcean datacenter to contain the resources of your cluster. It is a good idea to use the data center that is geographically closest to you and your users.
Select cluster capacity
Scroll down to the ‘Choose cluster capacity’ section. Here you can define the nodes that will be available to the cluster. Your cluster’s workloads run on these nodes. The nodes are orchestrated automatically by the Kubernetes control plane provided by DigitalOcean.
Nodes are sorted into node pools. This is a Kubernetes term for a group of one or more nodes, each with the same hardware resources. For our purposes, we only need a single Node pool to get started.
The “Machine Type” drop-down box allows you to choose which type of DigitalOcean drop you want to use. It’s worth checking out the droplet pricing table if you’re unsure about the differences between each type. We stick to the “base nodes” that offer a good balance between compute performance and available memory.
Select the droplet variant you want to use from the “Node plan” drop-down list. To cut costs, we use the smallest option available: 1 vCPU and 1 GB RAM, priced at $ 10 / month per node. DigitalOcean labels this as a “development plan” as the available resources are unlikely to be sufficient for long-term production use.
Finally, specify how many nodes you want to add to the cluster. The default selection is 3, but you can reduce this to 1 for development purposes. Note that your services will not be available during Kubernetes upgrades if you choose to use only one node. Multiple nodes increase redundancy, support horizontal scaling, and reduce downtime during updates.
When you have finished adding your nodes, scroll down the page and name your cluster. Click the “Create Cluster” button to start the provisioning process. This takes a maximum of five minutes.
Get started with your cluster
While you wait, you can click through the “Getting Started” guide that appears at the top of the page. This will help you download
kubectl, the official Kubernetes command line client, and
doctl, DigitalOcean’s own customer.
The next step allows you to download the Kubernetes configuration file for your cluster. This can be used with
kubectl to connect to your cluster – after downloading, pass the path as value to the
kubectl --kubeconfig=kubeconfig-path.yaml get nodes
The above command displays the details of all nodes in your cluster.
When using this method, keep in mind that the authentication certificate will expire after a week. You must download it again when the timer expires. An alternative approach uses
doctl to get the configuration file and configure automatic certificate management – use the command displayed under “Automated Certificate Management” to set this up.
In the final phase, you can quickly install “1-Click Apps” from the DigitalOcean Marketplace. These are preconfigured implementations of commonly used services, such as NGINX Ingress Controller and Linkerd. Click “Install” next to one of the apps to add to your cluster. The process may take a few minutes.
Manage your cluster
You can see the Node Pools and their Nodes of your cluster by clicking on the “Nodes” tab at the top of the screen. Click on a node pool to view the nodes in it.
You can add a new Node Pool by clicking the “Add Node Pool” button at the top right. To edit an existing node pool, click on the three-dot icon to the right of the table and choose “Resize or Autoscale.”
In the dialog box, you can choose from a fixed number of nodes (default) or autoscale. When using the “Fixed size” option, specify the exact number of nodes to use.
Select the ‘Autoscale’ radio button to define a minimum to maximum range for the number of nodes. Additional nodes are automatically added and removed based on the resource usage of your cluster’s workloads.
You can view the activity within your cluster by clicking the “Insights” tab at the top of the screen. These are standard cluster-level metrics for important metrics such as CPU usage and network bandwidth. Use the “Select Object” drop-down to go to a specific node or pool.
More management options
DigitalOcean’s platform has built-in support for the Kubernetes Dashboard, the official web interface of the Kubernetes project. Click the “Kubernetes Dashboard” button in the top right to launch the app in a new tab. It is preconfigured with a valid authentication token.
DigitalOcean also offers automatic cluster upgrades. Click on the “Settings” tab at the top of the screen. Then press “Enable automatic upgrades”. Click the “Edit” button to adjust the acceptable timeframe for updates.
DigitalOcean now automatically applies Kubernetes patch updates to your cluster. You will be notified when new major versions are available. If so, a one-click upgrade button will be offered in the interface.
You can delete your cluster at any time using the “Destroy” button on the Settings screen. This removes all compute resources associated with the cluster. Some peripherals, such as block storage volumes and network load balancers, may need to be manually removed.
That’s all you need to do to create a Kubernetes cluster on DigitalOcean. It is important to note that Kubernetes managed resources appear elsewhere in your DigitalOcean Control Panel (for example, nodes are listed in the “Droplets” management interface). Do not change the properties of these resources directly – instead, use the Kubernetes interface to ensure that they remain consistent with the expectations of the Kubernetes control plane.