Skip to content

Fix rancher-lb LoadBalancer wait-loop in RKE2 scripts - #172

Merged
DefNotJeffrey merged 2 commits into
mainfrom
fix/rancher-lb-wait-loop-issue-21
Jul 19, 2026
Merged

DefNotJeffrey merged 2 commits into
mainfrom
fix/rancher-lb-wait-loop-issue-21

Conversation

@cyberops7

@cyberops7 cyberops7 commented Jul 9, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes the "Waiting for LoadBalancer to come online" loop in the RKE2 scripts, which never actually waited.

The loop was written as kubectl get svc -n cattle-system 'jsonpath={..status.conditions[?(@.type=="Pending")].status}' — but with no -o flag, kubectl treats jsonpath={...} as a service name. That returns a NotFound error and empty stdout, so [[ "" = "True" ]] is always false and the body never runs. The jsonpath also targeted .status.conditions[Pending], a shape Services do not have (that is a Pod-readiness condition).

Now it polls the rancher-lb service and blocks until MetalLB assigns an external IP, which is what the message promises:

while [[ -z $(kubectl get svc rancher-lb -n cattle-system -o 'jsonpath={.status.loadBalancer.ingress[0].ip}' 2>/dev/null) ]]; do

Applied to both Kubernetes/RKE2/rke2.sh and Kubernetes/RKE2-Cilium/rke2.sh.

Also includes a number of shellcheck fixes.

For context on #21: the exact command it reported (kubectl get svc name=rancher-lb) is already gone from the scripts, so that specific error no longer occurs. This PR repairs the related rancher-lb LoadBalancer wait that was left broken in the same block.

Verification: shellcheck clean on both files; loop semantics tested with a mock kubectl (waits while the IP is empty, exits once an IP appears).

Closes #21

cyberops7 added 2 commits July 8, 2026 22:57
The wait-loop was missing '-o' before the jsonpath template, so
'jsonpath={...}' was parsed as a service name and the query errored
to empty output, causing the loop to never wait. It also queried
.status.conditions[Pending], a shape Services do not have.

Poll the rancher-lb service and block until MetalLB assigns an
external IP instead.
The lint CI runs pre-commit on changed files, so touching these scripts
surfaced pre-existing warnings. Address them without changing behavior:
- Quote array elements (SC2206) and command substitutions (SC2046).
- Disable SC2087 on the ssh heredocs (vars are intentionally expanded
  client-side) and SC1090 on 'source ~/.bashrc' (not followable).
- Keep unused config knobs (KVVERSION, interface) with a targeted
  SC2034 disable; drop the genuinely-unused allnomaster1 array.
- Strip trailing whitespace.

Verified: shellcheck --severity=warning clean and pre-commit green
(ShellCheck v0.10.0) on both files; bash -n syntax OK.
@cyberops7
cyberops7 marked this pull request as ready for review July 14, 2026 04:24
@cyberops7
cyberops7 requested a review from DefNotJeffrey July 14, 2026 04:24
@DefNotJeffrey
DefNotJeffrey merged commit 8c8385c into main Jul 19, 2026
2 checks passed
@DefNotJeffrey
DefNotJeffrey deleted the fix/rancher-lb-wait-loop-issue-21 branch July 19, 2026 16:32
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.

Error from server (NotFound): services "name=rancher-lb" not found

2 participants