Repository navigation
Description
Friction
Off the home network, the tunnel kubeconfig context from #1595 works only while cloudflared access tcp runs in a terminal someone keeps open. When the listener isn't running, kubectl fails with "connection refused" on 127.0.0.1:16443. That is the same error the workstation gave before #1595, and nothing says the forward is what's missing. k8s/README.md leaves "a command that keeps the forward running" to its own item.
Evidence
- On 2026-10-17, after v0.2.36 reached
mainand Argo CD synced cloudflared's 6443 egress rule:- With the listener running,
kubectl --context <cluster>-tunnel get nodeslisted the cluster's nodes throughk8s.<domain>. - A second after the listener exited, the same command failed with "The connection to the server 127.0.0.1:16443 was refused".
- With the listener running,
- A second listener started on the same port fails with "bind: address already in use". Nothing owns the forward, so the user starts and stops it by hand.
devops k8scommands use the kubeconfig's current context. Off the network, the user must also switch to the tunnel context by hand.
Remedy
A devops k8s tunnel command group.
devops k8s tunnel start:
- runs
cloudflared access tcp --hostname <host> --url 127.0.0.1:<port>detached, in its own process group (start_new_session=True); - records its PID under the data directory;
- waits until the port accepts connections;
- prints the Access login URL when cloudflared asks for one;
- when a forward is already running, reports it instead of starting another;
- with
--context, adds or updates the<cluster>-tunnelcontext with thekubectl configcommandsk8s/README.mdgives.
devops k8s tunnel stop:
- signals the process group with the guarded
os.killpgpattern AGENTS.md requires (never PID 0 or 1, never its own group).
devops k8s tunnel status:
- reports whether the port is listening;
- reports whether the API server answers (a 401 from
/versioncounts as reached).
Configuration:
- The hostname comes from a setting, with no fallback: when the setting is unset, the command fails with an error naming it.
- The port defaults to a value in
src/devops_cli/config/defaults.py.
Tests use a fake cloudflared in tmp_path that listens on a free port:
- after
start,statusreports the port listening; - a second
startstarts no new process; stopends the whole process group;- an unset hostname fails with an error naming the setting.
Pending a person: from off the home network, devops k8s tunnel start --context, the Access login, then kubectl --context <cluster>-tunnel get nodes.
Proposed design
Problem statement
The current k8s tunneling setup requires manual intervention to keep the cloudflared forward running when off the home network. Users must manually start and stop cloudflared access tcp commands, which is error-prone and inconvenient.
Acceptance criteria
- Criterion 1: A
devops k8s tunnel startcommand exists that runs cloudflared in detached mode with its own process group
Verification: Runningdevops k8s tunnel startcreates a new process group and starts cloudflared withstart_new_session=True - Criterion 2: The tunnel command records its PID under the data directory after starting
Verification: After runningdevops k8s tunnel start, the PID is written to a file in the data directory - Criterion 3: A
devops k8s tunnel stopcommand exists that properly terminates the tunnel process group
Verification: Runningdevops k8s tunnel stopsends SIGTERM to the process group usingos.killpgwith proper guards - Criterion 4: A
devops k8s tunnel statuscommand reports whether the port is listening and the API server answers
Verification: Runningdevops k8s tunnel statusreturns information about port listening status and API server reachability - Criterion 5: The tunnel command fails with an error when hostname setting is unset
Verification: Runningdevops k8s tunnel startwithout a hostname setting reports an error naming the missing setting
Key questions
- What is the default port for the tunnel?: The default port comes from
src/devops_cli/config/defaults.py[sources: src/devops_cli/config/defaults.py] - How should the tunnel command handle an already running forward?: When a forward is already running, the command should report it instead of starting another (proposed)
- What configuration setting provides the hostname for the tunnel?: The hostname comes from a setting with no fallback - when the setting is unset, the command fails with an error naming it (proposed)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsReady
Activity
dan-petty commentedon Oct 18, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
The candidate proposes a new command group to manage k8s tunnels, which is a feature.This feature improves usability and workflow but isn't critical for core functionality.It solves a significant friction point for users working off the home network.The implementation requires managing process groups, handling configuration, and writing tests with fake cloudflared.dan-petty commentedon Oct 22, 2026
Status set to Ready at ae8c2d9 (see proposed design in issue body).
chore(main): release 0.12.0 (#2552)