Hi there! I am brand new to working with Allocations - HTTP API | Nomad by HashiCorp and I was wondering if someone could provide an example of code that provides a good starting point for a new person. If it’s in ruby, that would be even better. Currently, I am unable to fully understand how to construct the WebSocket request. Thank you in advance
Thanks for using Nomad!
For a general-purpose ruby client, you can check out the Nomad OpenAPI Project project. It contains a ruby client, but that client does not yet support streaming endpoints like
exec. Were still figuring out how we want to handle streaming endpoints.
I hope between the two you find the help you need.
- Derek and the Nomad Team
Thank you for the quick reply! Aside from using WebSockets, is there any other way to interact with the an alloc shell? Our team is looking to execute basic health/troubleshooting commands that don’t require real time in/out streams (i.e. execute a command and output data to a file).
For a one-shot command I think you just want to use the
nomad alloc exec command. Here are the docs. Then you could just pipe that to a local file.
Thank you again! So, it looks like (for example) the below could be remotely executed to create a heap dump of an alloc without having to enter the interactive shell:
nomad alloc exec eb17e557 /bin/sh -c 'jcmd <pid of alloc> GC.heap_dump /alloc/tmp/alloc_heapdump.bin'
That seems like it should work. Have you tried it?
Not yet… I will keep this thread updated. Thanks!
The above did work. Thank you!