3 min read
Kubernetes Cluster Creation on Baremetal Host Using Cluster API

This post is a summary of my talk at Open Source Summit Japan 2019, co-presented with Himani Agrawal.

Resources:


There are many different tools available to bootstrap and manage Kubernetes clusters within various platforms, but they don’t all interoperate. The Cluster API project attempts to solve this issue by creating a common declarative API, tools, and best practices for deploying, configuring, and managing Kubernetes across multiple platforms.

Running Cluster API for raw baremetal KVM machines without an IaaS vendor remains a challenge. In this talk, we showed how to use and configure Libvirt to create a custom provider for Cluster API.

What is Cluster API?

Cluster API uses CRDs underneath for provisioning and managing Kubernetes clusters. It comprises five custom resources on top of a Kubernetes cluster:

Cluster API crds

Cluster Resource

A Cluster resource provides a way to define common configuration for the desired Kubernetes cluster to be deployed (also called the target cluster). The implementation of how to actually create a cluster depends on the infrastructure provider.

A cluster definition is specified in the cluster resource spec which has generic cluster info like network CIDRs, API endpoints, service domain, etc.

Machine Resource

A Machine resource resembles an individual Kubernetes control plane or Kubernetes worker node. It contains the specification for the machine’s configuration including:

  • Kubernetes version
  • Machine roles (control plane or worker)
  • Provider-specific configuration

Creating a Custom Provider

The talk covers how one can write a Cluster API provider for baremetal hosts using Libvirt. The same concepts can be applied to create a new provider for any infrastructure of your choice.

Key components of a Cluster API provider include:

  • Cluster Actuator: Handles cluster-level operations (create, update, delete)
  • Machine Actuator: Handles machine-level operations (create, update, delete)
  • Controller Manager: Reconciles the desired state with actual infrastructure

Why Libvirt for Baremetal?

Libvirt provides a consistent API for managing virtualization technologies. When working with baremetal hosts that run KVM, Libvirt offers:

  • Domain (VM) lifecycle management
  • Network configuration
  • Storage management
  • Cross-hypervisor compatibility

This makes it an excellent choice for creating a Cluster API provider that can provision Kubernetes nodes on baremetal infrastructure without requiring a full IaaS platform.


For the complete technical details and implementation guide, please refer to the original article on ITNEXT.