Cluster API: Cluster Lifecycle Management in Kubernetes

Cluster API: Cluster Lifecycle Management in Kubernetes

A plain-English guide to using Kubernetes itself to create, upgrade, repair and retire other Kubernetes clusters, with the same declarative habits you already use for applications.

Imagine you manage a fleet of ships. Each ship needs to be built, launched, fuelled, repaired, upgraded with new equipment and, eventually, retired. If you have one ship, a skilled crew can handle all of that by hand. If you have fifty ships spread across different harbours, hand-crafted care stops working. Each ship drifts into its own habits. One has newer engines, one has older radios, one has a crew who remembers a fix that nobody wrote down. When something breaks at three in the morning, nobody is sure how that particular ship was built.

Running Kubernetes clusters is very similar. Creating one cluster is a weekend project. Running dozens, across clouds, data centres and teams, is a different job entirely. Clusters must be created the same way every time, upgraded safely, repaired when machines die and deleted cleanly when no longer needed. Doing this with scripts and checklists works for a while, and then it does not.

Cluster API is the Kubernetes community’s answer. It lets you describe clusters as ordinary Kubernetes objects and uses controllers, the same kind of tireless workers that keep your pods running, to build and maintain whole clusters for you. In this guide you will learn what Cluster API is, how it works inside, how clusters are created, upgraded and healed, how to run it safely at fleet scale, and how it compares with the alternatives. Every new term is explained in simple words and tied to an everyday picture.

1Why Cluster Lifecycle Is a Hard Problem

Kubernetes is excellent at managing applications. Strangely, it was not built to manage itself. That gap is what this chapter is about.

A cluster has a whole life, not just a birth

People often think of cluster setup as one event: run an installer, wait, done. In reality a cluster lives through many stages, and each stage brings its own risks. The set of activities from birth to retirement is called the cluster lifecycle.

1

Create

Build the network, the machines, the control plane and the worker nodes, and connect them so that they behave as one cluster.

2

Scale

Add or remove machines as demand changes, in the right places and with the right sizes.

3

Upgrade

Move to newer Kubernetes versions regularly, since old versions stop receiving security fixes, without breaking the applications that run on top.

4

Repair

Notice when a machine is sick or gone, and replace it before users feel it.

5

Retire

Delete the cluster and every cloud resource it created, so that nothing is left behind to cost money or leak data.

Pets and cattle

Operations teams use a famous picture. A pet is a server you name, nurse back to health and cannot bear to lose. Cattle are servers you number, replace when sick and never worry about individually. Healthy infrastructure treats machines as cattle. But a hand-built cluster tends to become a pet: it has a story, odd settings, special fixes and a person who knows its secrets. When that person leaves, the cluster becomes a risk.

Everyday Analogy

Think of an airline. It does not let each aircraft be maintained by whoever happens to be in the hangar. It has standard procedures, scheduled inspections, tracked parts and a rule that a faulty part is replaced, not guessed at. Cluster lifecycle management is the airline’s maintenance system for your clusters.

Cluster sprawl

Why would anyone need many clusters? Good reasons are common. Separate clusters for production and testing. Separate clusters per region for lower delay and legal rules about where data may live. Separate clusters per team or customer for stronger isolation. Separate clusters for different Kubernetes versions during migrations. Edge locations, such as stores and factories, each with a small cluster. Before long, an organization may own dozens or hundreds.

Tens to hundreds
of clusters in a large organization
3 releases
of Kubernetes per year, each needing upgrades
Every cluster
needs the same care, again and again

What goes wrong without a system

  • Drift. Clusters that began identical slowly become different, and nobody can say how.
  • Slow upgrades. Each upgrade is a nervous, manual project, so clusters fall behind and become insecure.
  • Knowledge locked in heads. Only a few people know the steps.
  • Slow recovery. After a failure, rebuilding takes days instead of minutes.
  • Orphaned resources. Forgotten disks, load balancers and networks keep costing money.
i
Good to Know

Notice that these are the same problems Kubernetes solved for applications. Declare what you want, let controllers make it so, and let them keep it so. Cluster API applies that same idea one level up.

2The Landscape of Ways to Run Clusters

Cluster API is one choice among several. Seeing the whole landscape helps you understand what it is good at, and what it is not trying to be.

Common approaches

Approach

Hand-built with kubeadm

kubeadm is the official tool to bootstrap a cluster on machines you already prepared. It is flexible and educational, but you must create the machines and handle everything else.

Approach

Cluster installers

Tools like kOps and similar installers automate machine creation on particular clouds. Many of them run once from a command line and do not keep watching afterwards.

Approach

Infrastructure as code

Tools like Terraform describe machines and networks in files. They are excellent for infrastructure, but they apply changes only when someone runs them, and do not heal clusters on their own.

Approach

Managed Kubernetes

Cloud services such as EKS, AKS and GKE run the control plane for you. Very convenient, though each cloud has its own interface and rules.

Approach

Vendor platforms

Commercial platforms bundle cluster management with other features, sometimes using Cluster API underneath.

Approach

Cluster API

Clusters described as Kubernetes objects and managed continuously by controllers, on many infrastructures through a common set of interfaces.

The key difference: continuous reconciliation

Most older tools are imperative runs. You run them, they do work and they stop. If a machine disappears an hour later, nothing notices. Cluster API is built from controllers that run forever. They compare the clusters you asked for with the clusters that exist, every few seconds, forever. A missing machine is noticed and replaced, not because someone ran a script, but because the controller always wants reality to match the description.

QuestionRun-once toolsCluster API
When does it act?When a person runs itContinuously, on every change and on a timer
What notices a dead node?Monitoring and humansHealth check controllers
How do you describe a cluster?Scripts or tool-specific filesKubernetes objects, stored and versioned like any other
How do you upgrade?Follow a runbookChange a version number and let controllers roll it out
Does it work across clouds?Usually one cloud per toolCommon interfaces, many providers
!
Watch Out

Cluster API is not a magic installer that hides all complexity. It gives you a consistent, automated way to manage clusters, but you still choose networking, storage, machine sizes and upgrade policies. It automates decisions. It does not make them.

3The Big Idea: Kubernetes Managing Kubernetes

Cluster API is easy to understand once you see its one central trick: it uses a Kubernetes cluster to manage other Kubernetes clusters.

Two kinds of clusters

Every Cluster API setup has two roles. They may be played by different clusters, and the names are worth learning because they are used everywhere.

  • The management cluster is the control room. It runs the Cluster API controllers. It stores descriptions of all the clusters you want. It is where you apply changes, and where the work is decided.
  • A workload cluster, sometimes called a target cluster, is a cluster that Cluster API creates and looks after. It is where your applications run. There can be as many as you like.
Everyday Analogy

The management cluster is the air traffic control tower. The workload clusters are the aircraft. The tower does not carry passengers. It tracks every flight, tells each one what to do and notices when one goes missing. The aircraft carry the passengers, which here are your applications.

Clusters as ordinary objects

In the management cluster, a workload cluster is represented by a small set of Kubernetes objects. Want a cluster with three control plane machines and five workers on a certain Kubernetes version? You write those wishes as objects and apply them with the same tools you use for deployments. The Cluster API controllers read them and start building. Want to upgrade? Change the version in the object. Want to add workers? Change a number.

flowchart TB
    ADMIN["Platform engineer or GitOps tool"] -->|"applies cluster descriptions"| MGMT
    subgraph MGMT["Management cluster"]
        OBJ["Cluster API objects"] --> CTRL["Cluster API controllers"]
    end
    CTRL -->|"calls cloud and data center APIs"| INFRA["Infrastructure: networks, machines, load balancers"]
    INFRA --> W1["Workload cluster A"]
    INFRA --> W2["Workload cluster B"]
    INFRA --> W3["Workload cluster C"]
    CTRL -.->|"watches health and reconciles"| W1
    CTRL -.->|"watches health and reconciles"| W2
    CTRL -.->|"watches health and reconciles"| W3
Figure 1 – One management cluster describes and maintains many workload clusters.

Why this works so well

  • One language. Teams already know how to write, review and apply Kubernetes objects. Clusters become just another kind of object.
  • One workflow. The same version control, review and GitOps practices that manage applications now manage infrastructure.
  • Built-in self-healing. Controllers reconcile continuously, so drift is corrected automatically.
  • Common interfaces. Providers for different clouds follow shared rules, so most of your habits carry over from one infrastructure to another.

Where it comes from

Cluster API is a project of the Kubernetes community, run by the special interest group responsible for cluster lifecycle, the same group that maintains kubeadm. It started in 2018 and has grown into a mature project with a large set of providers. Its command-line helper is called clusterctl.

i
Good to Know

Cluster API is not a hosted product you buy. It is open-source software that you run. Several vendors build commercial platforms on top of it, but the project itself is community-owned.

4The Core Objects You Must Know

Cluster API defines a small family of object types. If you already understand pods and deployments, you are halfway there, because the design deliberately mirrors them.

The mirror: applications and machines

Kubernetes manages application containers through pods, ReplicaSets and Deployments. Cluster API manages the machines that make up a cluster through three objects with the same relationships. This is the single most helpful idea for learners.

For applicationsFor machines in Cluster APIWhat it does
PodMachineOne single machine, such as one virtual server that will become a node
ReplicaSetMachineSetKeeps a stated number of identical machines running
DeploymentMachineDeploymentManages rolling updates between MachineSets as the machine template changes

The full cast of objects

Top level

Cluster

The overall description of a workload cluster: its network ranges, its endpoint and links to its control plane and infrastructure objects. It is the root of the family tree.

Machines

Machine

Represents one machine. It points to the specific infrastructure object that creates the server, and to the bootstrap configuration that turns it into a node.

Machines

MachineSet

Maintains a set number of machines from one template. If one is lost, it creates another.

Machines

MachineDeployment

Owns MachineSets and performs rolling changes. This is the object you edit to scale workers or move them to a new version.

Control plane

Control plane object

Describes the control plane of the cluster, for example how many replicas it has and which version. The kubeadm based implementation is called KubeadmControlPlane.

Health

MachineHealthCheck

Defines what an unhealthy machine looks like and what to do about it, which is normally to replace it.

Fleet

ClusterClass

A reusable blueprint for clusters, so that many clusters can be created from one standard design with only a few differences.

Pools

MachinePool

An option that maps a group of workers to a cloud-native scaling group, where the cloud manages the machines.

flowchart TB
    CL["Cluster"] --> CP["Control plane object - KubeadmControlPlane"]
    CL --> INF["Infrastructure cluster object"]
    CL --> MD["MachineDeployment - workers"]
    MD --> MS["MachineSet"]
    MS --> M1["Machine 1"]
    MS --> M2["Machine 2"]
    CP --> M3["Control plane Machine"]
    M1 --> IM1["Infrastructure machine - the real server"]
    M1 --> BC1["Bootstrap config - how to join"]
    MHC["MachineHealthCheck"] -.->|"watches"| MS
Figure 2 – The family tree of Cluster API objects. A Cluster owns its control plane and its worker deployments, and each Machine points to the real server behind it.
i
Good to Know

Notice that a Machine does not itself contain provider-specific details. It points to other objects for those. This indirection is what lets the same Machine concept work on any cloud, and is the subject of the next chapter.

5The Provider Model: One Design, Many Infrastructures

The cleverest part of Cluster API is how it separates the general idea of a cluster from the messy details of any particular cloud.

The problem providers solve

Creating a virtual server on Amazon Web Services is different from creating one on Azure, on a VMware data centre or on bare metal. The calls, the names and the rules all differ. If the core Cluster API controllers had to know every infrastructure, the project would be impossible to maintain. Instead, the core knows only the general ideas, such as “a machine”, “a cluster endpoint” and “a node that must join”, and delegates the details to plug-ins called providers.

Everyday Analogy

Think of a general contractor who builds houses in many countries. The contractor knows the plan, the schedule and the quality checks. For the plumbing in each country, a local specialist is hired who knows the local codes and parts. Cluster API is the contractor. Providers are the local specialists.

The four kinds of providers

Provider type

Core provider

Supplies the general controllers for Cluster, Machine, MachineSet, MachineDeployment and health checks. Every setup has exactly one.

Provider type

Infrastructure provider

Knows how to create the real things: networks, load balancers and servers on a specific platform, such as a public cloud, a virtualization system or bare metal.

Provider type

Bootstrap provider

Produces the startup instructions that turn a fresh server into a Kubernetes node. The most common one uses kubeadm.

Provider type

Control plane provider

Manages the control plane machines as a unit, handling their creation, certificates, etcd and rolling upgrades. The common one is also built on kubeadm.

Many infrastructure providers exist

The community maintains providers for the major public clouds, for VMware vSphere, for OpenStack, for bare metal through projects such as Metal3, and for many smaller platforms. There is also a provider that uses Docker containers as pretend machines. It is meant for local development and testing, not for production. A rich ecosystem of providers means you can often use the same habits and even the same blueprints across very different environments.

How a provider plugs in: the contract

Providers do not talk to the core by guesswork. They follow a published contract, a set of rules about what their custom objects must look like and how they must report progress. For example, a provider’s machine object must report when the server is ready and give an identifier for it, called a provider ID. The core controllers watch for these signals and act when they appear. Because the contract is public, anyone can write a new provider for a new platform.

flowchart TB
    CORE["Core Cluster API controllers"] -->|"Machine refers to"| IMT["Infrastructure machine object - provider specific"]
    CORE -->|"Machine refers to"| BTS["Bootstrap config object - provider specific"]
    CORE -->|"Cluster refers to"| ICL["Infrastructure cluster object - provider specific"]
    CORE -->|"Cluster refers to"| CPO["Control plane object - provider specific"]
    IMT --> AWS["AWS"]
    IMT --> AZ["Azure"]
    IMT --> VS["vSphere"]
    IMT --> BM["Bare metal"]
    BTS --> KB["kubeadm bootstrap"]
Figure 3 – The core controllers talk to providers through references. Swapping the infrastructure provider changes only the bottom of the picture.

Why the references are objects, not fields

You will notice that a Machine does not hold settings like “instance size” or “disk type”. It holds a reference to another object that does, owned by the provider. This keeps the core small, lets each provider evolve freely and makes it possible to reuse the same shape across clouds. The cost is that a full cluster description is made of several objects that point at each other, which can feel verbose at first. Blueprints, covered later, hide much of that.

!
Watch Out

Providers are separate projects with their own release schedules and maturity. Before you choose one, check how actively it is maintained, which Kubernetes versions it supports and which features, such as managed Kubernetes variants, it covers.

6Setting Up: The Management Cluster and clusterctl

There is a small chicken-and-egg question at the start: to create clusters with a cluster, you first need a cluster. Here is how teams solve it.

Step one: get a first cluster

The management cluster can be any working Kubernetes cluster. For learning, it is often a tiny throwaway cluster created on a laptop with a tool that runs Kubernetes inside containers. For real use, it may be a cluster created by hand, a managed cloud cluster or a cluster built by a previous Cluster API run.

Step two: install the controllers with clusterctl

clusterctl is the command-line helper for the project. Its first job is to install Cluster API into the management cluster. A single initialization command installs the core controllers, plus the infrastructure, bootstrap and control plane providers you choose. It also installs a helper called cert-manager, which issues the certificates that the controllers’ own web hooks need.

1

Prepare credentials

The infrastructure provider needs permission to create machines and networks. You give it cloud credentials, which are stored as secrets in the management cluster. These credentials are powerful and need special protection.

