coreos / layering-examples

Apache License 2.0
105 stars 24 forks source link

inject-go-binary: Move service into `/usr`, statically enabled #55

Closed cgwalters closed 1 year ago

cgwalters commented 1 year ago

A big deal about the move to custom containers is that user content is treated the same way as OS content. We should encourage storing custom systemd units in /usr so that they also end up underneath the read-only bind mount too.

While we're here, also do the "static enablement" pattern to force the unit on, regardless of presets. Because thinking about presets is just annoying and unnecessary really. If I'm injecting my custom service, there's really no scenario where I want some other preset file to control its enablement.

cgwalters commented 1 year ago

With this I see:

[root@cosa-devsh ~]# systemctl status hello-world
● hello-world.service - A hello world unit!
     Loaded: loaded (/usr/lib/systemd/system/hello-world.service; disabled; preset: disabled)
     Active: active (exited) since Fri 2023-03-24 13:02:21 UTC; 21s ago
    Process: 975 ExecStart=/usr/bin/hello-world (code=exited, status=0/SUCCESS)
   Main PID: 975 (code=exited, status=0/SUCCESS)
        CPU: 1ms

as expected. Note the preset: disabled - but that doesn't matter because we forced it on. We don't want to care about presets.