knight42 / krelay

A better alternative to `kubectl port-forward` that can forward TCP or UDP traffic to IP/Host which is accessible inside the cluster.
MIT License
248 stars 15 forks source link

always using default namespace? #5

Closed jonsalvas closed 2 years ago

jonsalvas commented 2 years ago

First of all: Thanks for the awesome plugin, this is exactly what I need.

Unfortunately I am a bit stuck, because a `kubectl relay' seems to always create a deployment in the default namespace, for which I don't have access to. Is there a way to specify the target namespace somehow (-n is ignored)?

I0413 08:27:51.904065    1474 main.go:142] "Check if krelay-server exists"
Error: ensure krelay-server: get krelay-server: deployments.apps "krelay-server" is forbidden: User "u-fnkzi4b3ce" cannot get resource "deployments" in API group "apps" in the namespace "default"

Command was:

kubectl relay -n mynamespace host/my.host.com 6333

Thanks!

knight42 commented 2 years ago

@jonsalvas Hi! I am glad that you find this plugin useful ❤️ !

Regarding to your question, the flag -n represents the namespace of the target object(such as Service, Pod). I think we could add a new flag, like --server.namespace, to override the current hard-coded default namespace.

Nevertheless some required permissions must be granted to use this plugin. If you only want to forward traffic to a hostname, please make sure the following permissions is granted

rules:
- apiGroups:
  - ""
  resources:
  - pods
  - pods/portforward
  verbs:
  - create
  - watch
- apiGroups:
  - apps
  resources:
  - deployments
  verbs:
  - create
  - get
  - watch
knight42 commented 2 years ago

@jonsalvas Hi! Please upgrade krelay to the latest version v0.0.4, and try out the following command:

kubectl relay --server.namespace mynamespace host/my.host.com 6333