2

Initialize

The initialization command installs cert-manager, the core provider and the chosen providers as ordinary deployments.

3

Verify

You check that the controller pods are running and that the new object types are available in the API.

4

Generate a cluster description

clusterctl can fill in a template for your chosen infrastructure, producing a ready-to-apply set of objects for a new cluster, using your settings such as version and machine counts.

5

Apply it

You apply the generated objects. From this moment, the controllers take over and the cluster starts to appear.

Other jobs of clusterctl

  • Describe. Show a tree of a cluster’s objects with the health of each one, which is excellent for troubleshooting.
  • Get kubeconfig. Fetch the access file that lets you talk to a workload cluster.
  • Upgrade. Update Cluster API and its providers themselves, which is separate from upgrading the Kubernetes version of workload clusters.
  • Move. Transfer all the cluster descriptions from one management cluster to another. This allows the pivot described in a later chapter.
flowchart LR
    BOOT["Bootstrap cluster - for example a small local cluster"] --> INIT["clusterctl init installs Cluster API and providers"]
    INIT --> MGMT["Management cluster is ready"]
    MGMT --> GEN["Generate and apply cluster description"]
    GEN --> WL["Workload cluster is built"]
    WL -.->|"optional pivot with clusterctl move"| SELF["Workload cluster becomes the new management cluster"]
Figure 4 – The usual setup path, from a first tiny cluster to a managed fleet.
i
Good to Know

The tool that created your first cluster does not matter much. What matters is that you treat the management cluster as a critical system from the day it manages anything real.

7Anatomy of a Cluster Creation

When you apply the objects for a new cluster, a chain of controllers wakes up. Following the chain shows how much hidden work the system does for you.

The chain of events

1

The Cluster object is noticed

The core controller sees a new Cluster. It sees that the cluster points to an infrastructure object and a control plane object, and waits for them to become ready.

2

Shared infrastructure is built

The infrastructure provider creates the things shared by the whole cluster, such as the network, subnets, security rules and a load balancer in front of the future control plane. Its address becomes the cluster’s stable endpoint.

3

Certificates are generated

The control plane provider creates the cluster’s certificate authority and other key material, and stores them as secrets in the management cluster.

4

The first control plane machine appears

The control plane controller creates a Machine. The bootstrap provider prepares startup data to initialize a brand-new cluster, and the infrastructure provider creates the real server and hands it that data.

5

The server boots and starts Kubernetes

On first boot, the server runs the startup instructions, installs or starts the Kubernetes components and forms the first control plane node.

6

Access is published

A kubeconfig secret is created in the management cluster, so you and the controllers can reach the new cluster.

7

More control plane machines join

The controller adds the remaining control plane machines one at a time, each joining the existing cluster and its etcd database, until the desired count is reached.

8

Workers are created

The MachineDeployment’s MachineSet creates worker Machines. Each gets join instructions, boots and attaches to the cluster.

9

The Cluster is declared ready

When the control plane is available and the machines are running with nodes, status conditions turn healthy. Add-ons such as the network plugin are still needed for nodes to be fully ready.

sequenceDiagram
    participant U as User or GitOps
    participant C as Core controllers
    participant I as Infrastructure provider
    participant K as Control plane provider
    participant B as Bootstrap provider
    participant W as New cluster
    U->>C: Apply Cluster and related objects
    C->>I: Build network and load balancer
    I-->>C: Endpoint ready
    C->>K: Create control plane
    K->>K: Generate certificates
    K->>B: Request init bootstrap data
    B-->>K: Startup data in a secret
    K->>I: Create first machine with startup data
    I->>W: Server boots and forms cluster
    W-->>K: Control plane responds
    K->>I: Add remaining control plane machines
    C->>I: Create worker machines
    I->>W: Workers join
    C-->>U: Cluster reported ready
Figure 5 – The conversation between the controllers when a new cluster is created.

Why order matters

Notice that each step waits for the previous step to report ready. Controllers do not run a script from top to bottom. Each one watches the objects it cares about and acts when its inputs are ready. If something fails in the middle, for example a cloud quota is hit, the process pauses at that point, reports the reason in a status condition and retries. When you fix the cause, it continues from where it stopped, without starting over.

!
Watch Out

A cluster whose nodes remain “not ready” right after creation is often just waiting for a network plugin. Cluster API builds the cluster. It does not decide your networking. Installing a network plugin is a separate step that you must plan.

8Managing the Control Plane

The control plane is the brain of a cluster. Managing it safely is the most delicate part of the lifecycle, and Cluster API gives it special treatment.

Why the control plane is special

Worker machines are interchangeable. If one dies, another can take its place and nothing is lost. Control plane machines are different, because they hold etcd, the database that stores everything the cluster knows. Etcd works by agreement among members, called a quorum. With three members, the cluster survives the loss of one. With five, it survives the loss of two. Replace members carelessly, and you can lose agreement or lose data.

Everyday Analogy

Imagine a jury of three people that must agree by majority. If one juror leaves, the other two can still decide. If two leave at once, the jury cannot act. Replacing jurors is fine, but only one at a time, and only after the new juror is fully briefed. The control plane controller follows exactly this careful habit.

What the control plane controller does

Task

Create in order

It brings up the first member, waits for it to be healthy, then adds the others one at a time.

Task

Keep etcd healthy

Before removing or adding a member, it checks that etcd has quorum and that the member list matches the machines that exist.

Task

Manage certificates

It holds the cluster’s root certificates, and can renew certificates before they expire, often as part of replacing machines.

Task

Roll upgrades

When the version or the machine template changes, it replaces control plane machines one by one, while keeping the cluster available.

Task

Spread across failure zones

It tries to place members in different availability zones, so that the loss of a single zone does not break quorum.

Task

Remediate unhealthy members

When a control plane machine fails and a health check says it should be replaced, the controller replaces it only if it is safe for etcd.

Choosing the number of control plane machines

MembersFailures toleratedTypical use
1None. Losing it loses the control planeLocal development, short-lived tests
3OneThe usual choice for production
5TwoVery large or very critical clusters, at higher cost and slightly slower writes

Even numbers such as two or four add cost without adding failure tolerance, so odd numbers are the rule.

The stable address

All the nodes and users must reach the control plane at an address that does not change when machines come and go. The infrastructure provider usually creates a load balancer for this purpose, and the cluster’s endpoint points to it. Without a stable endpoint, replacing a control plane machine would break every node’s connection to the cluster.

i
Good to Know

Cluster API replaces control plane machines instead of patching them in place. This “build new, remove old” habit is called immutable infrastructure, and it is the thread that runs through all upgrades in the next chapters.

9From Blank Server to Working Node

A newly created server knows nothing about Kubernetes. The bootstrap process is how it learns who it is and which cluster to join.

The startup data

When the infrastructure provider creates a server, it can hand it a block of text that the server runs on first boot. This is usually in a format called cloud-init, or a similar format for some operating systems. The bootstrap provider writes this text. It contains everything the server needs: files to place on disk, certificates, settings for the Kubernetes agent and commands to run.

For a control plane machine that starts a new cluster, the text tells the machine to initialize the cluster. For every other machine, it tells the machine to join an existing cluster using a time-limited token, the cluster’s address and a fingerprint to check that the cluster is genuine. The bootstrap data is stored in a secret in the management cluster, and the provider passes it to the server at creation.

The join sequence

1

Bootstrap config is generated

When a Machine is created, its bootstrap config object produces the startup data and marks itself ready.

2

The server is created

The infrastructure provider creates the server and passes the startup data. It records the server’s identity, the provider ID, in its status.

3

The server runs the instructions

On first boot, it starts the container runtime and the Kubernetes agent, and contacts the cluster endpoint.

4

A node object appears

The cluster registers a new node. Its provider ID matches the one recorded on the Machine.

