-
Notifications
You must be signed in to change notification settings - Fork 208
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
Context names with special characters break generated hostnames #240
Comments
hosswald
changed the title
Context names with special characters break hostnames
Context names with special characters break generated hostnames
Sep 7, 2022
hosswald
added a commit
to hosswald/kubefwd
that referenced
this issue
Sep 7, 2022
…ng [^a-zA-Z0-9\-.] with underscore) fixes txn2#240
hosswald
added a commit
to hosswald/kubefwd
that referenced
this issue
Sep 12, 2022
…placed with dash * leading and trailing dashes are stripped * added test txn2#240
hosswald
added a commit
to hosswald/kubefwd
that referenced
this issue
Sep 12, 2022
…placed with dash * leading and trailing dashes are stripped * added test txn2#240
hosswald
added a commit
to hosswald/kubefwd
that referenced
this issue
Sep 12, 2022
…placed with dash * leading and trailing dashes are stripped * added test txn2#240
D3-LucaPiombino
pushed a commit
to CodeCoil/kubefwd
that referenced
this issue
Jun 13, 2024
…ng [^a-zA-Z0-9\-.] with underscore) fixes txn2#240
D3-LucaPiombino
pushed a commit
to CodeCoil/kubefwd
that referenced
this issue
Jun 13, 2024
…placed with dash * leading and trailing dashes are stripped * added test txn2#240
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First of all, thanks for the amazing tool. I've been using Kube Forwarder so far and was missing the ability wo forward one or more clusters all at once, and having to come up with ports because everything is accessible via localhost only.
However, I found two problems that make my use-case more complicated.
I have multiple OpenShift contexts that I need to connect to at the same time and that I log into using oc login. This command creates contexts in my .kube/config that are named like this:
project-name/cluster-name:6443/username
Based on this, kubefwd creates hostnames like this from that: service-name.namespace.project-name/cluster-name:6443/username
Forward slashes and colons in hostnames are obviously not so great. While some programs don't have a problem with that (e.g. psql --host), most programs don't like this at all because it cannot be parsed. Add a port and it becomes even more obvious: service-name.namespace.project-name/cluster-name:6443/username:5432
My suggestion is to add for each hostname generated in the hosts file a variant where any characters not allowed in hostnames (in my case: "/" and ":") are replaced by "-" or "_".
My workaround was using kubectl config rename-context. When I log in again (oc login tokens expire after 24h), it will add a new context, but the credentials are also used for the renamed context, which I can pass to kubefwd moving forward.
Bonus question: I tried to work around this using --domain, however I could not find a way to make this work with multiple contexts and namespaces(use --domain d1 for --context c1 --namespace n1 and --domain d2 for --context c2 --namespace n2).
The text was updated successfully, but these errors were encountered: