Skip to content

Instantly share code, notes, and snippets.

@ml4
Created August 1, 2023 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ml4/8ee3854b9d5618f3e97048c309565a55 to your computer and use it in GitHub Desktop.
Save ml4/8ee3854b9d5618f3e97048c309565a55 to your computer and use it in GitHub Desktop.
## cadvisor
#
variable "dh_uid" {
type = string
default = "mydh"
}
#
## pwd needs to be _read -sp_'d into the user's env before the job is run:
## read -sp '> ' NOMAD_VAR_dh_pwd && export NOMAD_VAR_dh_pwd=${NOMAD_VAR_dh_pwd}
#
variable "dh_pwd" {
type = string
}
## cadvisor container deployment - funnel to prometheus
#
job "cadvisor" {
name = "cadvisor" # default would be above job ID
priority = 50 # default
region = "global" # default
datacenters = ["*"] # default
meta {
info = "Runs cadvisor to harvest container metrics"
}
group "cadvisor" {
count = 1
network {
port "http" { to = 8080 }
}
task "cadvisor" {
driver = "docker"
config {
init = false
image = "${var.dh_uid}/my-cadvisor:latest"
image_pull_timeout = "3m"
auth {
username = var.dh_uid
password = var.dh_pwd
}
privileged = true
ports = ["http"]
## from
## https://github.com/google/cadvisor#quick-start-running-cadvisor-in-a-docker-container
#
mount {
type = "volume"
source = "/"
target = "/rootfs"
readonly = true
}
mount {
type = "volume"
source = "/var/run"
target = "/var/run"
// readonly = false
readonly = true
}
mount {
type = "volume"
source = "/sys"
target = "/sys"
readonly = true
}
mount {
type = "volume"
source = "/var/lib/docker"
target = "/var/lib/docker"
readonly = true
}
mount {
type = "volume"
source = "/dev/disk"
target = "/dev/disk"
readonly = true
}
devices = [
{
host_path = "/dev/kmsg"
container_path = "/dev/kmsg"
}
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment