Welcome to the secret kitchen of Cloud Providers! This lab is designed to pull back the curtain on how Hyperscalers automate the creation and management of thousands of Kubernetes clusters.
By combining Cluster API (CAPI), Sveltos, and Cilium, you are building a full-blown Kubernetes-as-a-Service platform on your local machine. You won't just learn how to use Kubernetes; you will learn how to provide it as a service, automated from infrastructure to networking.
graph TD
subgraph "Management Cluster (k3d)"
CAPI[CAPI Controllers]
CAPD[Docker Infrastructure Provider]
Sveltos[Sveltos Manager]
YAML[Cluster Manifests]
end
subgraph "Docker Host"
Network[Kind/Docker Bridge Network]
Peering[Network Peering: k3d <--> kind]
end
subgraph "Workload Cluster (Containers)"
CP[Control Plane Node]
Worker[Worker Node]
Cilium[Cilium CNI - eBPF]
Goldpinger[Goldpinger Mesh]
end
%% Provisioning flow
YAML --> CAPI
CAPI --> CAPD
CAPD --> CP
CAPD --> Worker
%% Add-ons flow
Sveltos -- "Remote Management" --> CP
Sveltos --> Cilium
Sveltos --> Goldpinger
%% Networking
CP --- Network
Worker --- Network
Peering --- Network
A lightweight k3s cluster running in Docker. It acts as the Control Plane of the Control Planes, hosting all the operators and controllers.
- Cluster API: Extends Kubernetes with Custom Resource Definitions (CRDs) to manage clusters as objects.
- CAPD (CAPI Provider Docker): The infrastructure provider that translates CAPI
Machineobjects into Docker containers. It uses specializedkindnode images that run a fullsystemdinit system inside the container.
A powerful add-on manager for Kubernetes. In this lab, Sveltos is configured in Centralized Mode: agents run on the management cluster and remotely manage the workload clusters. It uses a Label-based selector to automatically target new clusters.
- Cilium: A CNI (Container Network Interface) powered by eBPF. It replaces traditional
iptablesfor faster and more secure networking. - Hubble: Provides deep observability of network flows at Layer 3, 4, and 7.
When running Kubernetes inside Docker (CAPD/Kind), each node is a container running a full systemd init process.
- Problem:
systemd,kubelet, andcontainerduse inotify (a Linux kernel subsystem) to monitor file system events. Since all nodes share the host's kernel, the default limits (usually 128 instances) are quickly exhausted, causing workers to crash withToo many open files. - Solution: We increase
max_user_instances(number of monitoring programs) andmax_user_watches(number of files watched) on the host.
sudo sysctl fs.inotify.max_user_instances=512
sudo sysctl fs.inotify.max_user_watches=524288This lab involves two distinct Docker networks:
- k3d network: Where the management cluster lives.
- kind network: Where the workload clusters are created by CAPD.
By default, these networks are isolated. Our bootstrap script performs a Network Peering by connecting the k3d management node to the
kindnetwork. This allows the CAPI and Sveltos controllers to reach the API Server of the workload clusters at their internal Docker IP.
./bootstrap/01-init-management-cluster.shWhat happens technically?
- k3d Cluster Creation: Spins up the management node.
- CAPD Initialization: Runs
clusterctl init, which deploys the CAPI core controllers and the Docker infrastructure provider. - Networking: Creates the
kindbridge network and attaches the management node to it.
./bootstrap/02-install-sveltos.shWhat happens technically?
- Operator Deployment: Installs Sveltos controllers in the
projectsveltosnamespace. - ClusterProfiles: Registers the
install-ciliumandinstall-goldpingerprofiles. These are blueprints that tell Sveltos: "If you see a cluster with the label cni=cilium, deploy this Helm chart".
kubectl apply -f clusters/workload-01.yaml --kubeconfig ./capi-management.kubeconfigWhat happens technically?
- CAPI Reconciliation: The CAPI controllers see the new
ClusterandDockerMachineobjects. - Infrastructure Provisioning: CAPD starts Docker containers for the Control Plane and Workers.
- Kubeadm Bootstrapping: Inside the containers,
kubeadmis executed to initialize the Kubernetes cluster. - Sveltos Detection: Sveltos detects the new cluster via CAPI events, matches the labels, and starts pushing Cilium and Goldpinger.
kubectl port-forward -n kube-system ds/goldpinger 8080:8080 --kubeconfig ./workload-01.kubeconfigAccess http://localhost:8080 to see the real-time mesh connectivity between all nodes.
kubectl port-forward -n kube-system svc/hubble-ui 12000:80 --kubeconfig ./workload-01.kubeconfigAccess http://localhost:12000 to inspect Layer 7 traffic and network policies.
./bootstrap/00-cleanup.shRemoves all workload containers (via Docker labels), deletes the kind network, and destroys the k3d cluster.