Skip to content

Port-forward auto-reconnect on pod restart for service-backed port-forwards #7272

Description

@Slambot01

Problem Description

When a port-forward's target pod is deleted or restarted (e.g. during a rolling update or scaling event), Headlamp marks the port-forward as Stopped and the user must manually restart it. This is disruptive during active development/debugging sessions where pods frequently cycle, forcing the user to navigate back to the service and re-initiate the port-forward each time.

Solution

When a service-backed port-forward's pod dies, Headlamp should automatically resolve a new pod via the Kubernetes Endpoints API and re-establish the port-forward tunnel on the same local port. The reconnection should retry with exponential backoff (e.g. 3 attempts: 5s → 10s → 20s) and show a "Reconnecting" status in the UI. If all attempts fail, the port-forward should be marked as stopped with an error message.

Feature's Benefit

All Headlamp desktop (Electron) users who port-forward to Services during development or debugging. Particularly useful for users working with Deployments that undergo frequent rolling updates.

Additional context

  • This only applies to Service-based port-forwards. Pod-only port-forwards lack the context to discover replacement pods.
  • The backend already has the service and serviceNamespace fields in the port-forward struct, so the Endpoints query is straightforward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions