Skip to content

Reading host's env variables from Wasm VMs #19

Closed

Description

@mathetake

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.

Activity

  1. mathetake commented on Jan 29, 2021

    @mathetake
    ContributorAuthor

    @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

  2. xuecanlong commented on Jan 29, 2021

    @xuecanlong

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

  3. PiotrSikora commented on Feb 5, 2021

    @PiotrSikora
    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.

  4. mathetake commented on Feb 5, 2021

    @mathetake
    ContributorAuthor

    @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!

  5. mathetake commented on Feb 5, 2021

    @mathetake
    ContributorAuthor

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

  6. linzg2002 commented on Dec 27, 2021

    @linzg2002

    @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.

  7. capitanFlint129 commented on May 8, 2022

    @capitanFlint129

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions