I’m looking in to setting up a micro service that can create nomad jobs from within nomad. I can’t find any information of how one can set that up. Is there a minimal example of how to do it? Is it even possible?
Similar to how one can use docker if one mounts the docker socket in to the container, i.e. docker run -it -v /var/run/docker.sock:/var/run/docker.sock ubuntu:latest sh -c "apt-get update ; apt-get install docker.io -y ; bash", and rbacandClusterRole` in k8s to be able to control the cluster from inside the cluster.
If the cluster has a public ip one can of course call it on that url, but it would be nice not requiring a public ip such one can use it for local development etc.
This has come up before. We’re currently exploring options for making this a first-class feature and where to prioritize it, but in the meantime, you could write your own job controller using the HTTP API. You should be able to inject the client IP using env { HOST_IP = “${attr.unique.network.ip-address}” } and then access it using the HTTP API.
If you are programming in go, you can check out the api package in the main Nomad repository for a fully baked API Client implementation. Also, we have a new experimental openapi project that is under active development. It doesn’t cover all endpoints yet, but it has Jobs, and it has multiple language targets. If you don’t see your language of choice you can even add your own. Take a look at the Makefile and the README for instructions and examples of how to generate clients for other languages. Also, feel free to submit a PR if you do add another language or add coverage for other endpoints. We’re definitely looking for contributors.
@DerekStrickland Thx that should work, I just could not figure out how to get that ip. I was thinking of using the HTTP API or Home - python-nomad for now, as I probably will do a quick setup of this in python for now.
@fhemberger The plan is to use the HTTP API or simmilar sdk. But my question is how to get that ip to call from within the cluster. That was the ip that could be public assuming one enables auth for nomad not the service itself. Sorry if that was unclear.
Hi @joh4n, I’m the creator of python-nomad and also a maintainer. While it took us a bit to add event stream support. You can now in the 1.4.1 version create a listener against the event stream to send results to a more established message broker/pub sub. It’s not exactly like firehose but give you the capability to integrate into your stack upon your discretion.
With Hashicorp adding an official openapi specification I imagine this will be the way to to go to generate client libraries once it has full compatibility with all of Nomads routes. python-nomad also doesn’t have 100% route support as well, but hoping to bridge that gap till the openapi spec is.
The events api seems like exactly what I was looking for I should probably read trough the https://www.nomadproject.io/api-doc I have just been reading on Documentation | Nomad by HashiCorp