kube-forwarder
kube-forwarder copied to clipboard
Environment variables auto-injection
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...
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)?
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 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 I'll try to add more details:
Initial conditions:
- I have k8s cluster
- I have installed "Kube Forwarder" on my local machine
- I have local project
A
that reads standard k8s environment variables to communicate with serviceB
inside k8s cluster (for exampleB_SERVICE_HOST
andB_SERVCE_PORT
)
Steps:
- In "Kube Forwarder" I add new resource that represents my service
B
, with forwarding resource port 8080 to my local port 8081 - "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 - I run my local project
A
and it automatically connects to serviceB
that is inside k8s cluster with the help of port forwarding and env variables injection.
Thanks! Now, It is clear for me. I agree it could be a nice feature.
I suppose it could be implemented in this way:
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.
That's kind of interesting, but where would it inject those environment variables into? .bashrc
?