Part 4: Connect CIVO Cluster With Humanitec

Markus Stahl
5 min readJul 27, 2023

As a developer with limited spare time to learn the pitfalls of Kubernetes, I am going to use the platform orchestrator Humanitec for my own use: managing small cloud projects.

Up to now, I explained how to create an account and how to deploy an application with Humanitec to a demo environment. The demo environment is of course not the right place to host your application. The environment gets wiped frequently and you do not have much insights on what components are available. Soon, you want your own environment.

Humanitec supports dedicated Kubernetes from the big 3 cloud providers, of which you of course would choose GKE. You can easily create a Google Kubernetes Engine on your Google Cloud Platofrm and connect your account with Humanitec (documentation here). The other providers are likely to be connected as easily.

Budget Calculation

When I did create my GKE it turned out be quite expensive. Roughly $220 per month. For a company these costs are ok, for a single free-time developer it is a hefty budget. So I was looking around for other providers and found Civo, who happen to run advertisements as if they had just waited for my pain: running a Kubernetes cluster only for a fraction of the costs at GCP.

I don’t remember the exact specs that I had compared, but initial comparison showed that I would pay $40 for an equivalent sized cluster at Civo. I sized down on nodes, as I only require a playground and now pay $20 for my Humanitec playground. That is a prize I can work with. If my playgrounds would become more serious, I could increase the cluster size, add more nodes, and bill the extra amount to the customer. Until then $20 for a playground or test environment are manageable.

Creating A Cluster at Civo.com

At first you need to create an account at https://www.civo.com/ . Do not get too over excited about the free budget they offer. It is very nice and generous, it just counts differently than you expect. The budget covers “only” the next 2 bills, meaning it can cover for up to 2 months, but if you create your account on the 29th, your first month’s bill arrives already 2 days later with almost no costs. Nevertheless, the budget is big enough to cover for heavy experiments no matter for 1 or 2 months.

You also get a notification when your budget is going to end. Not like at Google Cloud Platform, where I got instead of a notification but a bill after some zombie cluster had eaten up my free-budget without my knowledge. But that was 2 years ago, maybe Google changed their policy.

You might need to wait for a while until your account is validated, so plan for a break.

Creating K8s Cluster

Creating a Kubernetes cluster is straight forward. I used the dashboard, chose servers in Germany. As the initial budget is huge, I started using bigger machines and more nodes than I initially had planned for. During my second month I sized them down, which was easy and smooth, too.

Assuming that you have kubectl (and maybe a tool for cluster management like k9s) already installed, you can download the kubeconfig file from the dashboard:

I happen to already have a kubeconfig and needed to integrate the civo config. Thanks to the internet, I found this blog post explaining how to merge kubeconfig files. If you are using k9s (or equivilant) you can now connect to your civo cluster and check it out from the inside.

Connect Civo K8s Cluster to Humanitec

In Humanitec, everything is a resource. Cluster, namespace, persistent volume, database… if you want to provide a new resource available for applications, you first need to define that resource. You create a resource definition.

For creating a resource definition for your Kubernetes cluster, you login to Humanitec, choose Resource Management from the menu and click on Add resource definition:

From the list of available resource types, choose Kubernetes cluster (top of the list)

Next you need to choose a driver for that cluster. Drivers take care of managing your clusters infrastructure. Different providers can offer different tooling, that’s why Humanitec has different drivers on stock facilitating provider specific tooling. As we use a vanilla kubernetes on Civo, we just choose k8s-cluster

Finally, we get to configure connection details:

Do not get overwhelmed by the amount of properties requested. Under each field you find a hint where to find that property. Most of them you can retrieve from your kubeconfig file you had downloaded earlier.

Cluster API Server URL and Load Balancer IP you can retrieve from the dashboard of your cluster. They are listed on the right column of your dashboard. Retrieve:

  • “Cluster API Server URL” from “API Endpoint”
  • “Load Balancer” from “DNS Name”

Add DNS Resource for Civo

We are almost finished. When we deploy applications to our Civo cluster, we most likely would like to access it as well. We need an ingress resource for it. Civo provides Traefik as default ingress controller, which is not the default ingress resource provided by Humanitec.

Therefore, create another resource, this time with type “Ingress”. Just give it a name and leave all other fields empty. Civo will fill them with defaults, and make your ingress route work out-of-the-box. Add a matching criteria that ensures your traefik DNS is provisioned whenever an environment based on the civo cluster is used.

Summary

Now we have an affordable Kubernetes cluster connected to our platform orchestrator, in particular having a cluster from Civo.com connected with our Humanitec account.

For deploying actual applications to your cluster, you need to specify a matching criteria for your cluster-resource and your dns-resource. Only applications that match the criteria will be able to pull the resources. We will do that in another post.

--

--

Markus Stahl

Sustainable automation with open source technologies.