Kubernetes is a platform for orchestrating containerised applications. Learn how to get started with DigitalOceanâ€™s Managed Kubernetes service in this article.
Why Use Managed Kubernetes?
Both these projects focus on providing a lightweight solution thatâ€™s easy to get to grips with. Even so, hosting your own Kubernetes installation can be time-consuming and tricky to maintain. All the major public cloud providers have now developed fully-managed Kubernetes offerings which let you deploy apps quickly with minimal setup.
DigitalOceanâ€™s Managed Kubernetes service lets you create a Kubernetes cluster in only a few minutes. It supports the full Kubernetes API, node auto-scaling, and automatic Kubernetes version upgrades.
DigitalOcean provides 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 compute instances, termed â€œdroplets.â€� These are available in a range of sizes and start at $10/mo for a single vCPU with 2GB of RAM.
A word of warning before continuing: following the remainder of this guide will cause costs to accrue against your DigitalOcean account. We advise you use small, low-cost nodes when working with a Kubernetes cluster created for experimental purposes.
Creating Your Cluster
Begin by logging into your DigitalOcean account. Click the green â€œCreateâ€� button at the top right of the screen. Select â€œKubernetesâ€� from the menu that appears.
Begin by choosing the Kubernetes version to use. At the time of writing, the 1.17, 1.18 and 1.19 major releases are available. Itâ€™s advisable you use the newest release (1.19) unless you have a specific reason not to.
Next, select a DigitalOcean datacentre to contain your clusterâ€™s resources. Itâ€™s a good idea to use the datacentre thatâ€™s geographically closest to where you and your users are situated.
Choosing Cluster Capacity
Scroll down to the â€œChoose cluster capacityâ€� section. Here you can define the nodes which will be available to the cluster. Your clusterâ€™s workloads will execute on these nodes. The nodes will be 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â€� dropdown lets you choose which kind of DigitalOcean droplet to use. Itâ€™s worth reviewing the droplet pricing table if youâ€™re unsure of the differences between each type. Weâ€™ll be sticking with the â€œBasic nodesâ€� which give a good balance between compute performance and available memory.
Select the droplet variant to use from the â€œNode Planâ€� dropdown. To save costs, weâ€™re using the smallest option available â€“ 1 vCPU and 1GB 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 to add to the cluster. The default selection is 3 but you can reduce this down to 1 for development purposes. Be aware that your services will be unavailable during Kubernetes upgrades if you opt to use only a single node. Multiple nodes increase redundancy, support horizontal scaling and reduce downtime during updates.
Once youâ€™re done adding your nodes, scroll down the page and give your cluster a name. Click the â€œCreate clusterâ€� button to begin the provisioning process. This will take up to five minutes to complete.
Getting Started With Your Cluster
While you wait, you can click through the â€œGetting Startedâ€� guide displayed at the top of the page. This will walk you through downloading
kubectl, the official Kubernetes command-line client, and
doctl, DigitalOceanâ€™s own client.
The next step allows you to download your clusterâ€™s Kubernetes configuration file. This can be used with
kubectl to connect to your cluster â€“ once downloaded, pass its path as the value to the
kubectl --kubeconfig=kubeconfig-path.yaml get nodes
The above command will list the details of all the nodes in your cluster.
When using this method, be aware that the authentication certificate expires after a week. Youâ€™ll need to re-download it when the timer expires. An alternative approach uses
doctl to fetch the configuration file and configure automated certificate management â€“ use the command shown under â€œAutomated certificate managementâ€� to set this up.
The last stage allows you to quickly install â€œ1-Click Appsâ€� from the DigitalOcean Marketplace. These are preconfigured deployments of commonly-used services, such as NGINX Ingress Controller and Linkerd. Click â€œInstallâ€� next to any of the apps to add to your cluster. The process may take several minutes to complete.
Managing Your Cluster
You can see your clusterâ€™s Node Pools and their Nodes by clicking the â€œNodesâ€� tab at the top of the screen. Click a Node Pool to view the Nodes within.
You can add a new Node Pool by clicking the â€œAdd Node Poolâ€� button in the top right. To edit an existing Node Pool, click the three-dots icon to the right of the table and choose â€œResize or Autoscaleâ€�.
The dialog lets you select from a fixed node count (the default) or automatic scaling. When using the â€œFixed sizeâ€� option, you specify the exact number of nodes to use.
Select the â€œAutoscaleâ€� radio button to define a minimum to maximum range for the node count. Additional nodes will be added and removed automatically 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. This defaults to cluster-level metrics for key statistics such as CPU usage and network bandwidth. Use the â€œSelect objectâ€� dropdown to drill down to a specific node or pool.
More Management Options
DigitalOceanâ€™s platform has built-in support for the Kubernetes Dashboard, the official web UI from the Kubernetes project. Click the â€œKubernetes Dashboardâ€� button in the top right to launch the app in a new tab. Itâ€™ll be preconfigured with a valid authentication token.
DigitalOcean also offers automatic cluster upgrades. Click the â€œSettingsâ€� tab at the top of the screen. Next, press â€œEnable automatic upgradesâ€�. Click the â€œEditâ€� button to customise the acceptable update timeframe.
DigitalOcean will now automatically apply Kubernetes patch updates to your cluster. Youâ€™ll be notified when new major versions are available. When they are, a one-click upgrade button will be offered within the interface.
You can delete your cluster at any time using the â€œDestroyâ€� button on the Settings screen. This will delete all the compute resources associated with the cluster. Some peripheral objects, such as block storage volumes and network load balancers, may need to be manually removed.
Thatâ€™s all there is to creating a Kubernetes cluster on DigitalOcean. Itâ€™s important to note that Kubernetes-managed resources will display elsewhere in your DigitalOcean Control Panel (for example, nodes will show up in the â€œDropletsâ€� management interface). Donâ€™t modify the properties of these resources directly â€“ use the Kubernetes interface instead to ensure they remain consistent with the expectations of the Kubernetes control plane.
The post How to Create a Managed Kubernetes Cluster on DigitalOcean â€“ CloudSavvy IT appeared first on TechFans.