Skip to content
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

Reading host's env variables from Wasm VMs #19

Closed
mathetake opened this issue Dec 10, 2020 · 8 comments
Closed

Reading host's env variables from Wasm VMs #19

mathetake opened this issue Dec 10, 2020 · 8 comments

Comments

@mathetake
Copy link
Contributor

mathetake commented Dec 10, 2020

Actually, there's a need for reading envs from Plugins as you can see issues below:

We should have a consensus on how to deal with it, like,

  • having a restriction system to limit which variable can be read from a particular plugin
  • just leaving this to the host implementation

this is somewhat related to #17 since this would be implemented as WASI's environ_get.

@xuecanlong
Copy link

and do you have plan to support in https://github.com/proxy-wasm/proxy-wasm-rust-sdk ?

@mathetake
Copy link
Contributor Author

mathetake commented Jan 29, 2021

@xuecanlong
once it's specified in ABI, yeah this would be added to Rust SDK for sure. But we haven't reached any consensus yet. So please stay tuned for the ABI update. cc @PiotrSikora

@xuecanlong
Copy link

xuecanlong commented Jan 29, 2021

@mathetake
Thanks, I really need it.
Do we have another way to get POD_NAMESPACE and POD DEPLOYMENT NAME?

@PiotrSikora
Copy link
Member

Note that there is really nothing for the Proxy-Wasm spec to define here (well, other than saying that it's allowed, see: #17), since reading environment variables is already defined in the WASI spec.

This actually already works in the Rust SDK (if you compile it for the wasm32-wasi target), but we don't export any variables in Envoy, so the list is empty.

@mathetake if you want to add a key-value map of the variables to export from Envoy, feel free to do it. But this has to be an explicit map (possibly with pass-through for configured values) and not a complete pass-through to the host variables.

@mathetake
Copy link
Contributor Author

@mathetake if you want to add a key-value map of the variables to export from Envoy, feel free to do it. But this has to be an explicit map (possibly with pass-through for configured values) and not a complete pass-through to the host variables.

OK, will do. Thanks for clarification here!

@mathetake
Copy link
Contributor Author

Created the issue in Envoy side: envoyproxy/envoy#14958. Please refer there for those who are interested in this feature.

@linzg2002
Copy link

linzg2002 commented Dec 27, 2021

@mathetake I am very interested on this reading host env feature. So I just reviewed all issues and PR around this topic. But still not very clear about how to use it in real case. Could you give some tips? Such as how to config it in envoy.yaml and how to write the code in the wasm filter in C++?
I actually had tried like this:
in istio envoyfilter.yaml

config:
  root_id: my_root_id
  vm_config:
    code:
      local:
        filename: /var/local/lib/wasm-filters/example-filter.wasm
    runtime: envoy.wasm.runtime.v8
    vm_id: "my_vm_id"
    environment_variables: ["HOME"]

in my wasm-filter.cc

    this->theHome = std::getenv("HOME");

Unluckily, I got nothing output. So anywrong I did on this? Bwt, is the function support by istio-envoy? and which should the istio version to be at least? Looking forward for your help, thanks in advance.

@capitanFlint129
Copy link

@linzg2002, it seems to be used like this:

environment_variables:
  host_env_keys: ["HOME"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants