GitHub Actions
Automatisiere Cluster-Bereitstellung und Konfigurations-Sync mit GitHub Actions.
Voraussetzungen
- Ein Repository, das deine
cluster.lok8s.yamlenthält - lok8s CLI in CI verfügbar (installiert via
b env add) - Konfigurierte GitHub-Repository-Secrets
Erforderliche Secrets
Füge diese in den Repository-Einstellungen unter Settings > Secrets and variables > Actions hinzu:
| Secret | Beschreibung |
|---|---|
HCLOUD_TOKEN | Hetzner-Cloud-API-Token |
SSH_PRIVATE_KEY | Privater SSH-Schlüssel für den Node-Zugriff |
KUBECONFIG | Base64-kodierte kubeconfig (für Sync-Workflows) |
Provision-Workflow
Erstelle .github/workflows/provision.yml:
yaml
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 lok8s
run: b env add github.com/kernpilot/lok8s
- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
- name: Provision
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
run: lo provisionSync-Workflow
Erstelle .github/workflows/sync.yml, um Konfigurationsänderungen bei einem Push anzuwenden:
yaml
name: Sync Cluster
on:
push:
branches: [main]
paths:
- 'cluster.lok8s.yaml'
- 'deploy/**'
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install lok8s
run: b env add github.com/kernpilot/lok8s
- 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 provision
- name: Deploy platform
run: lo deploylo provision ist idempotent — erneutes Ausführen gleicht den Cluster an deine Spezifikation an. lo deploy rollt die Plattform-/Workload-Manifeste unter deploy/ aus.
Nächste Schritte
- Registrierung — beim kubehz-Dashboard registrieren
- KubeOne — Provisioner-Details
- CAPI — Cluster-API-Provisioner
Doku-Status
| Aspekt | Detail |
|---|---|
| Zustand | aktiv |
| Zuletzt geprüft | 2026-04-04 |