This repository contains an opinionated script to create a Kubernetes cluster using the Cluster API on a few infrastructure providers.
🎉 This is the successor of k8s-caph-talos
. 🎉
After creating a local bootstrap cluster, the workload cluster is created. At the end of the rollout, the management services are moved into the workload cluster.
The resulting cluster will be able to manage itself as well as create new clusters.
Infrastructure providers: docker, hetzner, vsphere
CNI: cilium
capictl
supports a number of options to configure the cluster. The following command will create a cluster with the default configuration:
bash capictl -n my-cluster
The following settings are supported:
Option | Variable | Default | Description |
---|---|---|---|
-n |
CLUSTER_NAME |
The name of the cluster | |
-v |
KUBERNETES_VERSION |
(latest) | The version of Kubernetes to deploy |
-b |
BOOTSTRAP_CLUSTER_PROVIDER |
kind |
The provider for the bootstrap cluster (valid values are kind , k3d ) |
-i |
WORKLOAD_PROVIDER |
docker |
The provider for the workload cluster (valid values are docker , hetzner , vsphere ) |
-p |
CNI_PLUGIN |
cilium |
The CNI plugin to use (valid values are cilium ) |
-x |
POD_CIDR |
10.42.128.0/17 |
The CIDR for pods |
-y |
SERVICE_CIDR |
10.42.0.0/17 |
The CIDR for services |
-c |
CONTROL_PLANE_NODE_COUNT |
1 |
The number of control plane nodes |
-w |
WORKER_NODE_COUNT |
2 |
The number of worker nodes |
All variables can be configured through a .env
file as well (including the provider specific variables described below).
The corresponding kubeconfig
file is stored in the current directory as kubeconfig-${CLUSTER_NAME}
.
The following provider specific variables are supported:
See the Hetzner Cloud provider documentation.
The following default values are configured:
Variable | Default | Description |
---|---|---|
HCLOUD_REGION |
fsn1 |
The Hetzner Cloud region |
HCLOUD_CONTROL_PLANE_MACHINE_TYPE |
cx21 |
The Hetzner Cloud control plane machine type |
HCLOUD_WORKER_MACHINE_TYPE |
cx21 |
The Hetzner Cloud worker machine type |
See the vsphere provider documentation.
The script relies on a number of binaries to work:
docker
envsubst
jq
kind
ork3d
kubectl
hcloud
clusterctl
cilium
Those prerequisites can be installed with uniget
.
This is how the script works:
- Create a bootstrap cluster using
kind
ork3d
- Initialize Cluster API in the bootstrap cluster
- Generate a cluster configuration for the workload cluster
- Wait for the control plane to initialize
- Deploy Cilium
- Deploy necessary components, e.g. cloud controller manager and CSI
- Wait for the controle plane to be ready
- Wait for the worker nodes to be ready
- Initialize Cluster API in the workload cluster
- Move the cluster configuration to the workload cluster
- Create a
kubeconfig
for the workload cluster with a dedicated service account
- Talos
- Idempotency (being able to restart and pick up where it left off)
- Configure CIDRs for pods and services
- Test
kubectl wait
- Support infrastructure docker?
- Support infrastructure vcluster?
- Check out Cluster API Operator