Use k0sApiPort for controller joins behind a host:port externalAddress #8861
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.40) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 282 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.338
Real PR Conversation Timeline
1 comments
"Review active on #8861"
general
weight: 0.35
twz123
Description
Since 4da84d23e,
spec.api.externalAddresscan include a port (lb.example.com:443). That port is the kube-apiserver port of the load balancer.getExternalURIForPortreturned such an address unchanged, whatever port was asked for, soK0sControlPlaneAPIAddress()returnedhttps://lb.example.com:443too. Controller join tokens then pointed at the API server instead of the k0s Join API.This PR has two commits, one for each commit it fixes:
1. Use k0sApiPort for joins behind a host:port externalAddress (fixes 4da84d23e)
-
getExternalURIForPort(port int, replacePort bool) *url.URLdecides whether a port inExternalAddressis kept, as forAPIAddressURL(), or replaced byport, as forK0sControlPlaneAPIAddress(). It splits the external address itself, without going throughExternalHost().- The
INADDR_ANYcheck uses the host part ofexternalAddress, so0.0.0.0:6443and[::]:6443are rejected like0.0.0.0and::.2. Report externalAddress in its INADDR_ANY error (fixes a759281d2)
- The error now reports the value of
externalAddressinstead ofaddress.I left the docs alone. The host:port form of
externalAddressisn't documented yet, and the existing footnote about the load balancer listening onport/k0sApiPortstill holds.Fixes #8774
Type of change
How has this been tested?
Added
TestExternalAddressURLs(with "API server URL" / "k0s Join API URL" assertion messages) to cover host, host:port, IPv4:port, IPv6 and [IPv6]:port. Added a "rejects any address as external address" case to cover0.0.0.0,0.0.0.0:6443,::and[::]:6443. Both fail on main and pass with this change.go test ./pkg/apis/k0s/v1beta1/ ./pkg/token/passes.Checklist
I used an AI coding assistant while preparing this change. I reviewed and tested it myself.