How maksim-paskal/hcloud-k8s-ctl works
Main components
• User CLI (hcloud‑k8s‑ctl)
• Entry point: cmd/main.go
• Parses config.yaml, command‑line flags, environment
• Configuration Module (pkg/config)
• Loads and validates user settings (cluster size, versions, autoscaling groups)
• Hetzner Cloud API Client (pkg/api)
• Wraps Hetzner Cloud REST calls (create server, network, load balancer, server types)
• Provisioning Engine (core logic in internal/internal.go + pkg/drain)
• Orchestrates resource creation, SSH execution, cluster bootstrap
• SSH/Script Executor (scripts/*.sh)
• common-install.sh, init-master.sh, post-install.sh, etc.
• Installs OS packages, Docker/containerd, kubeadm, configures master & worker
• Kubernetes Bootstrap
• kubeadm init on masters, kubeadm join on workers
• Flannel CNI, CSI driver, cloud‑controller‑manager, metrics server, autoscaler chart
• Autoscaling Controller
• Deploys Kubernetes Cluster‑Autoscaler configured with Hetzner autoscaling groups
• Examples & E2E Tests
• Helm chart in examples/charts
• End‑to‑end harness in e2e/ invoking CLI and validating cluster
Interactions
• User → runs hcloud-k8s-ctl CLI →
a. Configuration Module reads config.yaml →
b. Hetzner API Client provisions:
• VPC / Internal network
• Load balancer (for control plane)
• Master servers (odd count)
• (Later) Worker nodes via autoscaler groups
c. Provisioning Engine obtains server IPs →
• Uses SSH to run common-install.sh on all servers
• Runs init-master.sh on masters (with load balancer)
• Once control plane ready, runs post-install.sh to deploy add‑ons
d. Kubernetes cluster comes online with:
• Kubernetes control plane behind LB
• Flannel CNI, CSI, cloud‑controller, metrics-server, CSR approver
• Cluster‑Autoscaler tied to Hetzner autoscaling groups
• E2E Test Harness under e2e/ → invokes CLI → validates node count, SSH access, API responses
Architectural patterns & principles
• Layered design:
• cmd/ (presentation), pkg/ (business logic), internal/ (private core), scripts/ (procedural provisioning)
• Single‑binary CLI (Go + Cobra flags + Viper config)
• Infrastructure as code via procedural scripts and API calls
• Extensibility points: deployments: in config to enable optional charts (e.g., NFS)
• Testing harness separated under e2e/
Technologies & frameworks
• Language: Go (modules, go.mod)
• HCloud SDK (REST client in pkg/api)
• SSH + Shell scripts (scripts/)
• Kubernetes tools: kubeadm, kubectl, Helm templates (examples/ & scripts/chart)
• CICD: GitHub Actions workflows (.github/workflows)
• Release automation: Goreleaser (.goreleaser.yml)
Detail each component
• scripts/common-install.sh, init-master.sh, post-install.sh as separate steps
• Autoscaling groups feeding into the Kubernetes cluster via Cluster‑Autoscaler