5

The Machine links to its node

The core controller finds the node by the matching provider ID and stores a reference to it. From now on, the Machine and the node are tied together.

6

The Machine becomes Running

With a linked, healthy node, the Machine moves into its running phase.

Why the provider ID matters

The provider ID is the glue between two worlds: the cloud’s idea of a server and Kubernetes’ idea of a node. If these cannot be matched, because of a missing cloud integration for example, the Machine never gets its node reference and appears stuck. This is one of the most common reasons for a half-built cluster.

Access to the new cluster

While the cluster is being built, the control plane provider produces a kubeconfig file, which is the document that tells tools where the cluster is and how to authenticate. It is stored as a secret in the management cluster, named after the cluster. Authorized users fetch it to run commands against the workload cluster. The controllers use it too, to look inside the cluster, for example to find nodes.

!
Watch Out

Bootstrap data may contain sensitive material such as join tokens and certificates. Treat the secrets that hold it, and any logs of the first-boot process, as confidential.

i
Good to Know

A node that stays “not ready” for a long time after joining is usually waiting for a network plugin, or for a cloud integration component. These are installed after the cluster exists, and are the main subject of the add-ons chapter.

10Worker Machines: MachineDeployments in Action

Worker nodes carry your applications. Cluster API manages them with the same rolling approach that Kubernetes uses for application pods.

The three layers of workers

A MachineDeployment describes a group of workers: how many, which Kubernetes version, and which templates to use for the infrastructure and the bootstrap. It creates one MachineSet for each version of the template. The MachineSet creates and maintains the individual Machines. When you change the template, the MachineDeployment makes a new MachineSet and slowly moves machines over from the old one.

Templates are immutable

Here is an important rule. Infrastructure and bootstrap templates are not edited after use. If you want workers with a bigger instance size or a different disk, you do not change the existing template. You create a new template and point the MachineDeployment to it. This triggers a rollout that replaces old machines with new ones. The rule keeps history clear and ensures that all machines made from one template are truly identical.

Everyday Analogy

Think of a bakery that bakes bread from a recipe card. Once a batch has been made from a card, nobody scribbles on that card. If the recipe changes, a new card is written, and new batches use it. Old bread is retired as new bread comes out. You can always tell exactly which recipe produced which loaf.

Controlling the pace of change

Setting

Replicas

How many worker machines you want. Changing this number scales the group up or down.

Setting

Max surge

How many extra machines may be created above the desired number during a rollout, so that capacity does not dip.

Setting

Max unavailable

How many machines may be out of service at once while the rollout runs. Zero means a new machine must be ready before an old one goes.

Setting

Drain timeout

How long to wait for pods to leave a node before the machine is removed anyway. Protects against stuck deletions.

Setting

Failure domain

Which zone a group of workers should live in, which helps spread risk across zones.

Setting

Labels and taints

Node properties applied to machines from this group, so that groups can be targeted by workloads, such as a group of large-memory machines.

The life of one Machine

Each Machine reports a phase, which tells you where it is in life. Reading phases is the quickest way to see what is happening.

PhaseMeaning
PendingThe Machine exists but the bootstrap or infrastructure work has not started yet
ProvisioningThe server is being created and is starting up
ProvisionedThe server exists, but its node has not joined the cluster yet
RunningThe server exists and its node has joined and is linked to the Machine
DeletingThe Machine is being removed: its node is being drained and the server deleted
FailedSomething went wrong that cannot be fixed by waiting, and attention is needed

Deletion is careful too

When a Machine is deleted, Cluster API does not just yank the server away. It first cordons the node, which means telling the scheduler to place no new pods on it. Then it drains the node, which means politely evicting the running pods so they move elsewhere, respecting disruption budgets. Only after that does it delete the node object and finally the server itself. This graceful sequence protects your applications during scale-downs and upgrades.

11Upgrades: Replace, Do Not Patch

Upgrading Kubernetes is the task that teams fear most. Cluster API turns it into a repeatable, observable rollout.

The core approach

Cluster API upgrades clusters by replacing machines, not by logging into each one and updating software. To move to a newer Kubernetes version, you change the version field in the description. The controllers then create new machines with the new version and remove old ones, a few at a time. The result is that every machine always matches its description, with no half-upgraded leftovers or hand-made differences.

The order of operations

1

Plan and prepare

Check the version skew rules, read the release notes, test the upgrade on a non-production cluster and make sure backups of etcd or cluster data exist.

2

Create a machine image or template for the new version

For many providers, the image used to create servers must contain the matching Kubernetes components. A new template points to the new image.

3

Upgrade the control plane first

Update the version on the control plane object. The controller adds a new member with the new version, waits for it to be healthy, then removes an old member, one at a time.

4

Upgrade the workers

Update the MachineDeployment. New workers join, pods are drained from old workers, and the old workers are deleted, according to the surge and unavailable limits.

5

Verify

Check node versions, application health and any add-ons that need a matching update.

6

Repeat for the next minor version if needed

Kubernetes supports upgrading one minor version at a time, so a jump across several versions needs several rounds.

flowchart TB
    START["Change version in the description"] --> CPN["Create new control plane machine at the new version"]
    CPN --> CPH{"New member healthy and in quorum?"}
    CPH -->|"yes"| CPD["Remove one old control plane machine"]
    CPH -->|"no"| WAIT["Wait, report condition, retry"]
    CPD --> CPM{"More old control plane machines?"}
    CPM -->|"yes"| CPN
    CPM -->|"no"| WK["Start worker rollout"]
    WK --> WN["Create new worker, respecting max surge"]
    WN --> WD["Drain and delete an old worker, respecting max unavailable"]
    WD --> WM{"More old workers?"}
    WM -->|"yes"| WN
    WM -->|"no"| DONE["Cluster fully upgraded"]
Figure 6 – A rolling upgrade. Control plane first, then workers, always one careful step at a time.

What makes upgrades safe

  • Quorum checks. The control plane controller will not remove a member if doing so would break etcd.
  • Surge. New workers are created before old ones are removed, so total capacity does not drop.
  • Draining and disruption budgets. Pods are moved off gracefully, and applications that define budgets are protected.
  • Pause and resume. A rollout can be paused if something looks wrong.
  • Roll back by replacing. Since machines are disposable, returning to the previous description rolls the fleet back the same way.

Things that still need your attention

  • Applications must tolerate movement. Pods will be evicted and rescheduled. Applications with one replica, no disruption budget or local-only state will feel it.
  • Add-ons must be compatible. The network plugin, storage drivers and cloud integration have their own supported versions.
  • Removed APIs. Newer Kubernetes versions drop old API versions. Check your manifests before upgrading.
  • Cloud limits. Surging needs spare quota for the extra machines.
!
Watch Out

Cluster API upgrades the cluster, not your applications. A cluster upgrade that evicts a fragile application can still cause an outage. Prepare the applications as carefully as you prepare the cluster.

12Self-Healing with Machine Health Checks

Machines fail. Disks die, hosts are retired by the cloud and networks glitch. Cluster API can notice and replace sick machines without waiting for a human.

What a MachineHealthCheck does

A MachineHealthCheck is an object that selects a group of machines by label and describes what “unhealthy” means. The usual rule looks at the node’s ready condition. If a node has been not ready, or has been unreachable, for longer than a stated time, the machine is considered unhealthy. The controller then remediates it, which normally means deleting the Machine. Since the MachineSet that owns it wants a fixed number of machines, it immediately creates a replacement.

Everyday Analogy

Think of a lifeguard at a pool. The lifeguard does not wait for someone to ask for help. They watch for swimmers who have been under water too long, using a clear rule, and then act. A MachineHealthCheck watches the machines against a clear rule and acts.

The important settings

Rule

Unhealthy conditions

