DEV Community

M
M

Posted on

2

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.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay