clearlinux / cloud-native-setup

Automation around setting up the cloud-native content (kubernetes) on Clear Linux.
Apache License 2.0
61 stars 41 forks source link

Systemd level proxy instead of per service #307

Closed krsna1729 closed 4 years ago

krsna1729 commented 4 years ago

There is a way to use systemd level environment such that all services can inherit the environment, in this case the proxy env variables.

https://github.com/clearlinux/cloud-native-setup/blob/603c42703fe33bb6f30ec7d070f6eba6a71c5dd5/clr-k8s-examples/setup_system.sh#L158-L168

https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html

DefaultEnvironment=
Sets manager environment variables passed to all executed processes. Takes a space-separated list of variable assignments. See environ(7) for details about environment variables.

Example:

DefaultEnvironment="VAR1=word1 word2" VAR2=word3 "VAR3=word 5 6"
Sets three variables "VAR1", "VAR2", "VAR3".
CraigSterrett commented 4 years ago

I have not had luck getting this to work, even just manually setting the values with systemctl set-environment HTTP_PROXY="..." and doing a systemctl daemon-reload. Have you ever done this for system level environment variables?

krsna1729 commented 4 years ago

systemctl daemon-reexec might be needed.