Which node conditions count as sick, and for how long. A short timeout reacts fast but may replace machines for brief glitches. A long one is calmer but slower.

Rule

Startup timeout

How long a new machine may take to get a node, before it is judged as a failed start and replaced.

Safety

Max unhealthy

If too many machines look sick at once, remediation stops. This is a safety brake against a wider problem such as a network outage, where replacing everything would make matters worse.

Scope

Selector

Which machines the check applies to, such as only the workers of one cluster, or only the control plane.

Why the safety brake matters

Imagine the link between the management cluster and a workload cluster breaks. From the controllers’ point of view, every node suddenly looks unreachable. Without a brake, the health check would happily delete every machine in the cluster. The max unhealthy setting prevents this: when more than the allowed share of machines look sick, it concludes that something larger is wrong and stops, waiting for a human.

Control plane healing

Control plane machines can be remediated too, but with extra care. The control plane controller only replaces a member if the remaining members keep etcd healthy, and it replaces them one at a time. A cluster with a single control plane machine cannot safely heal itself, which is one more reason to run three in production.

Spreading risk across zones

Self-healing works best when machines are spread across failure domains, such as availability zones. If one zone fails, only the machines in it are lost. The control plane keeps quorum and the workers in other zones keep running, and replacements are created in healthy zones. Planning failure domains in advance turns a disaster into a routine recovery.

flowchart TB
    MON["MachineHealthCheck watches nodes"] --> BAD{"Node unhealthy longer than the timeout?"}
    BAD -->|"no"| OK["Keep watching"]
    BAD -->|"yes"| LIM{"Share of unhealthy machines below the limit?"}
    LIM -->|"no"| STOP["Stop remediation and alert a human"]
    LIM -->|"yes"| DEL["Delete the unhealthy Machine"]
    DEL --> MS["MachineSet notices a missing machine"]
    MS --> NEW["New Machine is created"]
    NEW --> JOIN["New node joins and takes workloads"]
Figure 7 – Self-healing: detect, check the safety brake, replace.

13ClusterClass: Blueprints for Fleets

A single cluster description is made of many objects that point at each other. For one cluster that is fine. For fifty it becomes a pile of nearly identical files. ClusterClass solves this.

The problem of repetition

Suppose you create ten clusters for ten teams. Each needs a Cluster object, a control plane object, an infrastructure cluster object, templates for machines and a MachineDeployment. Copy these ten times with small changes, and soon the copies drift. A fix made in one is forgotten in the others. Reviews become tiring because every change touches dozens of files.

The idea of a class

A ClusterClass is a reusable blueprint. It holds the shared design: the templates for the control plane, the templates for the infrastructure, and the named kinds of worker groups, for example “general” and “high-memory”. Individual clusters then refer to the class and state only what makes them different, such as the Kubernetes version, the number of control plane machines and how many workers of each kind they want. This part of a cluster is called its topology.

Everyday Analogy

Think of a housing developer with a few approved house designs. Each buyer chooses a design and picks the colour, the garden size and the number of garages. The builders do not redraw the plans for each house. A ClusterClass is the approved design, and a cluster’s topology is the buyer’s choices.

Variables and patches

To allow differences without breaking the blueprint, a class can define variables, which are named settings that each cluster may provide, such as an instance size or a region. It also defines patches, which are rules that take the variable values and apply them into the right places in the templates. This keeps the class in control: clusters can customize only what the class permits.

Managed topology: changes by editing one place

When a cluster uses a class, the controllers keep the underlying objects in line with the class and the topology. Change the Kubernetes version in the topology, and the controllers roll the control plane and the worker groups in the right order. Change a worker count, and the right MachineDeployment is adjusted. Update the class itself, and every cluster using it can be brought along, subject to your rollout process. One edit, many consistent results.

flowchart TB
    CC["ClusterClass - shared blueprint"] --> T1["Cluster A topology: version, 3 control plane, 5 general workers"]
    CC --> T2["Cluster B topology: version, 3 control plane, 2 general and 4 high memory workers"]
    CC --> T3["Cluster C topology: version, 1 control plane, 2 general workers"]
    T1 --> O1["Generated Cluster API objects for A"]
    T2 --> O2["Generated Cluster API objects for B"]
    T3 --> O3["Generated Cluster API objects for C"]
Figure 8 – One blueprint, many clusters. Each cluster states only its differences.

Advantages

  • Far less repeated configuration.
  • Consistent clusters across the fleet.
  • Upgrades done by editing one version field.
  • Central control of what clusters may change.

Disadvantages

  • An extra layer of ideas to learn, including variables and patches.
  • Changing a shared class can affect many clusters at once, so it needs careful rollout.
  • Debugging means understanding both the class and the generated objects.
  • Less direct freedom for one-off special clusters.
i
Good to Know

A good rule: write cluster descriptions by hand while you learn, and move to classes when you have more than a handful of similar clusters. Treat class changes like changes to a shared library: review them, test them on a small cluster, then roll them out in waves.

14Scaling and Autoscaling Clusters

Cluster API handles scaling at the machine level. It works together with the pod-level and node-level autoscalers of Kubernetes.

Manual scaling

The simplest scaling is to change a number. Increase the replicas of a MachineDeployment and new machines appear. Decrease it and surplus machines are drained and removed. For the control plane, scaling changes the number of members, which should be done carefully and only between supported counts such as one, three and five.

Automatic scaling with the Cluster Autoscaler

The Kubernetes Cluster Autoscaler has an integration with Cluster API. It treats each MachineDeployment as a node group. When pods cannot be placed because there is not enough room, it increases the replicas of a suitable MachineDeployment. When nodes are underused, it reduces them. You mark each MachineDeployment with minimum and maximum sizes, using annotations, so that the autoscaler can only move within safe bounds.

1

Pods go Pending

Application load grows and the scheduler cannot find room for new pods.

2

The autoscaler picks a group

It chooses a MachineDeployment whose machines would fit the pending pods, within its maximum size.

3

It raises the replica count

The autoscaler writes the new count to the MachineDeployment.

4

Cluster API creates machines

The MachineSet creates new Machines, which boot, join and become nodes.

5

Pods are scheduled

The scheduler places the waiting pods on the new nodes.

Each level of the system does one job. The workload autoscaler asks for more pods, the node autoscaler asks for more machines, and Cluster API builds the machines. They talk through ordinary Kubernetes objects.

Machine pools

Some clouds offer their own scaling groups, such as groups of identical virtual machines that the cloud manages. Cluster API can map a MachinePool to such a group. The cloud then handles creating and replacing machines, and Cluster API watches over the group. This can be faster and cheaper, but it moves some control to the cloud and may be less uniform across providers, so check the maturity of the feature in your provider.

OptionWho manages individual machinesStrengthsThings to watch
MachineDeploymentCluster APIUniform behavior across providers, fine control of rolloutsMachines are created one by one through the provider
MachinePoolThe cloud’s scaling groupUses cloud-native features and may scale fasterLess uniform, depends on provider support and maturity
!
Watch Out

Do not give two controllers authority over the same replica count. If the autoscaler manages a group, do not also have a deployment tool resetting the replicas to a fixed number on every sync. They will fight, and machines will appear and vanish.

15Add-ons and Day-Two Operations

A cluster that merely exists is not yet useful. It needs networking, storage, cloud integration and policy. Cluster API deliberately leaves most of this to other tools, but gives you ways to fit them in.

What a new cluster is missing

Required

Network plugin

Without one, pods cannot talk to each other, and nodes stay not ready. It must be installed soon after the control plane appears.

Usually required

Cloud controller manager

Connects Kubernetes with the cloud, for example to create load balancers for services, and to set the provider ID on nodes.

Usually required

Storage drivers

Allow persistent volumes to be created on the cloud’s disks.

Common

Metrics and autoscaling parts

Components that provide resource metrics to autoscalers, and the autoscalers themselves.

