Skip to content

fix: export KUBECONFIG inline and poll until k3s API is ready - #10

Merged
RuBiCK merged 1 commit into
mainfrom
fix/k3s-kubeconfig-wait
Jun 15, 2026
Merged

fix: export KUBECONFIG inline and poll until k3s API is ready#10
RuBiCK merged 1 commit into
mainfrom
fix/k3s-kubeconfig-wait

Conversation

@RuBiCK

@RuBiCK RuBiCK commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Root cause

Two bugs in the Start k3s step caused kubectl wait to fail with connection refused on localhost:8080:

Bug 1 — KUBECONFIG not visible within the same step

echo "KUBECONFIG=/etc/rancher/k3s/k3s.yaml" >> $GITHUB_ENV  # ← only applies to NEXT steps
kubectl wait ...  # ← still uses default kubeconfig → localhost:8080

$GITHUB_ENV writes are picked up at the start of the next step, not within the current run: block. Fix: also export KUBECONFIG=... in the same shell.

Bug 2 — kubectl ran before the API server was up
k3s installs as a systemd service and starts asynchronously. kubectl wait was called less than 1 second after systemd: Starting k3s, before the API server was listening. Fix: poll with until kubectl get nodes &>/dev/null; do sleep 3; done.

🤖 Generated with Claude Code

Two bugs in the Start k3s step:
1. KUBECONFIG was set only via $GITHUB_ENV, which applies to subsequent steps
   but not the current run: block — kubectl was hitting localhost:8080 (empty).
   Fix: also export KUBECONFIG in the same shell.
2. kubectl wait ran immediately after systemd started k3s, before the API
   server was up. Fix: poll with until kubectl get nodes until it responds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@RuBiCK
RuBiCK merged commit bc4e078 into main Jun 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant