-
Notifications
You must be signed in to change notification settings - Fork 56
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
Discussion: feature to allow passing environment variables from Pebble's own environment to services #125
Comments
One option would be an explicit Service description that says to pass
through specific env variables.
Certainly a common pattern for K8s config is env vars on the pod, and that
would be able to flow naturally to env vars for the runtime application if
you could pass them through.
I don't know yet whether that encourages good behavior or not, though.
…On Wed, Jul 20, 2022 at 8:43 AM Jon Seager ***@***.***> wrote:
This is part request, part discussion...!
Could we/should we support the ability for Pebble to pass elements of its
own environment to running services?
For example. if I were to start pebble with SOME_VAR=foobar pebble run
--hold, it would be interesting to allow a mechanism for passing SOMEVAR
to the services it manages?
—
Reply to this email directly, view it on GitHub
<#125>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABRQ7PKB4VVKQOLSDCJZXLVU7X5XANCNFSM54DQPQ4A>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
We were planning a feature where we'd allow
Just a silly example, but that would run Strictly speaking this might break backwards compatibility, if people really do have Thoughts? |
I think the interpolation in other fields is probably a slightly different concern. The I was actually envisaging something less fancy at this point which could be a field in the service spec named My use case is actually for firing things up on my desktop and inheriting variables like |
I think I would actually prefer something like:
or
|
Yeh |
I can see that What about And then as a related but separate feature, add support for
|
Ha, I just looked at the code (as well as testing it) and rediscovered that Pebble already inherits the parent environment for services. The code starts with
So
Then you run Pebble (
Side note: I edited the above comments as I realized that the config field is |
FWIW, @hpidcock initially suggested the |
Ah, that's interesting. I'll need to go back and check. Indeed, I think interpolation will get us there in that case. |
I don't think we want a behavior which is "inherit everything without
thinking about it", do we? It's convenient, but a very large hammer.
…On Thu, Jul 21, 2022 at 10:21 PM Ben Hoyt ***@***.***> wrote:
I can see that env-from is "cool", but I find it a bit confusing and
over-complicated. I'd like to keep things as simple as possible, and
relatively explicit.
What about inherit-env: true | false for when you want to inherit all of
Pebble's environment variables.
And then as a related but separate feature, add support for $SOMEVAR
interpolation to the command and env value fields. To me that reads
fairly obviously when you're reading layer config, and you can still be
explicit if you want to only inherit some variables by doing the following
(inheriting only FOO and BAR):
env:
FOO: $FOO
BAR: $BAR
—
Reply to this email directly, view it on GitHub
<#125 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABRQ7LMVCG42NAXPZ4OSCLVVIATBANCNFSM54DQPQ4A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@jameinel Perhaps, though see above -- it is what we have now! :-) |
In a voice discussion today, @hpidcock suggested that for one-shot commands and for We could have a special value like |
That sounds sensible. Would tie in well with our discussions around debugging where we could allow users to get a shell in the context of a service for debugging purposes. |
I went through the need of inheriting from the container environment during an exec when working on a charm. Basically the original docker container relies on one-shot shell scripts executed at startup. These scripts uses env vars declared with default value in the Dockerfile
I really like the idea of giving the possibility to pass the context, or select variables we'd like to pass from the context |
We discussed some of this with Gustavo last night, and there was general agreement that it'd be good to add an API parameter We should also add a However, note that this doesn't resolve this specific issue, which is about services inheriting Pebble's own environment variables. So I'll open another new issue for the context feature. (#159) |
Closing this. Per above, service execution already inherits environment variables (and #234 made that happen for exec and health checks too). Then in #246 we added "service context" for exec and health checks, allowing those command executions to run in the context of (inherit env vars, working-dir, and user/group) a specified service. Separately, at some point we plan to add |
This is part request, part discussion...!
Could we/should we support the ability for Pebble to pass elements of its own environment to running services?
For example. if I were to start pebble with
SOME_VAR=foobar pebble run --hold
, it would be interesting to allow a mechanism for passingSOMEVAR
to the services it manages?The text was updated successfully, but these errors were encountered: