← Back to Pull requests

Use k0sApiPort for controller joins behind a host:port externalAddress #8861

Open
unknown opened this pull request with 282 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 18, 2026 23:41 UTC
Author

Description

Since 4da84d23e, spec.api.externalAddress can include a port (lb.example.com:443). That port is the kube-apiserver port of the load balancer. getExternalURIForPort returned such an address unchanged, whatever port was asked for, so K0sControlPlaneAPIAddress() returned https://lb.example.com:443 too. 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.URL decides whether a port in ExternalAddress is kept, as for APIAddressURL(), or replaced by port, as for K0sControlPlaneAPIAddress(). It splits the external address itself, without going through ExternalHost().
- The INADDR_ANY check uses the host part of externalAddress, so 0.0.0.0:6443 and [::]:6443 are rejected like 0.0.0.0 and ::.
2. Report externalAddress in its INADDR_ANY error (fixes a759281d2)
- The error now reports the value of externalAddress instead of address.

I left the docs alone. The host:port form of externalAddress isn't documented yet, and the existing footnote about the load balancer listening on port/k0sApiPort still holds.

Fixes #8774

Type of change

  • Non-breaking change

  • Breaking change (must respect the version skew policy)
  • How has this been tested?

  • Manual test

  • Automated test added
  • 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 cover 0.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

  • This pull request follows the contributing guidelines

  • I have performed a self-review of my changes

  • I have made corresponding changes to the documentation
  • I used an AI coding assistant while preparing this change. I reviewed and tested it myself.

    Diff: 282 lines (+211 / -71) across 3 files Reviewer: twz123 Review duration: 17283m
    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
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.7% (MEDIUM) · Higher = larger blast radius
    39.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.7% · Safe to merge
    22.7%
    Repository