threefoldtech / cloud-container

A builder for a simple initramfs image to run container over virtiofs inside cloud-hypervisor
Apache License 2.0
0 stars 1 forks source link

pass env vars via /etc/environment #24

Closed muhamadazmy closed 6 months ago

muhamadazmy commented 6 months ago

To unify passing env vars for cloud-init and cloud container we should pass env vars from the /etc/environment file. By providing a write-file option to cloud init as per this post here

https://stackoverflow.com/questions/38044184/how-to-set-system-wide-environment-variable-in-cloud-config-file-on-digital-ocea

AbdelrahmanElawady commented 6 months ago

From the stackoverflow thread it seems to be OS dependent. /etc/environment seems to be working with Ubuntu but on Alpine for example it's in /etc/profile. Do we check what OS we are using or which env file exists and append based on that?

muhamadazmy commented 6 months ago

Yeah i know it's os dependent but was hoping that all distros uses the same file.

AbdelrahmanElawady commented 6 months ago

After looking into it, it turned out there is no standard way or file that guarantee global environment variables for all processes to use. Cloud-init also does not handle environment variables at all. IMO I think the approaches we are doing now with setting it in containers and passing it as kernel args in VMs are enough.

muhamadazmy commented 6 months ago

I agree:

I will close this as won't fix