Schedule to dynamic ip

Heja there,

is there any way to use contraint or affinity to schedule a job to the host currently running the keepalived dynamic-ip?

Long: I’m running a small cluster with fixed ips but also some additional VIPs with keepalived. This all works well, what I can’t get my head around how I could schedule the workloads through nomad so that it lands on the host which is running the VIP at that time.

My first thought was to use host_network in client config with reloading nomad service on the fly through the keepalived scripts. But I cant get it to work this way.

Currently running 1.0.0-b3 still.

1 Like

purely as a hack … could it possible as follows:

  • a system job (while 1 loop) which updates a meta variable inside Nomad’s config directory to indicate where the IP is present.

  • non IP machines will emit “nothing” or empty in this variable

  • the job should update the file only if the previous value of the “ip state” was different (and somehow cause the Nomad Agent to reload.

  • the Nomad job can then use the meta variable to do scheduling

Of course, I see cases (short duration) where more that one machine could have the “I hold the IP” state set to true

1 Like

Another thought is a possible script based health check which can do something similar.
Maybe even update a variable back into Consul?

1 Like

You’re right. I thought to do it with keepalived scripts on its own but if kad fails those don’t work so I’ll need a watchdog for this. This can do its magic with the nomad metadata. That said I tried systemctl reload but meta seem to be only loaded with restart. As is the host_network too.

Then I also thought about consul. But I actually don’t know how to handle this or if nomad can reschedule based on consul checks/kv - so I have to tackle this first.

That said I hoped for an easy solvable thing but it’s just getting more complicated with each idea I have. That’s one thing I’m missing for nomad - a way to get more “information”/“out-of-the-box” metadata. Like ALL the IPs of the host available not only the one unique.

I’ve read your suggestions again and realized I’ve not understood them correctly the first time. I never thought about an nomad own systemjob (thought systemd here).

I like both ideas - I’m still tinkering with nomad only and have much to learn :smiley: It’s alot harder to find things online about nomad compared to k8s for example.

1 Like

This is an excellent interview question, in my opinion! :grin: :smiley: