Creating clusters

Step 1: Applying the Cluster Stack

A Cluster Stack is like a blueprint for all objects and configuration needed to create a cluster. For each release, this objects and configurations are heavily tested by Syself to guarantee integrity and interoperability.

The first step for cluster creation is making a Cluster Stack Release available. Create a file named clusterstack.yaml , with the following content:

clusterstack.yaml yaml
apiVersion: clusterstack.x-k8s.io/v1alpha1 kind: ClusterStack metadata: name: hetzner-apalla-1-29 spec: provider: hetzner name: apalla kubernetesVersion: '1.29' channel: stable // [!code tooltip:true:1:This means new releases will be automatically available] autoSubscribe: true providerRef: name: hetzner-apalla-1-29 kind: HetznerClusterStackReleaseTemplate apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1 --- apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1 kind: HetznerClusterStackReleaseTemplate metadata: name: hetzner-apalla-1-29 spec: template: spec: nodeImages: - controlplaneamd64hcloud - workeramd64hcloud

And apply it to the management cluster:

When a ClusterStack is applied, a ClusterStackRelease is created from it, and the necessary components starts to be prepared in your Hetzner account. In our case, we applied a ClusterStack with autoSubscribe set to true, so it'll fetch the latest release and create the ClusterStackRelease object based on that. You don't need to interact directly with the release.

It takes around 5 minutes for the ClusterStackRelease to be ready, as the node images are being built. You can check the status of these node images by running kubectl get HetznerNodeImageReleases . These objects have a one-to-one relationship with the snapshots in your Hetzner project, which you can view under Servers / Snapshots in the Hetzner Console.

note

If you already have a ClusterStack applied from a previous cluster, there is no need to apply it again since the HetznerNodeImageReleases and ClusterStackRelease are already there. You can use the same release and node images for any number of clusters.

After the node images are successfully built, the ClusterStackRelease hetzner-apalla-1-29-v4 will be ready for you to use in your cluster. Check with:

Step 2: Creating your cluster

Now that we have a Cluster Stack Release ready, we can create a cluster from it. For that, create a cluster.yaml file with the contents below, replacing the <SSH_KEY_NAME> with the one you configured in the Account Preparation guide:

cluster.yaml yaml
apiVersion: cluster.x-k8s.io/v1beta1 kind: Cluster metadata: // [!code tooltip:mycluster:1:Use any meaningful name for your cluster] name: mycluster spec: clusterNetwork: services: cidrBlocks: ['10.128.0.0/12'] pods: cidrBlocks: ['192.168.0.0/16'] serviceDomain: 'cluster.local' topology: class: hetzner-apalla-1-29-v4 version: v1.29.6 controlPlane: // [!code tooltip:3:1:We are using three replicas to have a highly available controlplane. Feel free to change it!] replicas: 3 workers: machineDeployments: - class: workeramd64hcloud name: md-0 // [!code tooltip:1:1:We are using one replica to speed up the provisioning. You can also change this!] replicas: 1 failureDomain: nbg1 variables: overrides: - name: workerMachineTypeHcloud value: cx31 variables: - name: region value: nbg1 - name: controlPlaneMachineTypeHcloud value: cx31

And apply it to the management cluster with:

Cluster creation will take a few more minutes. You can monitor the process by looking at the machine objects:

These represent actual machines in your Hetzner project. If all of them are in the Running phase, it means your cluster is ready!

Step 3: Accessing your cluster

To get the kubeconfig of your workload cluster, you can use the command:

When accessing your cluster, you may see some pods still pending. This is normal, you just have to wait for it to be completely initialized. When all pods are running and the four nodes are in ready state, it means your cluster is completely provisioned.

And that's it! Now you have a production-ready, highly available Kubernetes cluster managed by Syself Autopilot. And since everything is defined using Kubernetes manifests, you can have your entire cluster configuration managed with GitOps, using your favorite tools.

Optional: Run sample workload

Deploy the sample pod to your cluster:

And create a port forwarding to access it:

Now, go to http://localhost:8080 in your browser.

Further Reading

In the How to guides / Create clusters section you can find tutorials for common tasks you might want to do in your cluster. We recommend you go over it after creating your first cluster.

Previous
Hetzner account preparation
Next
Adding users