Nomad

From Leo's Notes
Revision as of 00:26, 16 February 2021 by Leo (talk | contribs) (→Cheat sheet)
This page was last edited on 16 February 2021, at 00:26.

HasiCorp Nomad

Cheat sheet

Allocations are like pods, it contains one or more 'tasks'

Tasks are just containers

Job files contain all the information about the deployment.

Task Command
Start an agent nomad agent -dev -bind 0.0.0.0 -log-level INFO
Show node status nomad node status
Show connected members nomad server members
Create an example job nomad job init
Run a job nomad job run example.nomad
Show a job's status nomad job status example
Examine an allocation nomad alloc status allocation-id
Examine an allocation's logs nomad alloc logs allocation-id task-name


Other

Consul integration

Start consul: consul agent -dev

Nomad appears to just detect this automatically, like magic.

NFS Persistent Volumes

  • How do I get a container with a persistent volume via NFS?

Traefik load balancing

Configure Traefik with the consulCatalog provider in the traefik.toml configuration file:

# Enable Consul Catalog configuration backend.
[providers.consulCatalog]
    prefix           = "traefik"
    exposedByDefault = false

    [providers.consulCatalog.endpoint]
      address = "127.0.0.1:8500"
      scheme  = "http"

When defining a service within a job in Nomad, specify the following tags:

service {
      name = "demo-webapp"
      port = "http"

      tags = [
        "traefik.enable=true",
        "traefik.http.routers.http.rule=Path(`/myapp`)",
      ]

Traefik will then be notified of the new backends when changes to this service happens via Consul.

Open Questions

  • Can we have the load balancing Traefik instance be an external service? If so, how?