Kubernetes and DigitalOcean Blockstorage


This article is now obsolete. The preferred method of attaching Digital Ocean block storage to Kubernetes (since 1.11)  is via the CSI (Container Storage Interface). You can find the Digital Storage CSI driver here : https://github.com/digitalocean/csi-digitalocean


So I moved to DigitalOcean for hosting of the Votavi platform infrastructure. This will also be the place where the production hosting will start. DigitalOcean has a couple of advantages. Hourly hosting, which will make scaling up and  down, temporary resources for testing, upgrading the cluster etc etc much more cost efficient.

But much more important is the block storage which can be enabled on Kubernetes. So here a little tutorial on how to do that;

This info is based on (DigitalOcean Provisioner).You will need the files (manifests) from the repository in the link.

  1. To enable Kubernetes to dynamically create Volumes based on VolumeClaim requests (Persistent Volume in Kubernetes), you will need an API key from DigitalOcean, you can create one here (if you have a DigitalOcean account).
  2. Base64 the token (on commandline echo  -n <api-token> | base64), and insert it into manifests/digitalocean-secret.yaml . Apply the yaml file to your Kubernetes cluster (via kubectl or the dashboard).
  3. Now load the RBAC files into your cluster (RBAC) , since this implementation is based on Kubernetes 1.9/1.10 I make the assumption Role-Based Access Control is used.
  4. So for the next step we need the provisioner which will handle the communication to the DigitalOcean API (provisioner ) , and load it into your cluster.
  5. For this step we need to adjust the manifest yaml file. This file creates the Deamonset on your cluster so every node can mount the DigitalOcean block storage volumes. Edit the host path in the file so it matches your environment, for me the default path was fine (Kubeadm installation on Debian 9 servers). Now load the file into your cluster.
  6. For the final step. Take the StorageClass yaml file , edit the Digital Ocean zone so it is in the same zone as your servers are, now block storage can be attached to them. You can adjust the Storage Class name if you want, I keep it on ‘default’. Load the file into your cluster and you are ready. You now have your Kubernetes Cluster running with dynamically allocated DigitalOcean Block Storage 😀 .

You can create your first volumeclaim as explained in Persistent Volumes in Kubernetes.  After creating a volumeclaim you should see the volume in the DigitalOcean dashboard next to droplets in the volumes tab. This volume can now be mounted by a Kubernetes Pod via its Kubernetes claimName .