• 2 Posts
  • 15 Comments
Joined 1 year ago
cake
Cake day: July 2nd, 2023

help-circle
  • I think there are two approaches to infrastructure as code (and even code in general):

    • as steps (ansible, web UI like pihole…)
    • declarative (nix, k8s, nomad, terraform…)

    Both should scale (in my company we use templating a lot) but I find the latter easier to debug, because you can ‘see’ the expected end result. But it boils down to personal preference really.

    As for your case, ideally you don’t write custom code to generate your template (I agree with you in that it’s tedious!), but you use the templating tool of your framework of choice. You can see this example, it’s on grimd (what I forked leng from) and Nomad, but it might be useful to you.

    P.S also added to the docs on the signal reloading here


  • I have a similar use case where I also need my records to change dynamically.

    Leng doesn’t support nsupdate (feel free to make an issue!), but it supports changing the config file at runtime and having leng reread it by issuing a SIGUSR1 signal. I have not documented this yet (I’ll get to it today), but you can see the code here

    Alternatively, you can just reload the service like you do with pihole - I don’t know how quick pihole is to start, but leng should be quick enough that you won’t notice the interim period when it is restarting. This is what I used to do before I implemented signal reloading.

    Edit: my personal recommendation is you use templating to render the config file with your new records, then reload via SIGUSR1 or restart the service. nsupdate would make leng stateful, which is not something I desire (I consider it an advantage that the config file specifies the server’s behaviour exactly)









  • What you described is correct! How to replicate this will depend heavily on your setup.

    In my specific scenario, I make the containers of all my apps use leng as my DNS server. If you use plain docker see here, if you use docker compose you can do:

    version: 2
    services:
     application:
      dns: [10.10.0.0] # address of leng server here!
    

    Personally, I use Nomad, so I specify that in the job file of each service.

    Then I use wireguard as my VPN and (in my personal devices) I set the DNS field to the address of the leng server. If you would like more details I can document this approach better in leng’s docs :). But like I said, the best way to do this won’t be the same if you don’t use docker or wireguard.

    If you are interested in Nomad and calling services by name instead of IP, you can see this tangentially related blog post of mine as well