amir20 / dozzle

Realtime log viewer for docker containers.
https://dozzle.dev/
MIT License
5.02k stars 266 forks source link

feat!: implements swarm mode with agents #3058

Closed amir20 closed 1 week ago

amir20 commented 3 weeks ago

This pull request introduces a significant change in design by implementing Dozzle agents. Dozzle agents communicate with each other over a secured RPC. Only Dozzle agents can talk to each other. This is achieved by using pinned certificates.

There are two use cases for agents. The first one is to support Dozzle in Swarm mode without much configuraiton. The second use case is to replace remote hosts.

Dozzle in Swarm Mode

In Swarm mode, Dozzle creates connection to a cluster of agents running together. In this mode, all logs are streamed to the UI. There isn't much configuration needed except DOZZLE_MODE=swarm.

services:
  dozzle:
    image: amir20/dozzle:pr-3058
    environment:
      - DOZZLE_MODE=swarm
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "8080:8080"
    networks:
      - dozzle
    deploy:
      mode: global

networks:
  dozzle:
    driver: overlay

Note amir20/dozzle:pr-3058 is required to point to this PR.

You can see agents working together by doing docker service logs -f <service_name>.

Setting up remote host

For remote host, it works similar to swarm mode except that the agent's endpoints need to be configured.

To start an agent, you need to run docker run --volume=/var/run/docker.sock:/var/run/docker.sock -p 7007:7007 amir20/dozzle:pr-3058 agent. This will start an agent and starting listening to port 7007.

Then you can start Dozzle as usual docker run -p 8081:8080 amir20/dozzle:pr-3058 --remote-agent [ip]:7007.

This PR is still in development. Any testing would be appreciated.

See #3052 for more details.

Still to do:

githubbiswb commented 2 weeks ago

Looks good to me, and works very well. A much simpler config and less images, always a plus

Keep up the great work!

devioa commented 1 week ago

docker build error

 => ERROR [builder 10/14] COPY shared_key.pem shared_cert.pem ./                                                 0.0s
------
 > [builder 10/14] COPY shared_key.pem shared_cert.pem ./:
------
Dockerfile:49
--------------------
  47 |     COPY main.go ./
  48 |     COPY protos ./protos
  49 | >>> COPY shared_key.pem shared_cert.pem ./
  50 |
  51 |     # Copy assets built with node
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref e1af3785-ab55-4be1-9acc-2344d09c5acf::k0alhi681gfc2txlmd9df3jeq: "/shared_key.pem": not found

Do I need to generate this certificate myself?

amir20 commented 1 week ago

Yep. make generate will create them. Official releases have private keys that are secret.

Use make docker to build.

devioa commented 1 week ago

Yep. make generate will create them. Official releases have private keys that are secret.

Use make docker to build.

Thanks