Common

Policy, security and observability

Admission policies, runtime security agents, logging and monitoring stacks that every cluster of the organization should have.

Common

Access control

Roles, bindings and sign-in integration so people can use the cluster safely.

Ways to install add-ons

  • ClusterResourceSet. A built-in feature that applies a bundle of resources, such as a network plugin’s manifests, to every new cluster matching a label. It is simple, and good for the first essentials. It is mostly “apply once” and does not manage later updates of the add-ons well.
  • Add-on providers. Community add-on providers install packages such as Helm charts into workload clusters and keep them in step with a declared version.
  • GitOps tools. A tool running in the management cluster, or in each workload cluster, applies the add-ons from a repository and keeps them reconciled. This is the most popular approach for fleets because it handles updates and drift too.
  • Baked into images. Some teams include certain components in the machine image or bootstrap data. This is quick but ties add-on updates to machine replacement.

The ordering challenge

Add-ons depend on each other and on the cluster state. The network plugin must exist before pods can start. The cloud controller manager must exist before nodes get their provider IDs and become ready. Storage drivers need the cloud integration. If you install them in the wrong order or too late, nodes sit not ready, and the Machines appear stuck. Plan a clear startup sequence for each cluster type and test it end to end.

Day-two tasks

  • Certificate renewal. Certificates expire. The control plane controller can renew them as machines are replaced, and can be set to rotate machines that are close to expiry.
  • Operating system patching. Because machines are replaced, security patches reach the fleet by building new images and rolling the machines, which is cleaner than patching in place.
  • Backups. Back up etcd or cluster state for workload clusters, as well as the management cluster’s own objects.
  • Cost control. Track which clusters exist, who owns them and when they should be removed.
  • Decommissioning. Deleting a Cluster object removes the machines and the cloud resources it created, in order, which prevents leftover costs.
i
Good to Know

Define a standard “cluster baseline” of add-ons, put it under version control, and apply it to every cluster the same way. Then a new cluster is truly ready for use minutes after it is created, not days.

16The Management Cluster as a Critical System

The management cluster holds the keys to your whole fleet. Designing it for safety and recovery is one of the most important decisions you will make.

What happens if it is lost?

Here is a comforting fact. Workload clusters keep running if the management cluster is down. Their control planes and nodes do not depend on the controllers for their daily operation. Applications continue to serve users. However, you lose the ability to create, upgrade, scale and automatically heal those clusters until the management cluster comes back. If a machine fails during that time, nothing replaces it.

The bigger danger is data loss. The management cluster stores the descriptions, the certificate authorities and the kubeconfig secrets of every workload cluster. If those are lost with no backup, you may be unable to manage or even reach your clusters.

Protecting it

Resilience

High availability

Run the management cluster with a multi-member control plane across zones, and run controllers with more than one replica where supported.

Recovery

Backups

Back up the management cluster regularly, including Cluster API objects and secrets, using tools for cluster backups, and test restoring them.

Recovery

Source of truth in Git

Keep cluster descriptions in a repository. Then the management cluster can be rebuilt and re-pointed at the same descriptions.

Isolation

Limit access

Only a small team should be able to change the management cluster. Everyone else works through reviewed changes to the repository.

Self-managed clusters and the pivot

A common pattern is to start with a temporary management cluster, create a real cluster with it, and then move the Cluster API controllers and objects into that new cluster. This is the pivot, done with the clusterctl move command. After it, the new cluster manages itself, and the temporary one can be discarded. Self-managed clusters reduce the number of systems to look after, but they have a delicate property: a broken cluster may have lost the very controllers needed to fix it. Keep strong backups and a rebuild plan for this case.

Layouts for the management layer

LayoutDescriptionGood forTrade-off
Single centralOne management cluster for all workload clustersSmall and medium fleets, simple operationsA single point of risk and a large blast radius
Per environmentSeparate management clusters for production and non-productionProtecting production from mistakes made while experimentingMore clusters to look after
Per regionA management cluster in each region or data centreLatency, data rules and limiting regional failuresNeeds consistent tooling across regions
Self-managedEach cluster manages itself after a pivotEdge sites and very independent clustersHarder recovery when a cluster is broken
!
Watch Out

Treat the management cluster like the root key of your organization’s infrastructure. It holds cloud credentials with power to create and destroy machines. A break-in there is a break-in everywhere.

17GitOps for a Fleet of Clusters

Cluster API turns clusters into data. Once clusters are data, all the habits of good software delivery apply to them.

The pattern

In a GitOps setup, a Git repository holds the desired state, and a tool inside the cluster continuously compares the repository with the live objects and fixes differences. For clusters, this means the cluster descriptions live in Git. A pull request that adds a cluster file creates a cluster. A change of version upgrades it. Removing the file removes the cluster. Everything is reviewed, recorded and reversible.

flowchart LR
    DEV["Engineer opens a pull request"] --> REV["Review and approval"]
    REV --> GIT["Git repository: cluster descriptions"]
    GIT --> SYNC["GitOps tool in management cluster"]
    SYNC --> CAPI["Cluster API objects"]
    CAPI --> CTRL["Cluster API controllers"]
    CTRL --> FLEET["Workload clusters created, upgraded, repaired"]
    FLEET -.->|"status"| CAPI
Figure 9 – GitOps for clusters. Every change to the fleet goes through review.

Benefits

  • Audit trail. Every cluster change has an author, a reviewer and a date.
  • Easy rollback. Revert a commit, and the fleet follows.
  • Self-service with guard rails. Teams request clusters by opening a pull request against an approved class, and checks verify that they stay within policy.
  • Disaster recovery. The repository is a complete record of what should exist.
  • Consistency. The same process creates every cluster, so drift disappears.

A sensible repository layout

Folder

Classes

The shared ClusterClass blueprints and their templates, owned by the platform team.

Folder

Clusters

One small file or folder per cluster, holding its topology and any environment-specific values.

Folder

Add-on baselines

The standard bundle of add-ons applied to clusters, separated by cluster type.

Folder

Policies

Rules that check pull requests, such as allowed versions, regions and machine sizes.

Promotion across environments

Treat cluster upgrades like application releases. A new Kubernetes version or a class change first goes to a development cluster, then to staging clusters, then to production in waves. Each wave is a separate pull request, with checks between them. This slow, observable path replaces a risky big-bang upgrade with a series of small, reversible steps.

i
Good to Know

Name and label clusters consistently, with owner, environment, region and purpose. Labels let you select groups of clusters for upgrades, health checks, policies and cost reports, and they turn a pile of clusters into an organized fleet.

18Security of the Cluster Factory

A system that can build and destroy clusters is a very attractive target. Security here means protecting both the factory and its products.

What is at stake

Asset

Cloud credentials

The infrastructure provider holds permission to create networks, servers and disks. Stolen, these let an attacker run up costs or delete everything.

Asset

Cluster certificate authorities

The secrets that sign each cluster’s certificates. Anyone holding them can mint administrator access to that cluster.

Asset

Kubeconfig secrets

Ready-made administrator access files for the workload clusters, stored in the management cluster.

Asset

The descriptions themselves

Whoever can edit them can create machines, change versions or delete clusters. Write access to the repository is power over the fleet.

