This document discusses Nomad packs, which are a templating and packaging tool for easily deploying popular applications to Nomad. Key points include:
- Nomad packs use HashiCorp Configuration Language (HCL) templates and Go template syntax to define jobs.
- Pack structure includes templates, variables, metadata, and output files. Common patterns can be abstracted and reused across packs.
- Packs can be run via the nomad-pack CLI and support variables, registries for finding packs, and CI/CD workflows.
- The author discusses ideas for the future including pre-commit hooks, locals support, meta packages, and dependency health checks.
1. 10 things i learned building
Nomad packs
Bram Vogelaar
@attachmentgenie
2. Confidential and Proprietary
~ ❯ whoami => Bram Vogelaar
• Used to be a Molecular Biologist
• Then became a Dev, now an Ops
• Currently Cloud Engineer @ The Factory
• Amsterdam HUG organizer
3. Confidential and Proprietary
Nomad
• Open-source tool for dynamic workload scheduling
• Batch, containerized, and non-containerized applications.
• Has native Consul and Vault integrations.
• Has token based access setup.
• Jobs written in (H)ashiCorp (C)onfiguration (L)anguage
https://www.nomadproject.io/
4. Confidential and Proprietary
Nomad Job Structure
job "lorem-ipsum" {
group ”frontend" {
network {
port "http" { to = ”3000” }
}
service {
name = ”lorem"
port. = ”http"
}
task "server" {
driver = "docker"
config {
image = ”cicero/lorem-ipsum:v1.0.0"
ports = ["http"]
}
}
}
5. Confidential and Proprietary
Surprisingly Dynamic
job "lorem-ipsum" {
group ”frontend" {
network {
port "http" { to = ”3000” }
}
service {
name = ”lorem"
port. = ”http"
}
task "server" {
driver = "docker"
config {
image = ”cicero/lorem-ipsum:v1.0.0"
ports = ["http"]
}
}
}
6. Confidential and Proprietary
Incredibly Dynamic
● Data Centers
● Region
● Namespace
● Constraints
● Count
● Restart Configuration
● Network
● Volumes
● Service Checks
● Consul Connect
● Resource Limits
● Artifacts
● Templates
● Autoscaler Configuration
8. Confidential and Proprietary
Nomad Pack
• Templating and Packaging tool
• Easily deploy popular applications to Nomad
• Re-use common patterns across internal applications
• Find and share job definitions with the Nomad community
• Jobs written in (H)ashiCorp (C)onfiguration (L)anguage
• Templates are written using Go Template Syntax.
• Nightlies only right now!
https://github.com/hashicorp/nomad-pack
9. Confidential and Proprietary
Pack Registries
$ nomad-pack registry list
$ nomad-pack registry add o11y https://github.com/attachmentgenie/nomad-pack-o11y-registry
$ nomad-pack run grafana --var job_name=dashboard --registry=o11y
$ nomad-pack run packs/grafana -f vars/grafana.hcl –f vars/lab.hcl
https://github.com/hashicorp/nomad-pack-o11y-registry
10. Confidential and Proprietary
Default Registry
$ nomad-pack registry list
PACK NAME | REF | METADATA VERSION | REGISTRY | REGISTRY URL
-----------------------------+--------+------------------+-----------------+-----------------------------
alertmanager | latest | 0.0.1 | default | github.com/hashicorp
aws_efs_csi | latest | 0.0.1 | default | github.com/hashicorp
mkdir –p $HOME/.nomad/packs/default on offline systems!
12. Confidential and Proprietary
metadata.hcl
app {
url = "https://grafana.com/"
author = "Grafana Labs"
}
pack {
name = "grafana"
description = "Grafana is a multi-platform open source analytics and interactive visualization tool."
url = "https://github.com/attachmentgenie/nomad-pack-o11y-registry/grafana"
version = "0.1.0"
}
13. Confidential and Proprietary
variables.hcl
variable "datacenters" {
description = "A list of datacenters in the region which are eligible for task placement"
type = list(string)
default = [“dc1”]
}
Variable “resources” {
description = “The resource to assign to the Grafana service task”
type = object({
cpu = number
memory = number
})
default = {
cpu = 200,
memory = 256
}
}