DEV Community

M
M

Posted on

tailscale and beszel on hashicorp nomad

hey,
i just want it to share with you what i found today: https://tailscale.com/blog/video-beszel

so i deciced to try it on hashicorp nomad and it works great!

here is jobs example:

beszel dashboard

variables {
  domain = "beszel.my.domain.tld"
}

job "beszel-dashboard" {
  datacenters = ["rpi"]

  group "beszel" {
    count = 1

    task "beszel-dashboard" {
      driver = "docker"

      config {
        image = "henrygd/beszel:latest"

        extra_hosts = [
          "host.docker.internal:host-gateway"
        ]
        volumes = [
          "/data/beszel:/beszel_data",
        ]
      }

      resources {
        cpu    = 500
        memory = 1024
      }

      service {
        name = "beszel-dashboard"
        provider     = "nomad"
        address_mode = "driver"
        port = "8090"
        tags = [
          "traefik.enable=true",
          "traefik.http.routers.http-${NOMAD_ALLOC_ID}.entrypoints=web",
          "traefik.http.routers.http-${NOMAD_ALLOC_ID}.rule=Host(`${var.domain}`)",
          "traefik.http.services.http-${NOMAD_ALLOC_ID}.loadbalancer.server.port=8090",
          # "traefik.http.services.https-${NOMAD_ALLOC_ID}.loadbalancer.server.port=8090",
          "traefik.http.routers.https-${NOMAD_ALLOC_ID}.rule=Host(`${var.domain}`)",
          "traefik.http.routers.https-${NOMAD_ALLOC_ID}.entrypoints=websecure",
          "traefik.http.routers.https-${NOMAD_ALLOC_ID}.tls.certresolver=le",
          "traefik.http.routers.https-${NOMAD_ALLOC_ID}.tls=true"
        ]
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

and system job for agents:

job "beszel-agent" {
  datacenters = ["*"]
  type        = "system"

  meta {
    version = "2"
  }


  group "beszel" {
    count = 1

    network {
      mode = "host"
      port "http" {
        host_network = "tailscale"
        static       = 45876
      }
    }

    task "beszel-agent" {
      driver = "docker"

      config {
        image        = "henrygd/beszel-agent:latest"
        volumes      = ["/var/run/docker.sock:/var/run/docker.sock:ro"]
        ports        = ["http"]
      }
      env {
        PORT = "45876"
        KEY  = "<your key from dashboard here>"
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

each new host gets its own agent on port, so you can add that IP to your beszel dashboard.

and thats it.

Top comments (0)