mirror of
https://github.com/apricote/apricote.de.git
synced 2026-01-13 20:51:02 +00:00
3.9 KiB
3.9 KiB
| author | title | date | summary | description | tags | ShowBreadCrumbs | cover | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Julian Tölle | Building a Kubernetes cloud-controller-manager | 2023-09-06 | A tutorial series to showcase the steps needed to build a Kubernetes Cloud Controller Manager. Intended to be your guide into better Kubernetes-compatibility for your own Infrastructure-as-a-Service Cloud. | This tutorial series tries to showcase the steps needed to build a first iteration of a Kubernetes Cloud Controller Manager. It can be adapted to any Cloud Provider and may be your guide into better Kubernetes-compatibility for your own Infrastructure-as-a-Service Cloud. |
|
true |
|
{{< collapse summary="Disclaimers" openByDefault=true >}}
Work
I [work for Hetzner Cloud]({{< ref "/work" >}}) and this project was done during working hours as part of the Lab Days. During Lab Days, employees can spend time on projects unrelated to their work.
Production Readiness
The code written in this series is not ready for production.
You should not actually use the code provided here for your Kubernetes Cluster on Hetzner Cloud.
Please use the official hcloud-cloud-controller-manager instead.
{{</ collapse >}}
Introduction
What is a Cloud Controller Manager?
- Controllers: Loop that reconciles reality with the desired state
- Controller Manager: Binary that runs a bunch of controllers
- Cloud Controller Manager: Part of the Kubernetes Control Plane, responsible for exposing Cloud Provider functionality inside the Kubernetes cluster.
- Controllers in CCMs:
- Node Metadata
- Match Kubernetes
Nodeto Cloud API Server (/Instance/Droplet/...) and setspec.providerID - Label Kubernetes
Nodeswith metadata of the Node, including the Instance Type, Topology (Region, Zone) - Figure out the Network addresses of the
Nodeand set them instatus.addresses.
- Match Kubernetes
- Node Lifecycle
- The
kubeletis usually responsible for creating theNodeobject in Kubernetes on its first startup. - This does not work well for the removal of the node, as the
kubeletmight not get a chance to do this. Instead, the Node Lifecycle controller regularly checks if the Node was deleted in the Cloud API, and if it was it also deletes theNodeobject in Kubernetes.
- The
- Service
- Watches
Serviceobjects withtype: LoadBalancer. Creates Cloud Load Balancers and configures them according to theServiceandNodeobjects
- Watches
- Route
- In Kubernetes, every Pod gets an IP address. This IP address needs to be available from every other pods network (by default). This is usually implemented as an Overlay Network through your CNI like Calico or Cilium.
- If you are already using some kind of Private Networking functionality of your Cloud Provider, then you can use this instead to get rid of the additional Overlay Network and let the Cloud Provider handle the connectivity.
- This is implemented by configuring Routes in the Private Network Routing Table that send all traffic to the
Nodesspec.podCIDRto theNodesprivate IP.
- Node Metadata
What is the Hetzner Cloud?
- IaaS with: Servers, Load Balancers, Private Networks
Parts
This project got way longer than I expected, so I split everything up into 5 parts:
