Nomad: Difference between revisions

From Leo's Notes
This page was last edited on 16 February 2021, at 00:26.
Initial Content
 
Line 1: Line 1:
HasiCorp Nomad
HasiCorp Nomad


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


Line 9: Line 9:
<br />
<br />
{| class="wikitable"
{| class="wikitable"
!
!Task
!
!Command
|-
|-
|Start an agent
|Start an agent
Line 35: Line 35:
|Examine an allocation's logs
|Examine an allocation's logs
|<code>nomad alloc logs allocation-id task-name</code>
|<code>nomad alloc logs allocation-id task-name</code>
|}
|}<br />
==Other==


== Other ==
===Consul integration===
 
=== Consul integration ===
Start consul: <code>consul agent -dev</code>
Start consul: <code>consul agent -dev</code>


Nomad appears to just detect this automatically, like magic.
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 <code>consulCatalog</code> provider in the <code>traefik.toml</code> configuration file:
{{Highlight
| code = # Enable Consul Catalog configuration backend.
[providers.consulCatalog]
    prefix          = "traefik"
    exposedByDefault = false
    [providers.consulCatalog.endpoint]
      address = "127.0.0.1:8500"
      scheme  = "http"
| lang = text
}}
When defining a service within a job in Nomad, specify the following tags:
{{Highlight
| code = service {
      name = "demo-webapp"
      port = "http"
      tags = [
        "traefik.enable=true",
        "traefik.http.routers.http.rule=Path(`/myapp`)",
      ]
| lang = text
}}
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?

Revision as of 00:26, 16 February 2021

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?