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

Define environment variables for deployed containers #95

Closed
4 tasks done
robhaswell opened this issue Jun 18, 2014 · 7 comments
Closed
4 tasks done

Define environment variables for deployed containers #95

robhaswell opened this issue Jun 18, 2014 · 7 comments

Comments

@robhaswell
Copy link
Contributor

Docker convention is to supply runtime configuration to containers as environment variables. A user must be able to define the environment for each container in the Flocker configuration.

@robhaswell robhaswell changed the title deploy.cfg must support environment variabels for containers Define environment variables for deployed containers Jun 18, 2014
@robhaswell robhaswell added this to the Release 0.1 milestone Jun 18, 2014
@exarkun
Copy link
Contributor

exarkun commented Jun 19, 2014

This is probably part of the application configuration. Along with the volume and image information, we should include a section for environment variables and their values.

@itamarst itamarst removed this from the Release 0.1 milestone Jun 26, 2014
@itamarst
Copy link
Contributor

We can probably do the demonstrations we want for 0.1 without this feature.

@itamarst itamarst added this to the Release 0.2 milestone Aug 13, 2014
@itamarst
Copy link
Contributor

Latest gear supports this I think, but we may need to update the gear we've packaged.

@wallrj wallrj self-assigned this Aug 14, 2014
@wallrj
Copy link
Contributor

wallrj commented Aug 14, 2014

It seems that our versions of gear and docker do allow us to supply environment variables.

[vagrant@localhost environment-server]$ sudo gear install --start=true clusterhq/environment-server:1 rjw1 foo=bar deep=purple firstname=richard
Setting --env-id to N4bFpLmjQwT4iZqCa5mIwA
systemd: Reloading daemon
Container rjw1 is starting
[vagrant@localhost environment-server]$ sudo gear status rjw1
ctr-rjw1.service - Container rjw1
   Loaded: loaded (/var/lib/containers/units/rj/ctr-rjw1.service; enabled)
   Active: active (running) since Thu 2014-08-14 02:36:25 PDT; 8s ago
  Process: 3830 ExecStartPost=/usr/bin/gear init --post rjw1 clusterhq/environment-server:1 (code=exited, status=0/SUCCESS)
  Process: 3821 ExecStartPre=/usr/bin/docker rm rjw1 (code=exited, status=1/FAILURE)
  Process: 3811 ExecStartPre=/bin/sh -c /usr/bin/docker inspect --format="Reusing {{.ID}}" "rjw1-data" || exec docker run --name "rjw1-data" --volumes-from "rjw1-data" --entrypoint /bin/true "clusterhq/environment-server:1" (code=exited, status=0/SUCCESS)
 Main PID: 3829 (docker)
   CGroup: /container.slice/container-small.slice/ctr-rjw1.service
           └─3829 /usr/bin/docker run --rm --name rjw1 --volumes-from rjw1-data --env-file /var/lib/containers/env/contents/N4/N4bFpLmjQwT4iZqCa5mIwA -a stdout -a stderr clusterhq/environment-server:1

Aug 14 02:36:25 localhost.localdomain gear[3830]: user: unknown user ctr-rjw1
Aug 14 02:36:25 localhost.localdomain systemd[1]: Started Container rjw1.
Aug 14 02:36:25 localhost.localdomain docker[3829]: export HOME='/'
Aug 14 02:36:25 localhost.localdomain docker[3829]: export HOSTNAME='61f7cbe4d8f4'
Aug 14 02:36:25 localhost.localdomain docker[3829]: export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
Aug 14 02:36:25 localhost.localdomain docker[3829]: export PWD='/'
Aug 14 02:36:25 localhost.localdomain docker[3829]: export SHLVL='1'
Aug 14 02:36:25 localhost.localdomain docker[3829]: export deep='purple'
Aug 14 02:36:25 localhost.localdomain docker[3829]: export firstname='richard'
Aug 14 02:36:25 localhost.localdomain docker[3829]: export foo='bar'

See openshift/geard#208 for the gear feature discussion.

Next I'll see if it's possible to supply environment variables via the REST API.

@wallrj
Copy link
Contributor

wallrj commented Aug 14, 2014

Ok, after some trial and error, I figured out that this is how to set the environment from the REST API

curl -X PUT "http://localhost:43273/container/rjw3" -H "Content-Type: application/json" -d '{"Image": "clusterhq/environment-server:1", "Started":true, "Environment":{"Id":"rjw3", "Variables":[{"Name": "Foo", "Value": "Bar"}]}}'

@wallrj
Copy link
Contributor

wallrj commented Aug 14, 2014

I created a geard ticket suggesting they document this. See openshift/geard#256

@itamarst
Copy link
Contributor

Remaining work to be covered by this issue: user facing documentation and entry in What's New. Unless there's something I'm missing? I guess there's also "notice if environment variables changed" which maybe is a follow up issue?

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

No branches or pull requests

4 participants