Skip to content

Latest commit

 

History

History
264 lines (211 loc) · 12.7 KB

configuration.md

File metadata and controls

264 lines (211 loc) · 12.7 KB

Configuration

urga does not need a configuration file. It reads the same environment variables as the nomad CLI, and command-line flags override them.

If you work with several clusters and want to switch between them inside urga, you can add an optional settings file. See Named clusters.

Environment variables

Variable Description
NOMAD_ADDR Address of the cluster. Default: http://127.0.0.1:4646.
NOMAD_TOKEN ACL token.
NOMAD_REGION Region to use. Default: the region of the agent urga connects to.
NOMAD_NAMESPACE Namespace to open on the first run. Default: all namespaces.
NOMAD_HTTP_AUTH user:password for a cluster behind HTTP basic auth.
NOMAD_CACERT CA certificate used to verify the cluster.
NOMAD_CAPATH Directory of CA certificates, instead of a single file.
NOMAD_CLIENT_CERT Client certificate, if the cluster requires one.
NOMAD_CLIENT_KEY Key of the client certificate.
NOMAD_TLS_SERVER_NAME Server name used to verify the certificate.
NOMAD_SKIP_VERIFY Set to true to skip certificate verification.
URGA_NO_UPDATE_CHECK Set to any value to stop urga from checking for a newer release and reading the release notes. See Newer releases.

Flags

Flag Description
--address Address of the cluster. Overrides NOMAD_ADDR.
--region Region to use. Overrides NOMAD_REGION.
--namespace Namespace to open. Overrides NOMAD_NAMESPACE and the saved session. An empty value means all namespaces.
--readonly Start in read-only mode.
--cluster Start on a cluster from the settings file. See Named clusters.
--version Print the version and exit.

Example:

urga --address https://nomad.example.com:4646 --region eu --namespace production

Read-only mode

With --readonly, urga does not change anything in the cluster. It hides every key that would: start and stop a job, revert, edit, scale, restart or stop an allocation, restart or signal a task, drain a client, change its eligibility, promote or fail a deployment, open a shell and run a command in a task. If you press one of these keys, the status line says that it is off. The header shows read-only next to the address.

The shell and the command are off in read-only mode because a command in a task can change anything the task can.

Token

The right end of the status line shows the ACL token urga sends. The Token: label has the color of the labels in the header; the value after it has a color that shows how long the token has left:

Status line Meaning
Token: deploy-bot, the name in green The token does not expire, or expires in more than 30 days.
Token: deploy-bot, the name in yellow It expires in 14 to 30 days.
Token: deploy-bot, the name in orange It expires in 5 to 14 days.
Token: expires in 4 days in red It expires in less than 5 days. Under a day, in hours, then minutes.
Token: expired in red It has expired.
Token: not valid in red The cluster does not accept the token: it is wrong, deleted or expired.
Token: anonymous in grey No token is set. The cluster answers with what anonymous access allows.

A token without a name shows the first 8 characters of its accessor ID, like Token: 3fa85f64. The empty-list and permission-denied lines below name it the same way.

On a cluster without ACLs there is no token, and the status line shows nothing about it.

A token that may read only some namespaces gets an empty list for the others, without an error. So when a list is empty and the token is not a management token, urga adds a grey line under the column titles:

  • Nothing here that deploy-bot can read: its policies may not allow it.
  • Nothing here: no token is set, and anonymous access may not allow it.

When the cluster refuses a request with 403 Permission denied, the status line says which token it refused: Permission denied: deploy-bot may not do this, Permission denied: no token is set or Permission denied: the token is not valid. For a management token, urga shows the reason the cluster gave.

Any error of the cluster shows as the cluster wrote it, without the response code around it: job not found, not Unexpected response code: 404 (job not found).

The token goes with every request. Over plain HTTP, anyone on the network between you and the cluster can read it. So when a token is set and the address starts with http:// and is not this machine (localhost, 127.0.0.0/8 or ::1), the status line warns once the cluster first answers, and again after each switch of cluster:

! the token goes to http://nomad.example:4646 without TLS

The warning does not replace an error, another warning or a command that is still running: it shows with a later answer. To stop it, use an https:// address.

Newer releases

When a newer release of urga is out, the header says so next to the version:

Urga Rev:  v0.5.0 ↑ v0.5.1

urga asks GitHub for the latest release when it starts, and then once a day while it runs. The request goes to api.github.com and says nothing about your cluster. If GitHub cannot be reached within 3 seconds, urga shows nothing and asks again the next day.

:about shows the version of urga, the commit it was built from and when, and whether a newer release is out. With a newer release, it says how to update: brew upgrade ingvarch/tap/urga for a copy installed with Homebrew, the release page for the rest. Below, it lists what changed: with a newer release, every release since yours, the newest first; without one, what came with yours. Changes are grouped by the type of their title: feat under ADDED, fix under FIXED, the rest under OTHER. urga reads the notes of the last 30 releases, once each time the screen opens.

A build from source, such as dev or v0.5.0-3-gabc1234, does not ask.

To turn the check off, set URGA_NO_UPDATE_CHECK to any value:

export URGA_NO_UPDATE_CHECK=1

Editor

urga opens jobs, namespaces, variables and client metadata in the editor set in $VISUAL. If $VISUAL is not set, it uses $EDITOR. When you save and close the editor, urga sends the change to the cluster. A job is planned first, see Editing a job. A variable is saved with check-and-set, see Editing a variable.

If you close the editor without a change, nothing is sent.

The editor opens a file in a directory urga makes for its run, urga-<number> in the system temp directory ($TMPDIR, or %TMP% on Windows). The file is deleted when the editor closes. The directory is deleted when urga exits, with what is left in it, also when the terminal is closed with the editor open: the file can hold a variable's values or other secrets. If urga is killed with SIGKILL, the directory stays.

If the cluster refuses the change, for example because of a syntax error or because the token may not make it, urga opens the editor again with your edit and the reason at the top, as comment lines:

# Not saved: the namespace is not valid JSON: unexpected end of JSON input.
# To save, change the file: delete these lines at least.
# To drop your edit, quit without saving.

Fix the file and save it to send it again. urga takes these lines off before it sends the file, so they do not break JSON and do not end up in a job. Because a file that comes back unchanged is not sent, saving it again takes a change: at least delete these lines. To drop your edit, close the editor without saving.

If you leave the screen, or switch clusters, before the cluster answers, urga does not open the editor again. The status line names a file that keeps your text instead. The file is in the system temp directory ($TMPDIR, or %TMP% on Windows) and is named urga-<number> with the extension of your edit, for example urga-1234567890.hcl. urga does not delete it. For a variable, the file holds its values: delete it once you have used it.

How urga stays up to date

Most screens, such as jobs, allocations and clients, follow the Nomad event stream: urga reloads the screen when something on it changes. Most lists are read once when they open: the stream starts after that read, and a change the list already shows does not reload it. A few lists, such as scaling policies and volumes, can reload once more when they open. So can the overview, when one of its lists is slow to answer. A screen of one object, such as a job, an allocation or a deployment, follows only that object. A client or a volume screen also follows every allocation, since Nomad does not mark an allocation event with its client or volume: it can reload once more when it opens, when another allocation changed after the client or the volume did. A screen that follows the stream also reloads every 30 seconds in case an event is missed. Screens that the event stream does not cover, such as namespaces and servers, reload every 2 seconds. Volumes and CSI plugins follow the stream on Nomad 1.10 and later, variables on Nomad 2.0 and later and on Nomad Enterprise 1.11.4 and later. On an older cluster, or when urga cannot read the version of the cluster, they are read every 2 seconds.

The client list and the screen of a client also follow the allocations of every namespace, so a client that fills up shows as full at once, and the allocations on a client show as they change. That needs a token that may read the jobs of every namespace. When the cluster refuses that stream, or ends it within 5 seconds with no event, which is how Nomad 2.0 refuses it, both follow the clients alone, with no warning. The screen of a client then reads its allocations every 30 seconds and whenever the client changes.

If the event stream is not available, which usually means the ACL token does not allow it, urga reloads every screen every 2 seconds instead. The status line says so.

urga also follows the allocations, deployments and clients of every namespace. When an allocation fails, a deployment fails or a client goes down, the status line says so for a few seconds, for example ! allocation web.frontend[0] failed in namespace production. Each one shows once; when several fail at once it names the newest. Only failures that happen after urga connects show, not the ones the cluster still remembers. A namespace created after urga connected is followed once the stream opens again, after a drop or a switch of cluster or region. The line does not replace an error, a warning about something else, or a command that is still running. It needs a token that can read jobs in every namespace and read clients. With any other token, or when the cluster does not send the stream, there is no line and no warning, and urga does not ask again until you switch cluster or region. The same goes for any other answer the cluster sends in place of the stream, an error included, and for a stream that ends within 5 seconds with no event, which is how Nomad 2.0 refuses it. If the stream stops after that, urga follows it again 30 seconds later, from where it stopped. If the cluster cannot be reached, when urga connects or after the stream stops, urga tries again every 30 seconds. It does the same when the cluster answers No cluster leader, as it does while its servers start, and when a proxy in front of the cluster answers 502, 503 or 504: the cluster behind it did not answer.

CPU Alloc and MEM Alloc in the header are how much of the cluster the running allocations asked for, out of what the ready clients give to jobs. They are not what the machines use. They are updated every 15 seconds. When a reading fails, the header keeps the last numbers, the status line says why once, and urga reads again 15 seconds later. Tasks of an allocation that do not run at the same time are not added up: like the scheduler, urga takes the largest of the prestart, main and poststop tasks, counts prestart sidecars with both the prestart and the main tasks, and poststart tasks with the main ones. CPU and memory of allocations and clients in a list are what they use, updated every 5 seconds.

Saved session

urga saves where you were and restores it on the next run:

  • the namespace;
  • the last list screen, such as jobs, clients or the overview;
  • which namespace each number key opens.

The session is saved to urga/config.json in:

  • $XDG_CONFIG_HOME, if it is set;
  • otherwise ~/.config on Linux, ~/Library/Application Support on macOS and %AppData% on Windows.

urga writes this file itself. You do not need to edit it.

On start, urga picks the namespace in this order: --namespace, the saved session, NOMAD_NAMESPACE, all namespaces. NOMAD_NAMESPACE comes after the saved session because it is set for every run, not chosen for this one.

With named clusters, each cluster has its own session in the same file.