kube-forwarder icon indicating copy to clipboard operation
kube-forwarder copied to clipboard

Environment variables auto-injection

Open vintikzzz opened this issue 5 years ago • 6 comments

It would be great if also environment variables will be injected while enabling port forwarding. I am talking about SOME_SERVICE_HOST, SOME_SERVICE_PORT and so on...

vintikzzz avatar Aug 17 '19 15:08 vintikzzz

Hi @vintikzzz, thanks for the feature request! Could you clarify, please, where you would like to use env variables? In the config text, config's path or in resource fields (name/namespace)?

proAlexandr avatar Aug 19 '19 06:08 proAlexandr

Ok! I have a lot of golang microservices in development. Every microservice reads information about location of another services from environment variable (see k8s docs). So it will be great if such env variables automatically become available in my dev-environment like this happens inside k8s.

vintikzzz avatar Aug 19 '19 11:08 vintikzzz

@vintikzzz Thanks for your comment, it seems I completely misunderstood the issue description. Is it something like "Env variables forwarding" feature? l.e. you want that env variables from a pod are available on your dev machine (the machine on which Kube Forwarder is installed)?

proAlexandr avatar Aug 21 '19 07:08 proAlexandr

@proAlexandr I'll try to add more details:

Initial conditions:

  1. I have k8s cluster
  2. I have installed "Kube Forwarder" on my local machine
  3. I have local project A that reads standard k8s environment variables to communicate with service B inside k8s cluster (for example B_SERVICE_HOST and B_SERVCE_PORT)

Steps:

  1. In "Kube Forwarder" I add new resource that represents my service B, with forwarding resource port 8080 to my local port 8081
  2. "Kube Forwarder" makes port forwarding for service B and also injects environment variables on my local machine B_SERVICE_HOST=127.0.0.1 and B_SERVCE_PORT=8081
  3. I run my local project A and it automatically connects to service B that is inside k8s cluster with the help of port forwarding and env variables injection.

vintikzzz avatar Aug 21 '19 12:08 vintikzzz

Thanks! Now, It is clear for me. I agree it could be a nice feature. I suppose it could be implemented in this way: image There is an advanced section in the resource form. After you open it you see the checkbox. If the checkbox is checked two text fields appear and have default values based on the resource name.

Sorry, I can't promise you that the feature will be implemented soon. Feel free to make a PR if it's very important for you.

proAlexandr avatar Aug 22 '19 05:08 proAlexandr

That's kind of interesting, but where would it inject those environment variables into? .bashrc ?

dobesv avatar Apr 15 '20 23:04 dobesv