hcavarsan / kftray

manage multiple kubectl port-forward commands, with support for UDP, K8s proxy, and github state sync.

Home Page:https://kftray.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Associate port forward to a domain name

merlindorin opened this issue · comments

Is your feature request related to a problem? Please describe.
I can have a lot of port-forward but naming them and having the ability to use them easily will be nice :).

Describe the solution you'd like
Add the ability to associate a domain to a forward. A local reverse proxy would be nice :) .

Describe alternatives you've considered
Nope, I am lazy

quick thought on a solution - i'd have to change the /etc/hosts file on the machine, and that might mess things up on the user's local machine.

but i'll think on it and circle back with more info...

having the domain with the same alias would be a cool feature, thanks for the feedback!

@merlindorin released ! https://github.com/hcavarsan/kftray/releases/tag/v0.9.0

when adding a new configuration, you can now choose to use an alias as a local domain name. If this option is enabled, when starting a new port forward in this configuration, kftray will add a new entry to the host file of the OS. This entry will add the alias and the local address. (this entry will be removed when port forwarding stops.)

image

can you check if it helps?

If you have any questions, please let me know

This is awesome, gonna check that once I am back from vacation . Thx!

Hi @hcavarsan , checking the feature and it is not working. I also checked the host file and it is unmodified.

I have this configuration:

Screenshot 2024-03-31 at 16 34 22

Some check I've done:

I used the link to open it in the browser. Didn't work.
curl http://argocd.cluster:8090/
curl: (6) Could not resolve host: argocd.cluster
ping argocd.cluster

ping: cannot resolve argocd.cluster: Unknown host
cat /etc/hosts

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section

hey @merlindorin , im reopening the issue to look into it... could you give me some more details:

  • what OS are you using?
  • did you try closing and reopening the app to see if the issue persists?
  • could you try installing the app via Homebrew to see if the same issue occurs?

ill see if i can simulate the issue on my end.

thx for the feedback!

hey, @merlindorin! are you still having the issue with the alias?

Re, sry for the delay.

  • what OS are you using? MacOS 14 Sonoma on M1.
  • did you try closing and reopening the app to see if the issue persists? Yes, and the issue is still there
  • could you try installing the app via Homebrew to see if the same issue occurs? Not working

btw, the brew installation method does not work on MacOS. The installer needs pnpm and even if it is installed it still need it...

brew install --HEAD kftray
==> Fetching hcavarsan/kftray/kftray
==> Cloning https://github.com/hcavarsan/kftray.git
Updating /Users/merlin/Library/Caches/Homebrew/kftray--git
==> Checking out branch main
Already on 'main'
Your branch is up to date with 'origin/main'.
HEAD is now at ebf28a3 fix: fix arrow position in windows OS
==> Installing kftray from hcavarsan/kftray
Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Settings.

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 15.1.

==> npm install -ddd --global --build-from-source --cache=/Users/merlin/Library/Caches/Homebrew/npm_cache --prefix=/opt/homebrew/Cellar/kftray/HEAD-ebf28a3/libexec /private/tmp/kftray-20240412-12011-v0uca2/kftray-0.9.6.tgz
==> npm install
==> npm run tauri build -- -b app
Last 15 lines from /Users/merlin/Library/Logs/Homebrew/kftray/03.npm:
npm
run
tauri
build
--
-b
app


> kftray@0.9.6 tauri
> tauri build -b app

     Running beforeBuildCommand `pnpm build`
sh: pnpm: command not found
       Error beforeBuildCommand `pnpm build` failed with exit code 127

If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
  https://github.com/hcavarsan/homebrew-kftray/issues


Error: A newer Command Line Tools release is available.
Update them from Software Update in System Settings.

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 15.1.

kftray's formula was built from an unstable upstream --HEAD.
This build failure is expected behaviour.
Do not create issues about this on Homebrew's GitHub repositories.
Any opened issues will be immediately closed without response.
Do not ask for help from Homebrew or its maintainers on social media.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.

@merlindorin got it! to install with brew, you need to install xcode first using xcode-select --install. I'll include this info in the readme. thanks!

also, could you run KFTray with enabled logs and check for errors in the logs? you can share the logs with me if you prefer.

io generate the logs, run this command in the terminal:

RUST_LOG="trace" KFTRAY_DEBUG="true" open /Applications/kftray.app

The logs file will be created in $HOME/.kftray/app.log.

xcode is already installed. The issue is sh: pnpm: command not found (even installed locally, do not want to work :/ ).

About the issue by itself... well it is now clear enough:

[2024-04-14T06:50:21Z ERROR kubeforward::port_forward] Failed to write to the hostfile for argocd-server: Permission denied (os error 13)

@merlindorin It looks like the problem is with the /etc/ directory being quite restricted. I'm going to look into a solution for this. In the meantime, there are two possible ways to address the issue and use the aliases:

  1. Run sudo chmod ugo+rw /etc/hosts to grant write permission to this file.
  2. Execute kftray with sudo by running sudo /Applications/kftray.app/Contents/MacOS/kftray.

These solutions are not the most secure since they grant write permission to the file itself, but they will resolve the issue for now. I'll keep this issue open to track the progress of the possible implementation to a more secure way (although it's unclear if that's feasible, as the app requires write permissions in the hosts file), is that okay with you?

Regarding the pnpm point, I've fixed it here: hcavarsan/homebrew-kftray@a6edaff. Now, if you run brew update and brew install, it should work :)

Thank you for the analysis and logs.

Awesome! Thanks a lot. Each day is a better day ;)

cool @merlindorin, i opened issue #230 to track and improve the local domain changes. thx for reporting these issues with kftray, it really makes the app better and more consistent :)