Skip to main content
← Back to list
01Issue
FeatureShippedSwamp CLI
Assigneesstack72

Relationships

#553 @swamp/kubernetes ignores certificate-authority-data from kubeconfig for self-signed CAs

Opened by bixu · 6/4/2026· Shipped 6/4/2026

Description

@swamp/kubernetes models fail with self-signed certificate in certificate chain when targeting a k3s cluster whose API server uses a self-signed CA, even though the kubeconfig has the correct CA embedded in certificate-authority-data.

Steps to reproduce

  1. Have a kubeconfig with a k3s-dev context that uses a self-signed CA (certificate-authority-data is populated)
  2. Create a model: swamp model create @swamp/kubernetes/node my-nodes --global-arg namespace=default --global-arg context=k3s-dev
  3. Run: swamp model method run my-nodes list --json

Observed

{
  "error": "request to https://10.155.48.10:6443/api/v1/nodes failed, reason: self-signed certificate in certificate chain",
  "code": "method_execution_failed"
}

Expected

The @kubernetes/client-node library's KubeConfig.loadFromDefault() parses certificate-authority-data and should configure the HTTPS agent with that CA. The request should succeed, as it does with kubectl --context k3s-dev get nodes.

Environment

  • swamp version: 20260604.165624.0-sha.9bed22cc
  • @swamp/kubernetes version: 2026.06.04.1 (also reproduced on 2026.05.27.2)
  • macOS Darwin 25.4.0

Workarounds attempted (none worked)

  • NODE_EXTRA_CA_CERTS=~/.kube/k3s-dev-ca.pem — ignored by Deno runtime
  • DENO_CERT=~/.kube/k3s-dev-ca.pem — ignored
  • DENO_TLS_CA_STORE=system — ignored
  • NODE_TLS_REJECT_UNAUTHORIZED=0 — ignored

The env vars don't reach the extension subprocess. The extension's buildClient() in _lib/helpers.ts calls kc.loadFromDefault() and kc.makeApiClient() which should propagate the CA — suspect the Deno bundler or runtime strips the CA from the HTTPS agent.

Upstream repository: https://github.com/swamp-club/swamp-extensions

Environment

  • Extension: @swamp/kubernetes@2026.06.04.1
  • swamp: 20260604.165624.0-sha.9bed22cc
  • OS: darwin (aarch64)
  • Deno: 2.8.2
  • Shell: /bin/zsh
02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED+ 2 MORETRIAGE+ 5 MOREREVIEW+ 3 MOREPR_MERGEDSHIPPED

Shipped

6/4/2026, 11:49:29 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack726/4/2026, 7:30:00 PM
Editable. Press Enter to edit.

bixu commented 6/4/2026, 6:42:29 PM(edited)

Update: root cause identified — stale kubeconfig, not a swamp/extension bug

The self-signed certificate in certificate chain error was caused by a reprovisioned k3s cluster. The cluster's CA rotated (serial 17801367571780587212) but our local kubeconfig still had the old CA and client credentials.

We resolved it by adding a refresh method to our @<org>/k3s/kubeconfig extension that SSHes to the control plane, fetches /etc/rancher/k3s/k3s.yaml, and merges fresh credentials into ~/.kube/config.

The real feature gap this exposed

@swamp/kubernetes models have no way to detect or recover from stale kubeconfig credentials at runtime. When a cluster is reprovisioned, every kubernetes model silently fails with a TLS error until the operator manually refreshes the kubeconfig. Ideally the extension would:

  1. Surface a clearer error when the CA doesn't match (distinguish "CA rotated" from "self-signed not trusted")
  2. Support a pre-flight check or hook that validates cluster reachability before method execution

Blocked by #554

We cannot verify whether the refreshed kubeconfig fixes @swamp/kubernetes models because all existing model definitions are stuck on typeVersion: 2026.05.27.2 with no upgrade path to 2026.06.04.1. kubectl --context k3s-dev works fine after the refresh — only swamp is blocked.

stack72 commented 6/4/2026, 8:24:24 PM

Related: #487 (dynamic host/data discovery from external sources). The stale kubeconfig problem here is another instance of the same pattern — static inputs going stale at runtime. The datasource/dynamic-input feature is tracked there. This issue is scoped to the immediate UX gap: better TLS error messaging in @swamp/kubernetes.

Sign in to post a ripple.