## Step 1: Applying the ClusterStack A [ClusterStack](/docs/hetzner/apalla/concepts/cluster-stacks) defines a complete, opinionated set of Kubernetes resources including cluster templates, node image configurations, and add-on manifests which are needed to create a production-ready cluster. For each release, these resources and configurations are heavily tested by Syself to guarantee integrity and interoperability. The first step for cluster creation is making a ClusterStack Release available. Create a file named `clusterstack.yaml`, with the following content: {% if $clusterstackrelease.version.isLatest %} ```yaml /// clusterstack.yaml apiVersion: clusterstack.x-k8s.io/v1alpha1 kind: ClusterStack metadata: name: hetzner-apalla-1-34 spec: provider: hetzner name: apalla kubernetesVersion: '1.34' channel: stable autoSubscribe: true providerRef: name: hetzner-apalla-1-34 kind: HetznerClusterStackReleaseTemplate apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1 --- apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1 kind: HetznerClusterStackReleaseTemplate metadata: name: hetzner-apalla-1-34 spec: template: spec: nodeImages: - controlplaneamd64hcloud - workeramd64hcloud ``` {% else /%} ```yaml /// clusterstack.yaml apiVersion: clusterstack.x-k8s.io/v1alpha1 kind: ClusterStack metadata: name: hetzner-apalla-1-34 spec: provider: hetzner name: apalla kubernetesVersion: '1.34' channel: stable autoSubscribe: false versions: - v6 providerRef: name: hetzner-apalla-1-34 kind: HetznerClusterStackReleaseTemplate apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1 --- apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1 kind: HetznerClusterStackReleaseTemplate metadata: name: hetzner-apalla-1-34 spec: template: spec: nodeImages: - controlplaneamd64hcloud - workeramd64hcloud ``` {% /if %} And apply it to the management cluster: {% terminal height="8rem" steps="[{\"command\":\"kubectl apply -f clusterstack.yaml\",\"output\": \"clusterstack.clusterstack.x-k8s.io/clusterstack created\\nhetznerclusterstackreleasetemplate.infrastructure.clusterstack.x-k8s.io/clusterstack created\"}]" /%} 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. {% callout type="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. {% /callout %} After the node images are successfully built, the ClusterStackRelease hetzner-apalla-1-34-v6 will be ready for you to use in your cluster. Check with: {% terminal height="12rem" steps="[{\"command\":\"kubectl get clusterstackrelease\",\"delay\":500,\"output\":\"NAME K8S VERSION READY AGE REASON MESSAGE\\nhetzner-apalla-1-34-v6 v1.34.6 true 1m\"}]" /%} ## Step 2: Creating your cluster {% callout type="tip" %} If you need your clusters to be SCS-compatible, you can refer to the [Creating SCS compatible clusters](/docs/hetzner/apalla/how-to-guides/scs-compatible-cluster) page. The [SCS (Sovereign Cloud Stack)](https://sovereigncloudstack.org/en/) is a European initiative for an open, transparent and vendor-neutral cloud ecosystem that guarantees sovereignty. {% /callout %} Now that we have a ClusterStackRelease ready, we can create a cluster from it. For that, create a `cluster.yaml` file with the contents below: ```yaml /// cluster.yaml apiVersion: cluster.x-k8s.io/v1beta1 kind: Cluster metadata: 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-34-v6 version: v1.34.6 controlPlane: class: hcloud replicas: 3 workers: machineDeployments: - class: workeramd64hcloud name: md-0 replicas: 1 failureDomain: nbg1 variables: overrides: - name: workerMachineTypeHcloud value: cpx42 variables: - name: region value: nbg1 - name: controlPlaneMachineTypeHcloud value: cpx42 ``` And apply it to the management cluster with: {% terminal height="6rem" steps="[{\"command\":\"kubectl apply -f cluster.yaml\",\"delay\":200,\"output\":\"cluster.cluster.x-k8s.io/mycluster created\"}]" /%} Cluster creation will take a few more minutes. You can monitor the process by looking at the machine objects: {% terminal height="13rem" steps="[{\"command\":\"kubectl get machines\",\"delay\":500,\"output\":\"NAME CLUSTER NODENAME PROVIDERID PHASE AGE VERSION\\nmycluster-jndgf-r4k7v mycluster mycluster-hb2wb-pb6d4 hcloud://12345678 Running 10m v1.34.6\\nmycluster-jndgf-sb6b8 mycluster mycluster-hb2wb-2g9wq hcloud://87654321 Running 8m v1.34.6\\nmycluster-jndgf-vhbsb mycluster mycluster-hb2wb-bnkjh hcloud://12348765 Running 5m v1.34.6\\nmycluster-md-0-zw8ln-pxztl-j4stb mycluster mycluster-md-0-bp4v2-7r2sv hcloud://43215678 Running 4m v1.34.6\"}]" /%} These represent actual machines in your Hetzner project. If all of them are in the `Running` phase, it means your cluster is ready! {% callout type="note" %} If a control plane node replacement or rolling update is stuck provisioning, this is most likely a regional HCloud capacity issue and the operation will remain blocked until capacity returns. Baremetal control planes are not subject to this, as updates and recovery operate on existing inventory. See [Baremetal Control Planes](/docs/hetzner/apalla/how-to-guides/cluster-configuration/baremetal-control-planes) for setup instructions. {% /callout %} ## Step 3: Accessing your cluster To get the kubeconfig of your workload cluster, you can use the command: {% terminal height="8rem" steps="[\"kubectl get secrets mycluster-kubeconfig -o=jsonpath='{.data.value}' \\\\\\n| base64 -d \\\\\\n> mycluster-kubeconfig.yaml\"]" /%} Now, you can change the `KUBECONFIG` environment variable to point to your new cluster: {% terminal height="4rem" steps="[{\"command\":\"export KUBECONFIG=mycluster-kubeconfig.yaml\",\"delay\":200,\"output\":\"\"}]" /%} If you want more information about workload and management clusters, check the [Management and Workload Clusters](/docs/hetzner/apalla/concepts/mgt-and-wl-clusters) section. 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: {% terminal height="24rem" steps="[{\"command\":\"cat < 80\\nForwarding from [::1]:8080 -> 80\\nHandling connection for 8080\"}]" /%} Now, go to [http://localhost:8080](http://localhost:8080) in your browser. ### Further Reading In the [Cluster configuration](/docs/hetzner/apalla/how-to-guides/cluster-configuration) 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. For a list of all servers supported by Syself Autopilot and recommendations, you can refer to the [Adding HCloud Servers](/docs/hetzner/apalla/how-to-guides/server-management/hcloud-server-management) page.