Setting up a managed Kubernetes Cluster on Digital Ocean

Introduction

This is probably going to be a very short post given how easy this process is. But since I am referencing Kubernetes in a Digital Ocean environment I felt remiss in not posting this first.

Before you start I am going to presume you have an account with Digital Ocean in the first place.  If not get one and this is a very simple process as well.

 

Why Digital Ocean?

Over the past few years I’ve worked with a variety of hosting providers including, but not limited to

  • Codero; where I host my email server
  • Amazon Web Services
  • Microsoft Azure
  • Digital Ocean

Codero only provides dedicated server services which I use one for my email server.  Currently that server is getting long in the tooth and at some point in the future (soon!) I plan to refresh that server with a newer bit of hardware and updated OS.

Amazon gets pricey very quickly and Microsoft Azure even quicker.

Which gets me to Digital Ocean.  All the cloud providers tell you that you only pay for what you use.  The devil is in the details and the pricing for AWS and Azure are such that any serious work winds up costing a lot.

Digital Ocean seems to be the most economical so I forsee having them for the foreseeable future as my cloud provider.

Digital Ocean also provides Virtual Private Machines (VPS), which are referred to as “Droplets”, and the pricing on them has proven to be very economical.

The Details

Signing on to the managed Kubernetes offering on Digital Ocean is a fairly new service.  It was beta for a while and you had to ask to be a beta tester which I did.  I didn’t get truly serious about messing with Kubernetes until I realized that I was going to need it for work for an upcoming project.

Build the Cluster

After logging into your Digital Ocean account expand the “Manage” menu on the left hand menu bar.

You’ll notice the menu dropdown has an entry for Kubernetes.  Now when I click on that I see the cluster that I already reated so in the upper right hand corner you can hit “Create” instead which will give you a drop-down that looks like this:

Click on “Clusters” and you’ll be taken to another page which asks you some pertinent questions.

You’ll be asked which version of Kubernetes you want to use (defaults to the latest stable version) which datacenter you want the cluster stood up in (defaults to San Francisco) and next you’ll be asked for basic information about the cluster itself.  How large a worker pool and what size droplets to use and the approximate monthly cost is shown during this selection process.

 

 

 


Further down on the page you’ll be asked to provide a name for the cluster itself. Once you’ve input all your choices hit the “Create Cluster” button on the bottom of the page and in about four minutes you’ll be the proud renter of a Kubernetes cluster that is managed by Digital Ocean.

Access to the Cluster

This is accomplished by downloading an identity configuration that should go into ${HOME}/.kube/config as a flat text file.   This provides the “keys to the kingdom” that allows you to deploy applications to the cluster using the kubectl command line. One annoyance is this config expires weekly and you’ll have to update it.  I find that annoying anyway… maybe others won’t.

Install kubectl

If you haven’t already done so install the kubectl command line.  If you are on a Debian family host here’s how using the native packaging utilities:


$ sudo apt-get update && sudo apt-get install -y apt-transport-https
$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
$ echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
$ sudo apt-get update
$ sudo apt-get install -y kubectl

 

Other Tooling

I’d also recommend highly downloading and installing the Digital Ocean command line tool “doctl” as it is a handy thing to have as well.  Very simple to do, it does require administrator access on you development system.  I won’t regurgitate the whole process but the instructions are here based on what OS your are running.

About: peter


Leave a Reply

Your email address will not be published. Required fields are marked *