Nomad 0.11 includes a new Web UI incarnation of the allocation exec feature that was first added to the CLI in Nomad 0.9.2. This lets operators connect to an allocation on a client and investigate without having to leave the browser.

Access and Use

You can find an exec button in the title area of running jobs, allocations, task groups, and tasks:

1585778570 nomad exec web u 1

Clicking it will open an exec popup for the job, listing its running task groups and tasks in the sidebar. Once you select a task (or if you arrived directly from a task detail page), you can customizse the command that will be run on the client and submit it to open the session.

1585778587 nomad exec web u 2

Run your commands as you would in any terminal and close the window when you’re done. If you need to probe another task within the job, you can click it in the sidebar to open another exec window.

Implementation

The feature incorporates Xterm.js, a web-based open-source terminal implementation used in popular projects such as VS Code. The UI opens a WebSocket via the API using the specified shell command, translates incoming socket frames into terminal output, and sends transformed user input through the socket.

Future Improvements

For now, the command used to open the exec session defaults to /bin/bash. This can be customizsed before opening the session, but subsequent sessions will still have it as the default. The final implementation will include persistence of the specified command in local storage so if you always use /bin/sh, for instance, you’ll only have to change it once in your browser.

1585778579 sidebar blog full

The sidebar is static in the current implementation, which means tasks that stop running will remain despite it no longer being possible to exec into them, and new tasks will not show up. A live-updating sidebar is in active development.

As of the existing implementation, ACLs are not consulted to determine whether your token has permission to open an exec session, but we plan to add permission-checking to conditionally turn off the exec button.

For other known bugs and limitations, see here. If you run into any undocumented bugs or have feature requests that aren’t covered there, let us know.

from Hashicorp Blog: https://www.hashicorp.com/blog/hashicorp-nomad-remote-exec-web-ui