8000 Port Forward deleted without UI notification when forwarding to wrong port · Issue #3301 · derailed/k9s · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Port Forward deleted without UI notification when forwarding to wrong port #3301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
igorakkerman opened this issue Apr 24, 2025 · 5 comments
Closed
Labels
bug Something isn't working in-progress Mark issue as being worked on

Comments

@igorakkerman
Copy link
igorakkerman commented Apr 24, 2025




Describe the bug
When I create a port forward to the wrong port, the port forward gets deleted without a UI notification. The error message in the log is not expressive.

When creating the port forward on a service, rather than on a pod, and the service exposes a different port than the pod does, it's easy to run into that issue, see below.

To Reproduce

  1. kubectl run nginx --image nginx
  2. In k9s, use Shift+F to create a port forward
  3. Enter 81 as container and local ports
  4. curl --verbose 'http://127.0.0.1:81/'
*   Trying 127.0.0.1:81...
* Connected to 127.0.0.1 (127.0.0.1) port 81
* using HTTP/1.x
> GET / HTTP/1.1
> Host: 127.0.0.1:81
> User-Agent: curl/8.11.1
> Accept: */*
>
* Recv failure: Connection was aborted
* closing connection #0
curl: (56) Recv failure: Connection was aborted
  1. See the port forward getting deleted without notification.
  2. Find error message in k9s.log:
Flash failed error="lost connection to pod"
Deleted portforward count=1 gvr=nginx||81:81

Expected behavior

  • UI message stating that the port forward was deleted, potentially giving a possible reason.
  • Expressive message in the log.

Versions:

  • OS: Windows 11
  • K9s: 0.50.4
  • K8s: 1.32.2

Additional context
I ran into this issue trying to connect to a service, which exposes port 80 and has targetPort 8080. I used port 80 in k9s as I did with kubectl:

kubectl port-forward svc/myservice 80:80

While kubectl forwards to 8080, k9s suggests 8080 but lets you enter any port, 80 in my case.
I didn't notice the pod's port in the kubectl output:

Forwarding from 127.0.0.1:80 -> 8080
Forwarding from [::1]:80 -> 8080

That's how I got stuck with the connection failing with k9s.

@igorakkerman igorakkerman changed the title Port Forward deleted without UI notification when forwarding to wrong port. Log: Flash failed error="lost connection to pod" Port Forward deleted without UI notification when forwarding to wrong port Apr 25, 2025
@R-Abinesh
Copy link
R-Abinesh commented Apr 27, 2025

@igorakkerman , I tried to replicate your issue manually and got the below response in my cluster.

Forwarding from 127.0.0.1:8081 -> 8080
Forwarding from [::1]:8081 -> 8080
Handling connection for 8081
E0427 14:04:17.081488  117104 portforward.go:413] "Unhandled Error" err=<
	an error occurred forwarding 8081 -> 8080: error forwarding port 8080 to pod bcf1907a82cf3332f3541f0a11e59a9ab3d98c1026c014dfed48d1f2f6211f98, uid : exit status 1: 2025/04/27 08:34:17 socat[47289] E connect(5, AF=2 127.0.0.1:8080, 16): Connection refused
 >
error: lost connection to pod

Only the error statement is printed to k9s.log. Do you want the log file to have the below message as well?

E0427 14:04:17.081488 117104 portforward.go:413] "Unhandled Error" err=<
an error occurred forwarding 8081 -> 8080: error forwarding port 8080 to pod bcf1907a82cf3332f3541f0a11e59a9ab3d98c1026c014dfed48d1f2f6211f98, uid : exit status 1: 2025/04/27 08:34:17 socat[47289] E connect(5, AF=2 127.0.0.1:8080, 16): Connection refused

@igorakkerman
Copy link
Author

Hi @R-Abinesh, thanks for looking into this.

Yes, IMO the logs should show a more expressive message, similar to what kubectl shows. That adds to what I was actually referring to:

I would hope not to even need to go to the logs but see an expressive output straight in the k9s UI.

@igorakkerman
Copy link
Author

An additional note/request:
When the user initiates the port forward on the service level, rather than on the pod level, and enters a port that the service doesn't forward to, then a warning should be shown in that same dialog in order to raise awareness that they might be making a mistake.

@derailed
Copy link
Owner
derailed commented May 3, 2025

@igorakkerman Actually this what we use to do in early k9s versions...
However, a pod can expose ports/proto that may or may not be advertised in the manifest.
Thus we've opted in letting the dialog be free form and tho we do suggests valid options we left it open for user knows best and let you free-from the ports.

I agree the message should bubble up to the ui in case of failures causing deletions and will update in the next drop.
Thanks for bringing this up!

@derailed derailed added bug Something isn't working in-progress Mark issue as being worked on labels May 3, 2025
@igorakkerman
Copy link
Author

Thanks @derailed , I agree that the user should have the final say and be free to enter whatever they want. However, a simple warning to them might be a compromise.

Showing a warning could be opted in or out in the settings, depending on what you would choose as the default.

derailed added a commit that referenced this issue May 8, 2025
@derailed derailed mentioned this issue May 8, 2025
tmeijn pushed a commit to tmeijn/dotfiles that referenced this issue May 10, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [derailed/k9s](https://github.com/derailed/k9s) | minor | `v0.40.10` -> `v0.50.5` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>derailed/k9s (derailed/k9s)</summary>

### [`v0.50.5`](https://github.com/derailed/k9s/releases/tag/v0.50.5)

[Compare Source](derailed/k9s@v0.50.4...v0.50.5)

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s.png" align="center" width="800" height="auto"/>

### Release v0.50.5
#### Notes

Thank you to all that contributed with flushing out issues and enhancements for K9s!
I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev
and see if we're happier with some of the fixes!
If you've filed an issue please help me verify and close.

Your support, kindness and awesome suggestions to make K9s better are, as ever, very much noted and appreciated!
Also big thanks to all that have allocated their own time to help others on both slack and on this repo!!

As you may know, K9s is not pimped out by corps with deep pockets, thus if you feel K9s is helping your Kubernetes journey,
please consider joining our [sponsorship program](https://github.com/sponsors/derailed) and/or make some noise on social! [@&#8203;kitesurfer](https://twitter.com/kitesurfer)

On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_invite/zt-3360a389v-ElLHrb0Dp1kAXqYUItSAFA)

#### Maintenance Release!

***

#### Resolved Issues

-   [#&#8203;3328](derailed/k9s#3328) Pod overview shows wrong number of running containers with sidecar init-container
-   [#&#8203;3309](derailed/k9s#3309) \[0.50.4] k9s crashes when attempting to load logs
-   [#&#8203;3301](derailed/k9s#3301) Port Forward deleted without UI notification when forwarding to wrong port
-   [#&#8203;3294](derailed/k9s#3294) \[0.50.4] k9s crashes when filtering based on labels
-   [#&#8203;3278](derailed/k9s#3278) k9s doesn't honor the --namespace parameter

***

#### Contributed MRs

Please be sure to give `Big Thanks!` and `ATTA Girls/Boys!` to all the fine contributors for making K9s better for all of us!!

-   [#&#8203;3311](derailed/k9s#3311) Fix concurrent read writes
-   [#&#8203;3310](derailed/k9s#3310) fix: use full path of date to avoid conflict
-   [#&#8203;3308](derailed/k9s#3308) Show replicasets from deployment view
-   [#&#8203;3300](derailed/k9s#3300) fix: truncate label selector input to max length
-   [#&#8203;3296](derailed/k9s#3296) fix: update time format in logging to 24-hour format

***

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/imhotep_logo.png" width="32" height="auto"/> © 2025 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)

### [`v0.50.4`](https://github.com/derailed/k9s/releases/tag/v0.50.4)

[Compare Source](derailed/k9s@v0.50.3...v0.50.4)

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s.png" align="center" width="800" height="auto"/>

### Release v0.50.4
#### Notes

Thank you to all that contributed with flushing out issues and enhancements for K9s!
I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev
and see if we're happier with some of the fixes!
If you've filed an issue please help me verify and close.

Your support, kindness and awesome suggestions to make K9s better are, as ever, very much noted and appreciated!
Also big thanks to all that have allocated their own time to help others on both slack and on this repo!!

As you may know, K9s is not pimped out by corps with deep pockets, thus if you feel K9s is helping your Kubernetes journey,
please consider joining our [sponsorship program](https://github.com/sponsors/derailed) and/or make some noise on social! [@&#8203;kitesurfer](https://twitter.com/kitesurfer)

On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_invite/zt-3360a389v-ElLHrb0Dp1kAXqYUItSAFA)

#### Maintenance Release!

***

#### Resolved Issues

-   [#&#8203;3288](derailed/k9s#3288) Resource search doesn't filter by name in custom view
-   [#&#8203;3286](derailed/k9s#3286) K9S doesn't understand matchExpressions selector in Deployment to Pod navigation
-   [#&#8203;3285](derailed/k9s#3285) Rollout Restart method conflicts with GitOps (Flux, ArgoCD)
-   [#&#8203;3283](derailed/k9s#3283) Deployment status showing wrong ready state
-   [#&#8203;3278](derailed/k9s#3278) k9s doesn't honor the --namespace parameter

***

#### Contributed MRs

Please be sure to give `Big Thanks!` and `ATTA Girls/Boys!` to all the fine contributors for making K9s better for all of us!!

-   [#&#8203;3292](derailed/k9s#3292) fix: respect insecure flag when switch context
-   [#&#8203;3277](derailed/k9s#3277) feat: add hostPathVolume (docker)
-   [#&#8203;3253](derailed/k9s#3253) fix: set default request timeout to 120 seconds
-   [#&#8203;2866](derailed/k9s#2866) Feature/default_view

***

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/imhotep_logo.png" width="32" height="auto"/> © 2025 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)

### [`v0.50.3`](https://github.com/derailed/k9s/releases/tag/v0.50.3)

[Compare Source](derailed/k9s@v0.50.2...v0.50.3)

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s.png" align="center" width="800" height="auto"/>

### Release v0.50.3
#### Notes

Thank you to all that contributed with flushing out issues and enhancements for K9s!
I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev
and see if we're happier with some of the fixes!
If you've filed an issue please help me verify and close.

Your support, kindness and awesome suggestions to make K9s better are, as ever, very much noted and appreciated!
Also big thanks to all that have allocated their own time to help others on both slack and on this repo!!

As you may know, K9s is not pimped out by corps with deep pockets, thus if you feel K9s is helping your Kubernetes journey,
please consider joining our [sponsorship program](https://github.com/sponsors/derailed) and/or make some noise on social! [@&#8203;kitesurfer](https://twitter.com/kitesurfer)

On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_invite/zt-3360a389v-ElLHrb0Dp1kAXqYUItSAFA)

#### Maintenance Release!

A bit more code spring cleaning/TLC and address a few bugs:

1.  \[RBAC View] Fix issue bombing out on RBAC cluster roles
2.  \[Custom Views] Fix issue with parsing `jq` filters and bombing out (Big Thanks to Pierre for flagging it!)

***

#### Contributed MRs

Please be sure to give `Big Thanks!` and `ATTA Girls/Boys!` to all the fine contributors for making K9s better for all of us!!

-   [#&#8203;3273](derailed/k9s#3273) k9s plugin scopes containers issue
-   [#&#8203;3169](derailed/k9s#3169) feat: pass context and token flags to kubectl exec commands

***

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/imhotep_logo.png" width="32" height="auto"/> © 2025 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)

### [`v0.50.2`](https://github.com/derailed/k9s/releases/tag/v0.50.2)

[Compare Source](derailed/k9s@v0.50.1...v0.50.2)

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s.png" align="center" width="800" height="auto"/>

### Release v0.50.2
#### Notes

Thank you to all that contributed with flushing out issues and enhancements for K9s!
I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev
and see if we're happier with some of the fixes!
If you've filed an issue please help me verify and close.

Your support, kindness and awesome suggestions to make K9s better are, as ever, very much noted and appreciated!
Also big thanks to all that have allocated their own time to help others on both slack and on this repo!!

As you may know, K9s is not pimped out by corps with deep pockets, thus if you feel K9s is helping your Kubernetes journey,
please consider joining our [sponsorship program](https://github.com/sponsors/derailed) and/or make some noise on social! [@&#8203;kitesurfer](https://twitter.com/kitesurfer)

On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_invite/enQtOTA5MDEyNzI5MTU0LWQ1ZGI3MzliYzZhZWEyNzYxYzA3NjE0YTk1YmFmNzViZjIyNzhkZGI0MmJjYzhlNjdlMGJhYzE2ZGU1NjkyNTM)

#### 5-0, 5-0 HotFix!

It looks like we've broken a few (more) things in the clean up process 😳
This is what you get for trying to refresh a ~10 year old code base 🙀
Apologizes for the `disruption in the farce`. Hopefully much happier on v0.50.2...
Are we there yet? Crossing fingers AND toes...

☠️ Careful on this upgrade! 🏴‍☠️
We've gone thru lots of code revamp/refactor in the v0.50.0, so mileage may vary...

***

#### Resolved Issues

-   [#&#8203;3267](derailed/k9s#3267) Show some output or message when no resources are found
-   [#&#8203;3266](derailed/k9s#3266) Command alias :dp fails with "no resource meta defined for deployments" error
-   [#&#8203;3264](derailed/k9s#3264) can't execute get(y) or describe(d) in StorageClass view
-   [#&#8203;3260](derailed/k9s#3260) yaml view of pod will crash the app (Boom!! cannot deep copy int. (Maybe??)

***

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/imhotep_logo.png" width="32" height="auto"/> © 2025 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)

### [`v0.50.1`](https://github.com/derailed/k9s/releases/tag/v0.50.1)

[Compare Source](derailed/k9s@v0.50.0...v0.50.1)

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s.png" align="center" width="800" height="auto"/>

### Release v0.51
#### Notes

Thank you to all that contributed with flushing out issues and enhancements for K9s!
I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev
and see if we're happier with some of the fixes!
If you've filed an issue please help me verify and close.

Your support, kindness and awesome suggestions to make K9s better are, as ever, very much noted and appreciated!
Also big thanks to all that have allocated their own time to help others on both slack and on this repo!!

As you may know, K9s is not pimped out by corps with deep pockets, thus if you feel K9s is helping your Kubernetes journey,
please consider joining our [sponsorship program](https://github.com/sponsors/derailed) and/or make some noise on social! [@&#8203;kitesurfer](https://twitter.com/kitesurfer)

On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_invite/enQtOTA5MDEyNzI5MTU0LWQ1ZGI3MzliYzZhZWEyNzYxYzA3NjE0YTk1YmFmNzViZjIyNzhkZGI0MmJjYzhlNjdlMGJhYzE2ZGU1NjkyNTM)

#### 5-0, 5-0 HotFix!

It looks like we've broken a few things in the clean up process 😳
Apologizes for the `disruption in the farce`. Hopefully happier on v0.50.1...
Crossing fingers and toes!

☠️ Careful on this upgrade! 🏴‍☠️
We've gone thru lots of code revamp/refactor in the v0.50.0, so mileage may vary...

***

#### Resolved Issues

-   [#&#8203;3262](derailed/k9s#3262) Crash when no shellPod is defined in config file
-   [#&#8203;3261](derailed/k9s#3261) aliases with namespace and/or labels produce an error
-   [#&#8203;3258](derailed/k9s#3258) mac silicon 0.50.0 runtime error
-   [#&#8203;3257](derailed/k9s#3257) pods are reported to run on nodes they are not running on
-   [#&#8203;3256](derailed/k9s#3256) Pods view seems broken in 0.50.0
-   [#&#8203;3255](derailed/k9s#3255) Custom view does not work randomly

***

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/imhotep_logo.png" width="32" height="auto"/> © 2025 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)

### [`v0.50.0`](https://github.com/derailed/k9s/releases/tag/v0.50.0)

[Compare Source](derailed/k9s@v0.40.10...v0.50.0)

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s.png" align="center" width="800" height="auto"/>

### Release v0.50
#### Notes

Thank you to all that contributed with flushing out issues and enhancements for K9s!
I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev
and see if we're happier with some of the fixes!
If you've filed an issue please help me verify and close.

Your support, kindness and awesome suggestions to make K9s better are, as ever, very much noted and appreciated!
Also big thanks to all that have allocated their own time to help others on both slack and on this repo!!

As you may know, K9s is not pimped out by corps with deep pockets, thus if you feel K9s is helping your Kubernetes journey,
please consider joining our [sponsorship program](https://github.com/sponsors/derailed) and/or make some noise on social! [@&#8203;kitesurfer](https://twitter.com/kitesurfer)

On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_invite/enQtOTA5MDEyNzI5MTU0LWQ1ZGI3MzliYzZhZWEyNzYxYzA3NjE0YTk1YmFmNzViZjIyNzhkZGI0MmJjYzhlNjdlMGJhYzE2ZGU1NjkyNTM)

***

#### ♫ Sounds Behind The Release ♭

-   [Afterimage - Justice](https://www.youtube.com/watch?v=9zBJlLbkfzA)
-   [This Is The Day - The The](https://www.youtube.com/watch?v=qBF3YqUzYRc)

#### 5-O, 5-0... Spring Cleaning In Effect!

☠️ Careful on this upgrade! 🏴‍☠️
We've gone thru lots of code revamp/refactor on this drop, so mileage may vary!!

##### K9s Slow?

It looks like K9s performance took a dive in the wrong direction circa v0.40.x releases.
Took a big perf/cleanup pass to improve perf and think this release should help a lot (famous last words...)

> NOTE! As my dear granny use to say: `You can't cook a great meal without trashing the kitchen`,
> So likely I have broken a few things in the process. So thread carefully and report back!

##### Now with Super Column Blow!

By general demand, juice up custom views! In a feature we like to refer to as `Super Column Blow...`
As of this drop, you can go full `Chuck Norris` and sprinkle some of your JQ_FU with you custom views.

For example...

```yaml

### views.yaml
views:
  v1/pods:
    sortColumn: NAME:asc
    columns:
    - AGE
    - NAMESPACE
    - NAME
    - IMG-VERSION:.spec.containers[0].image|split(":")|.[-1]|R # => Grab the main container image name and pull the image version

### => out into the `IMG-VERSION` right aligned column
```

> NOTE: ☢️ This is very much experimental! Not all JQ queries features are supported!
> (See https://github.com/itchyny/gojq for the details!)

#### Videos Are In The Can!

Please dial [K9s Channel](https://www.youtube.com/channel/UC897uwPygni4QIjkPCpgjmw) for up coming content...

-   [K9s v0.40.0 -Column Blow- Sneak peek](https://youtu.be/iy6RDozAM4A)
-   [K9s v0.31.0 Configs+Sneak peek](https://youtu.be/X3444KfjguE)
-   [K9s v0.30.0 Sneak peek](https://youtu.be/mVBc1XneRJ4)
-   [Vulnerability Scans](https://youtu.be/ULkl0MsaidU)

***

#### Resolved Issues

-   [#&#8203;3226](derailed/k9s#3226) Filter view will show mess when filtering some string
-   [#&#8203;3224](derailed/k9s#3224) Respect kubectl.kubernetes.io/default-container annotation
-   [#&#8203;3222](derailed/k9s#3222) Option to Display Resource Names Without API Version Prefix
-   [#&#8203;3210](derailed/k9s#3210) Description line is buggy

***

#### Contributed MRs

Please be sure to give `Big Thanks!` and `ATTA Girls/Boys!` to all the fine contributors for making K9s better for all of us!!

-   [#&#8203;3237](derailed/k9s#3237) fix: List CRDs which has k8s.io in their names
-   [#&#8203;3223](derailed/k9s#3223) Fixed skin config ref of in_the_navy to in-the-navy
-   [#&#8203;3110](derailed/k9s#3110) feat: add splashless option to suppress splash screen on start

***

<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/imhotep_logo.png" width="32" height="auto"/> © 2025 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yNTkuMCIsInVwZGF0ZWRJblZlciI6IjM5LjI2NC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in-progress Mark issue as being worked on
Projects
None yet
Development

No branches or pull requests

3 participants
0