A set of functions to setup K3s clusters on HCloud, based on vitobotta's hetzner-k3s
Hetzner-k3s is nicely engineered general k3s installation tool on Hetzner, with a large degree of declarative possibilities for customization. As terraform, it is a single static binary and idempotent, with a single source of truth. In contrast to terraform it is straightforward to use, with far less abstractions but a lot of built in best practices, incl CNI and autoscaling, plus faster.
This repo here provides a set of python functions, incl. possibly useful support tools to organize them, in order to further automate around the pure k3s installation, which hetzner-k3s provides.
- just create-cluster
- just port-forward # kubectl now works
- just flux-install
- just tekton-install # cloud native build system
- just p tekton port_forward # dashboard
This is created, from your laptop:
flowchart LR
A[World] --> B[Bastion Proxy<br/>IP pub<br/>Opt.LoadBalancer]
B --priv net--> M1[Master 1<br/>...<br/>Master 3]
B --priv net--> w1[Worker 1<br/>...<br/>Worker n]
B --priv net--> a1[Autoscaled 1<br/>...<br/>Autoscaled n]
That bastion server is the only one with a public IP, and is equipped with a l4 loadbalancer, forwarding the traffic into the cluster, like a hetzner loadbalancer would do.
Entry point is clusters/production - there all yaml files are evaluated, pointing to infra and apps.
Q: Why does dependsOn
work in clusters/production/infrastructure.yaml
but not in infrastructure/tekton/config/kustomization.yaml
?
-
clusters/production/infrastructure.yaml
:- This is a Flux Kustomization resource
- It's a Kubernetes custom resource (CR) that Flux uses to manage deployments
- It has its own API schema that includes
dependsOn
as a valid field - Example structure:
apiVersion: kustomize.toolkit.fluxcd.io/v1 kind: Kustomization metadata: name: infra-tekton spec: dependsOn: - name: some-other-kustomization
-
infrastructure/tekton/config/kustomization.yaml
:- This is a Kustomize configuration file
- It's used by the
kustomize
tool to build Kubernetes manifests - It has a different API schema that doesn't include
dependsOn
- Example structure:
apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - tektonconfig.yaml
-
Purpose:
- Flux Kustomization: Manages the deployment lifecycle, including ordering and dependencies
- Kustomize config: Just builds and transforms Kubernetes manifests
-
API Version:
- Flux Kustomization:
kustomize.toolkit.fluxcd.io/v1
- Kustomize config:
kustomize.config.k8s.io/v1beta1
- Flux Kustomization:
-
Functionality:
- Flux Kustomization: Can handle dependencies, health checks, and deployment ordering
- Kustomize config: Only handles manifest building and transformation
That's why the dependsOn
in infrastructure.yaml
works - it's telling Flux to wait for the operator to be ready before applying the config. The Kustomize config file can't do this because it's just a build tool, not a deployment manager.
Think of it this way:
- Kustomize is like a build tool that creates the Kubernetes manifests
- Flux is like a deployment manager that decides when and how to apply those manifests
The dependency needs to be managed at the deployment level (Flux) rather than the build level (Kustomize).