BigBoot / AutoKuma

AutoKuma is a utility that automates the creation of Uptime Kuma monitors based on Docker container labels. With AutoKuma, you can eliminate the need for manual monitor creation in the Uptime Kuma UI.
MIT License
309 stars 15 forks source link

Multiple docker sockets? #62

Closed andyloree closed 3 months ago

andyloree commented 3 months ago

Would it be possible to add support for multiple, remote docker hosts? Instead of having to create static files, ability to support multiple docker instances via something like docker-socket-proxy would allow for a non-swarm, stand-alone docker hosts configured via labels. Homepage does this today with labels approach, via a single config file, adding entries for each docker socket: https://gethomepage.dev/v0.8.0/configs/docker/#using-docker-socket-proxy

BigBoot commented 3 months ago

AUTOKUMA__DOCKER__HOSTS="tcp://host_1:2375;tcp://host_2:2375" should work.

Also make sure you're on the master tag and have pulled the latest image (or use ghcr.io/bigboot/autokuma:sha-11b6c5d) for the specific build.

andyloree commented 3 months ago

Thanks, mistakenly thought latest was getting tagged as the build :)

I got the latest running, but now having an issue with it not liking "tcp://" hosts, it keeps prepending "unix://" schema

# export AUTOKUMA__DOCKER__HOSTS="tcp://apps.[redacted]:2375"
# autokuma
...
WARN [kuma_client::util] Using DOCKER_HOST=unix://tcp://apps.[redacted].com:2375
WARN [autokuma::sync] Encountered error during sync: Error in the hyper legacy client: client error (Connect)

Seems like no matter what is in the env value, its putting unix:// schema on it. I tried a few different variations but no luck.

Looks like code at issue is here, hard-coded to prepend unix://

image

arhue commented 3 months ago

Hi,

I'm facing exact same issue and it's quite a coincidence that you were working on this at the same time. I have created PR here to fix this: https://github.com/BigBoot/AutoKuma/pull/64. I'm not a programmer and have not written Rust before. Please review/test before merging.

My Docker Swarm config file:

services:
  docker_host:
    image: ghcr.io/tecnativa/docker-socket-proxy:latest
    ports:
      - target: 2375
        published: 2375
        protocol: tcp
        mode: host
    environment:
      CONTAINERS: 1
      SERVICES: 1
      TASKS: 1
      POST: 0
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    deploy:
      mode: global
  autokuma:
    image: ghcr.io/bigboot/autokuma:sha-11b6c5d
    environment:
      AUTOKUMA__KUMA__URL: https://status.transnomis.com
      AUTOKUMA__DOCKER__SOURCE: Both
      AUTOKUMA__DOCKER__HOSTS: "tcp://qa-docker-1.transnomis.com:2375;tcp://qa-docker-3.transnomis.com:2375;tcp://qa-docker-4.transnomis.com:2375;tcp://qa-docker-5.transnomis.com:2375;tcp://qa-docker-6.transnomis.com:2375"
    deploy:
      replicas: 1
  uptimekuma:
    image: louislam/uptime-kuma:1.23.13
    volumes:
      - uptimekuma_data:/app/data
    networks:
      - uptimekuma
      - caddy
    deploy:
      replicas: 1
      placement:
        constraints: [node.hostname == qa-docker-1]
      labels:
        caddy: status.transnomis.com
        caddy.reverse_proxy: "{{ upstreams 3001 }}"
        caddy.tls: "simon@transnomis.com"
        caddy.tls.dns: "godaddy {env.GODADDY_TOKEN}"
networks:
  caddy:
    external: true
  uptimekuma:
    driver: overlay
    attachable: true

volumes:
  uptimekuma_data:

I get the following error:

uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [kuma_client::util] Using DOCKER_HOST=unix://tcp://qa-docker-1.transnomis.com:2375
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [autokuma::sync] Encountered error during sync: Error in the hyper legacy client: client error (Connect)
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [kuma_client::util] Using DOCKER_HOST=unix://tcp://qa-docker-1.transnomis.com:2375
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [autokuma::sync] Encountered error during sync: Error in the hyper legacy client: client error (Connect)
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [kuma_client::util] Using DOCKER_HOST=unix://tcp://qa-docker-1.transnomis.com:2375
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [autokuma::sync] Encountered error during sync: Error in the hyper legacy client: client error (Connect)
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [kuma_client::util] Using DOCKER_HOST=unix://tcp://qa-docker-1.transnomis.com:2375
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [autokuma::sync] Encountered error during sync: Error in the hyper legacy client: client error (Connect)
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [kuma_client::util] Using DOCKER_HOST=unix://tcp://qa-docker-1.transnomis.com:2375
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [autokuma::sync] Encountered error during sync: Error in the hyper legacy client: client error (Connect)
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [kuma_client::util] Using DOCKER_HOST=unix://tcp://qa-docker-1.transnomis.com:2375
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [autokuma::sync] Encountered error during sync: Error in the hyper legacy client: client error (Connect)
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [kuma_client::util] Using DOCKER_HOST=unix://tcp://qa-docker-1.transnomis.com:2375
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [autokuma::sync] Encountered error during sync: Error in the hyper legacy client: client error (Connect)
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [kuma_client::util] Using DOCKER_HOST=unix://tcp://qa-docker-1.transnomis.com:2375
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [autokuma::sync] Encountered error during sync: Error in the hyper legacy client: client error (Connect)
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [kuma_client::util] Using DOCKER_HOST=unix://tcp://qa-docker-1.transnomis.com:2375
uptimekuma_autokuma.1.8zmgere8fstc@qa-docker-4    | WARN [autokuma::sync] Encountered error during sync: Error in the hyper legacy client: client error (Connect)
arhue commented 3 months ago

@andyloree Commit from master now fixed the issue for me.