GitHub Actions
Automatiseer clusterprovisioning en configuratiesync met GitHub Actions.
De snelle route — de herbruikbare workflow
lok8s levert een kant-en-klare workflow die een ingecheckte cluster uitrolt en, als de cluster kubehz-zichtbaarheid aanzet (spec.kubehz.access is registered of managed), hem registreert en de claim-fingerprint in de jobsamenvatting zet (de claimsleutel die lo naar je Hetzner-project uploadt; zie Claimen). Hij heeft precies één secret nodig:
# .github/workflows/spinup.yml
name: Spin up cluster
on: workflow_dispatch
jobs:
spinup:
uses: kernpilot/lok8s/.github/workflows/spinup.yml@main
with:
domain: my-cluster.example.com
secrets:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}@main is een bewegende referentie
Dit roept de herbruikbare workflow aan op @main, dus hij verandert wanneer lok8s verandert. Dat is handig zolang lok8s jong is, maar het betekent dat een run zich anders kan gedragen dan de vorige zonder dat jij iets hebt gewijzigd. Een commit-SHA (spinup.yml@<sha>) legt het gedrag vast dat je hebt getest en is de veiligere keuze voor alles wat echte infrastructuur aanmaakt. Zoek de SHA op waar main nu naar wijst en plak die in uses::
gh api repos/kernpilot/lok8s/commits/main --jq .shaVastzetten op de huidige release (@v0.2.0, augustus 2026) wordt nog niet aangeraden: de workflow heeft sinds die tag uitrol met een claimsleutel gekregen, dus de release loopt achter op wat deze pagina beschrijft.
De cluster.lok8s.yaml voor het domein moet in je repo staan onder clusters/<domain>/. Er is geen platformtoken nodig: eigenaarschap toon je later interactief aan, wanneer je de cluster claimt.
Kies deze route tenzij je eigen stappen nodig hebt; de workflows hieronder tonen de volledige handmatige opzet.
Je eigen workflows schrijven
Vereisten
- Een repository met je
clusters/<domain>/cluster.lok8s.yaml - Repository-secrets geconfigureerd in GitHub (hieronder)
Vereiste secrets
Voeg deze toe in je repository-instellingen onder Settings > Secrets and variables > Actions:
| Secret | Beschrijving |
|---|---|
HCLOUD_TOKEN | Hetzner Cloud API-token |
SSH_PRIVATE_KEY | Privé-SSH-sleutel die overeenkomt met sshPrivateKey in je providerbeschrijving (toegang tot nodes) |
KUBECONFIG | Base64-gecodeerde kubeconfig (voor syncworkflows) |
lok8s installeren in CI
lok8s wordt gedistribueerd als b-omgeving, dus een runner heeft eerst b nodig en daarna de vastgezette toolchain. Commit je repo al .bin/b.yaml (de lok8s-installer maakt hem aan), dan herstelt b install alleen precies dezelfde toolchain; sla de regel b env add dan over.
- name: Install b (binary manager)
run: |
curl -fsSL https://raw.githubusercontent.com/fentas/b/v4.18.4/install.sh \
-o /tmp/b-install.sh
B_INSTALL_DIR="$HOME/.local/bin" bash /tmp/b-install.sh
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Install the lok8s toolchain
env:
# voorkomt GitHub API-ratelimits bij binary-downloads
GITHUB_TOKEN: ${{ github.token }}
run: |
b env add github.com/kernpilot/lok8s#kubeone
b install
echo "$PWD/.bin" >> "$GITHUB_PATH"Provision-workflow
Maak .github/workflows/provision.yml:
name: Provision Cluster
on:
workflow_dispatch:
inputs:
action:
description: 'Action to perform'
required: true
default: 'provision'
type: choice
options:
- provision
- destroy
jobs:
provision:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install b (binary manager)
run: |
curl -fsSL https://raw.githubusercontent.com/fentas/b/v4.18.4/install.sh \
-o /tmp/b-install.sh
B_INSTALL_DIR="$HOME/.local/bin" bash /tmp/b-install.sh
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Install the lok8s toolchain
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
b env add github.com/kernpilot/lok8s#kubeone
b install
echo "$PWD/.bin" >> "$GITHUB_PATH"
- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
- name: Run lo
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
run: lo --domain my-cluster.example.com ${{ inputs.action }}De dispatch-input kiest lo provision of lo destroy, dus één workflow dekt zowel opzetten als afbreken.
Sync-workflow
Maak .github/workflows/sync.yml om configuratiewijzigingen toe te passen bij een push:
name: Sync Cluster
on:
push:
branches: [main]
paths:
- 'clusters/**'
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install b (binary manager)
run: |
curl -fsSL https://raw.githubusercontent.com/fentas/b/v4.18.4/install.sh \
-o /tmp/b-install.sh
B_INSTALL_DIR="$HOME/.local/bin" bash /tmp/b-install.sh
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Install the lok8s toolchain
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
b env add github.com/kernpilot/lok8s#kubeone
b install
echo "$PWD/.bin" >> "$GITHUB_PATH"
- name: Setup kubeconfig
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config
- name: Reconcile infrastructure
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
run: lo --domain my-cluster.example.com provision
- name: Render the manifests
run: lo --domain my-cluster.example.com build
- name: Deploy platform
run: lo --domain my-cluster.example.com deploylo provision is idempotent: bij herhaald uitvoeren wordt het cluster gereconcilieerd naar je spec. lo build rendert je services en addons naar clusters/<domain>/artifacts.yaml, en lo deploy past dat bestand toe. lo deploy weigert te draaien voordat lo build het heeft aangemaakt.
Volgende stappen
- Registratie: registreren bij het kubehz-dashboard
- KubeOne: provisioner-details
- CAPI: Cluster API-provisioner
Documentstatus
| Aspect | Detail |
|---|---|
| Status | active |
| Laatst herzien | 2026-09-05 |