Protective measures

  • Least-privilege cloud permissions. Give the provider only the rights it needs, scoped to specific accounts, regions or resource groups. Avoid broad administrator keys.
  • Separate identities per team or environment. Many providers let a cluster refer to its own credentials. Then a team’s cluster uses a team-scoped identity, so a mistake or break-in in one area cannot reach the rest.
  • Short-lived credentials. Prefer identity systems that issue temporary credentials over long-lived keys, where the provider supports them.
  • Encrypt secrets at rest in the management cluster and restrict who can read secrets. Reading a kubeconfig secret is the same as being an administrator of that workload cluster.
  • Strong role-based access control. Few people should be able to edit Cluster API objects directly. Most changes should flow through reviewed repository changes.
  • Network isolation. Limit which networks can reach the management cluster’s API. The controllers need to reach workload clusters, but ordinary users usually do not need to reach the management cluster at all.
  • Audit logging. Record all changes to the management cluster, and alert on unusual actions such as bulk deletions.
  • Supply chain care. The providers and controllers are software you run with high privilege. Install them from trusted sources, verify image signatures, pin versions and update promptly when security fixes arrive.
  • Protect deletion. Consider extra approval steps for deleting production clusters, because a single mistaken delete can remove a whole environment.
Everyday Analogy

Think of a factory that makes safes. Guarding each safe is important. But the master keys, the blueprints and the machines that cut new locks are even more valuable. The management cluster is that room. It deserves the strongest door in the building.

Security of the workload clusters themselves

Cluster API builds clusters with sensible defaults, but it does not replace a security baseline. Use hardened machine images, enable audit logging on the control plane, apply pod security rules, restrict network traffic with policies, encrypt secrets stored in etcd, and rotate certificates. Capture these choices in the class or template, so every new cluster starts secure rather than relying on a post-creation checklist.

Tenancy

If many teams request clusters through the same management cluster, make sure teams cannot see or change each other’s clusters. Use namespaces per team for the Cluster API objects, role bindings that restrict access to those namespaces and policies that limit which classes, regions and machine sizes each team may use.

!
Watch Out

Backups of the management cluster contain the same sensitive secrets. Encrypt them, restrict access to them and store them separately from the cluster itself.

19Observability and Troubleshooting

When a cluster refuses to appear or an upgrade stalls, you need to know exactly where to look. Cluster API is designed to explain itself, if you know how to read it.

The language of conditions

Every Cluster API object reports conditions, which are short statements about its state with a reason and a message. They roll up through the family tree. A Cluster is ready only if its control plane and infrastructure are ready, and the control plane is ready only if its machines are ready. When something is wrong, the conditions point toward the failing part. The clusterctl describe cluster command draws this tree for you, with the health of each object.

What to watch

Signal

Cluster and Machine conditions

The first place to look. They show which stage is blocked and why, often naming the exact cloud error.

Signal

Machine phases

Machines stuck in Provisioning or Provisioned point to server creation or node join problems.

Signal

Events

Kubernetes events on the objects record each attempt and failure in time order.

Signal

Controller logs

The logs of the core and provider controllers contain detailed error messages, such as quota or permission failures.

Signal

Controller metrics

Reconcile durations, error counts and queue lengths show whether the controllers are healthy and keeping up.

Signal

Workload cluster health

The control plane’s own health, etcd status and node conditions, observed from inside the workload cluster.

Troubleshooting walk-through

1

Cluster stuck before the control plane appears

Look at the infrastructure cluster object. Common causes are missing cloud permissions, exhausted quotas, invalid network ranges or a load balancer that could not be created.

2

Machine stays in Provisioning

The server may not be created. Check the infrastructure machine object and the provider logs for errors about images, instance types, capacity or permissions.

3

Machine reaches Provisioned but never Running

The server exists but its node has not joined. Check the bootstrap data, the network path to the cluster endpoint, the join token’s lifetime, time synchronization and whether the provider ID matches.

4

Nodes join but stay not ready

Almost always a missing network plugin or cloud integration. Look at node conditions and the pods in the system namespace of the workload cluster.

5

Upgrade is stuck

Look for a new machine that cannot start, a drain that cannot finish because of a strict disruption budget, or an etcd health problem that makes the controller refuse to continue.

6

Deletion hangs

A Machine or Cluster that will not delete is usually waiting for a finalizer, for example a cloud resource that could not be removed or a node that cannot be drained. Find what it is waiting for before forcing anything.

7

Machines keep being replaced

A health check is replacing machines repeatedly. The cause may be an add-on problem that makes new nodes never become ready, or a rule that is too strict. Check the check’s thresholds and the reason nodes are unhealthy.

!
Watch Out

Never remove a finalizer by hand just to make an object disappear, unless you have checked what it protects. Doing so can leave real servers and disks running in your cloud, silently costing money, with no object left to track them.

i
Good to Know

Alert on a few simple things: Machines stuck in a phase for too long, Clusters not ready after a set time, controllers restarting often, and health checks that hit their maximum unhealthy limit. Together they catch most problems early.

20Advantages, Disadvantages and Alternatives

Cluster API is powerful, but it is not the right tool for every team. An honest ledger will help you decide.

Advantages

  • Declarative, version-controlled clusters that use familiar Kubernetes tools.
  • Continuous reconciliation, so drift and failures are corrected automatically.
  • Consistent lifecycle across clouds and data centres through the provider model.
  • Safe, rolling upgrades and self-healing as built-in behaviors.
  • Strong fit for fleets, with blueprints and GitOps.
  • Open source with an active community and many providers.

Disadvantages

  • A real learning curve with many objects and ideas.
  • You must run and protect a management cluster.
  • Provider quality and features vary between platforms.
  • Does not decide networking, storage or add-ons for you.
  • Debugging crosses several controllers and providers.
  • Overkill for one or two small clusters.

Compared with other approaches

ApproachBest atWeaker at
Cluster APIManaging many clusters continuously with a common model across platformsSimplicity for small setups, needs a management cluster
Infrastructure as code with TerraformBroad infrastructure beyond clusters, with a large ecosystem and familiar workflowContinuous healing and rolling replacement logic must be built separately
Cluster installers such as kOpsQuickly standing up clusters on a specific cloudCross-platform consistency and continuous reconciliation
Managed Kubernetes servicesLow operational burden, the cloud runs the control planePortability, and some control over version timing and settings
Vendor platformsIntegrated experience with supportCost and lock-in, though many are built on Cluster API

They can work together

These choices are not strict opposites. Cluster API has providers that create managed Kubernetes clusters on major clouds, so you can keep the same declarative habits while the cloud runs the control plane. Teams also use Terraform to create the management cluster and its surrounding network, and then Cluster API for the workload clusters. The right mix depends on your size, your skills and how many platforms you must support.

i
Good to Know

A rough rule of thumb: if you manage a handful of clusters on a single cloud with a managed service, you may not need Cluster API. If you manage many clusters, several platforms, edge sites or your own bare metal, it starts to repay its learning cost quickly.

21Patterns, Anti-Patterns and Best Practices

Teams that succeed with Cluster API repeat a small set of habits. Teams that struggle repeat a small set of mistakes.

Patterns that work

Pattern

Immutable machines

Never patch machines by hand. Change the template or image and let the controllers replace them.

Pattern

Golden classes

Define a few well-tested ClusterClasses for common needs and let teams choose, instead of letting every team invent a design.

Pattern

Wave-based upgrades

Upgrade a development cluster first, then staging, then production in groups, with checks and pauses between waves.

Pattern

Baseline add-on bundle

Apply the same networking, storage, policy and observability baseline automatically to every new cluster.

Pattern

Spread across failure domains

Place control plane and worker machines across zones so a zone loss is a routine event.

Pattern

Protected management layer

Keep the management cluster small, locked down, backed up and separated per environment for production.

Anti-patterns to avoid

ANTI-PATTERN 01Avoid
What it looks like

An engineer logs into a worker machine to fix a setting or install a tool by hand, because it is the quickest way to solve today’s problem.

Why it hurts

That machine now differs from its description. At the next rollout or health-check replacement, the fix vanishes, and nobody remembers why things worked.

Better approach

Make the change in the template, image or bootstrap configuration, and let the controllers roll it out.

ANTI-PATTERN 02Avoid
What it looks like

One management cluster with no backups manages every cluster in the company, and all engineers have administrator access to it.

Why it hurts

