1 hour ago · Tech · 0 comments

I use saltstack to manage deployment of docker containers in my homelab. For two of my cloud servers, I am running them in memory constrained environments for cost reasons, and typically only run the minimum required there. Since I wanted to wrap the docker_container module, I started by creating my own state in _states/docker_customized. I can do a simple naive version, just by using setdefault # _states/docker_customized.py def running(name, **kwargs): kwargs.setdefault("mem_limit", "1024M") kwargs.setdefault("oom_score_adj", 100) return __states__["docker_container.running"](name, **kwargs) If I then do a find replace on s/docker_container.running/docker_customized.running/g, then when I use state.apply on a target, it will call my method, update the values I want, before calling the original with the updated parameters (I may also need to update any watch or requires entires as needed). I can then take this further, and do more specific logic, like basing the limit on the server…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.