A single mistake or break-in affects the entire fleet, and a loss of the cluster could mean losing the certificates and access to everything.

Better approach

Back up regularly and test restores, limit access, keep the descriptions in Git and separate production management from experiments.

ANTI-PATTERN 03Avoid
What it looks like

Health checks are enabled with no limit on how many machines may be unhealthy, and a short timeout.

Why it hurts

A short network outage makes every node look unhealthy, and the controller starts deleting machines across the cluster, turning a small glitch into a major outage.

Better approach

Set a sensible timeout and a maximum unhealthy limit, and test the behavior in a non-production cluster.

ANTI-PATTERN 04Avoid
What it looks like

A shared ClusterClass is edited and rolled to every cluster at once, including production, with no staged rollout.

Why it hurts

A mistake in the shared blueprint reaches the whole fleet at the same moment, and recovery means fixing dozens of clusters in a hurry.

Better approach

Version classes, introduce changes to a small group first, and roll out in waves with checks.

Best practices at a glance

  • Start small. Learn with a local development setup, then a single real cluster, and add classes and fleet features as your needs grow.
  • Keep everything in Git, reviewed and versioned, with automated checks on every change.
  • Plan networking and add-ons first. Know how nodes will become ready before you create the first production cluster.
  • Use odd control plane counts of three or five, spread across zones.
  • Test upgrades regularly, not only when forced. Frequent small upgrades are safer than rare large ones.
  • Prepare applications for movement with multiple replicas, disruption budgets and readiness checks.
  • Monitor the controllers as production services in their own right.
  • Control credentials tightly, using least privilege and separate identities.
  • Practice disaster recovery. Rebuild a management cluster from backups and Git at least once before you need to.
  • Track version support. Keep Cluster API, providers and Kubernetes within supported combinations.

Common mistakes

  • Expecting Cluster API to choose and install networking and storage by itself.
  • Running a single control plane machine in production.
  • Editing machine templates in place instead of creating new ones.
  • Forgetting cloud quotas, so surge machines or new clusters cannot be created.
  • Skipping backups of the management cluster and its secrets.
  • Forcing finalizers off and leaving orphaned cloud resources.
  • Upgrading across several minor versions in one jump.
  • Letting two tools control the same replica count.

22Real-World Usage

Cluster API is used both directly by platform teams and as a building block inside commercial products.

Internal platform teams

Companies that run many clusters, for different teams, regions and environments, use Cluster API to give developers self-service clusters. A developer opens a pull request that picks an approved blueprint and a size, and automation creates a ready-to-use cluster with the standard baseline of add-ons. The platform team keeps one process for all clusters instead of one script per cloud.

Vendor platforms built on the project

Several commercial Kubernetes platforms use Cluster API under the hood for lifecycle operations. VMware’s Tanzu Kubernetes products are a well-known example. Other management platforms, such as those from SUSE and Mirantis, offer integrations or build their offerings around the same machine model. This shows that the project has become a common foundation, not just a tool for enthusiasts.

Bare metal and private data centres

Organizations running their own hardware use infrastructure providers that manage physical servers, such as the Metal3 project, which uses standard hardware management interfaces to provision machines. Cluster API then treats a physical server like any other Machine, giving data centre fleets the same rolling upgrades and self-healing as cloud clusters.

Multi-cloud and hybrid estates

Teams with workloads in several clouds and on-premises sites use the shared object model to keep a similar operating routine everywhere. The provider differences remain, but upgrade procedures, health checks and blueprints look the same, which lowers the training burden and reduces mistakes.

Edge and many small sites

Retail stores, factories and remote offices often need a small cluster each. With self-managed or regionally managed patterns, Cluster API lets a central team define the design once and roll out and upgrade it across hundreds of sites in controlled waves.

Test and CI environments

Because clusters are cheap to describe, build pipelines create short-lived clusters on demand to test software against specific Kubernetes versions, then delete them. The Docker based provider makes this fast on a developer laptop or a build server.

23Frequently Asked Questions

Short answers to the questions that new users ask most often.

Q1What is Cluster API in one sentence?
It is a Kubernetes project that lets you describe clusters as Kubernetes objects and uses controllers to create, upgrade, repair and delete those clusters on many different infrastructures.
Q2Do I need Cluster API to run Kubernetes?
No. Many teams run a few clusters with a managed service or a simple installer. Cluster API pays off when you manage many clusters, several platforms or your own hardware, and want consistent, automated lifecycle management.
Q3What is the difference between a management cluster and a workload cluster?
The management cluster runs the Cluster API controllers and stores the descriptions of clusters. Workload clusters are the clusters it creates and maintains, where your applications run.
Q4Is a Machine the same as a Node?
No. A Machine is a Cluster API object that represents a server and how it is created. A Node is the Kubernetes object that appears in the workload cluster once the server has joined. Cluster API links each Machine to its Node using the provider ID.
Q5What happens to my applications if the management cluster goes down?
Workload clusters keep running and serving traffic. What you lose is lifecycle automation: no creating, upgrading, scaling or automatic repair until the management cluster returns. This is why you must back it up and protect it.
Q6How does Cluster API upgrade a cluster?
You change the Kubernetes version in the description. The controllers create new machines at the new version and remove old ones, control plane first and then workers, one careful step at a time, draining nodes and checking etcd health on the way.
Q7Can Cluster API repair a failed node automatically?
Yes, with a MachineHealthCheck. It detects nodes that stay unhealthy past a timeout and deletes their Machines, so that the owning MachineSet creates replacements. A maximum unhealthy setting stops it from acting during large outages.
Q8Does it install the network plugin and other add-ons?
Not by itself. It builds the cluster. You install networking, storage drivers and other add-ons using ClusterResourceSets, add-on providers or GitOps tools. Plan this ahead, since nodes stay not ready until a network plugin exists.
Q9Can I use it with managed services such as EKS, AKS or GKE?
Several providers support managed Kubernetes variants, so you can keep the same declarative approach while the cloud runs the control plane. Feature coverage varies by provider, so check the current documentation of the one you plan to use.
Q10What is a ClusterClass and do I need one?
It is a reusable blueprint for clusters, with variables and patches for allowed differences. You do not need one for a few clusters. It becomes valuable when many clusters share the same design and you want consistent upgrades from one place.
Q11Why does Cluster API replace machines instead of updating them?
Replacing makes every machine match its description exactly, removes hidden hand-made differences and makes rollbacks simple. It follows the immutable infrastructure idea, treating machines as disposable.
Q12How do I get started safely?
Begin with the local development provider to learn the objects and flows. Then create one test cluster on your real platform, practice an upgrade, a node failure and a deletion, and add backups, GitOps and blueprints before running anything important.

24Summary and Key Takeaways

What to remember

  • Clusters have a whole lifecycle. Create, scale, upgrade, repair and retire. Doing this by hand across many clusters causes drift, slow upgrades and fragile knowledge.
  • Cluster API uses Kubernetes to manage Kubernetes. A management cluster runs controllers that read cluster descriptions and build and maintain workload clusters.
  • The objects mirror what you already know. Machine, MachineSet and MachineDeployment behave like Pod, ReplicaSet and Deployment, with templates that are created new rather than edited.
  • Providers hide platform differences. Core, infrastructure, bootstrap and control plane providers cooperate through a public contract, so the same habits work on clouds, virtualization and bare metal.
  • Upgrades and repairs are rolling replacements. Control plane first, then workers, with quorum checks, surge, draining and health checks that have safety brakes.
  • Fleets need blueprints and GitOps. ClusterClass removes repetition, and a reviewed repository gives audit trails, rollbacks and waves of upgrades.
  • Protect the factory. The management cluster holds cloud credentials, certificate authorities and kubeconfigs. Back it up, lock it down and separate production from experiments, and remember that Cluster API automates decisions you still have to make.