Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document CetusGuard as a Docker socket proxy solution #14806

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions collectors/cgroups.plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ container names. To do this, ensure `podman system service` is running and Netda
to `/run/podman/podman.sock` (the default permissions as specified by upstream are `0600`, with owner `root`, so you
will have to adjust the configuration).

[docker-socket-proxy](https://github.com/Tecnativa/docker-socket-proxy) can also be used to give Netdata restricted
access to the socket. Note that `PODMAN_HOST` in Netdata's environment should be set to the proxy's URL in this case.
[Docker Socket Proxy (HAProxy)](https://github.com/Tecnativa/docker-socket-proxy) or [CetusGuard](https://github.com/hectorm/cetusguard)
can also be used to give Netdata restricted access to the socket. Note that `PODMAN_HOST` in Netdata's environment should
be set to the proxy's URL in this case.

### Charts with zero metrics

Expand Down
41 changes: 34 additions & 7 deletions packaging/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,17 @@ your machine from within the container. Please read the following carefully.
#### Docker socket proxy (safest option)

Deploy a Docker socket proxy that accepts and filters out requests using something like
[HAProxy](https://github.com/netdata/netdata/blob/master/docs/Running-behind-haproxy.md) so that it restricts connections to read-only access to the CONTAINERS
[HAProxy](https://github.com/netdata/netdata/blob/master/docs/Running-behind-haproxy.md) or
[CetusGuard](https://github.com/hectorm/cetusguard) so that it restricts connections to read-only access to the `/containers`
endpoint.

The reason it's safer to expose the socket to the proxy is because Netdata has a TCP port exposed outside the Docker
network. Access to the proxy container is limited to only within the network.

Below is [an example repository (and image)](https://github.com/Tecnativa/docker-socket-proxy) that provides a proxy to
the socket.
Here are two examples, the first using [a Docker image based on HAProxy](https://github.com/Tecnativa/docker-socket-proxy)
and the second using [CetusGuard](https://github.com/hectorm/cetusguard).

You run the Docker Socket Proxy in its own Docker Compose file and leave it on a private network that you can add to
other services that require access.
##### Docker Socket Proxy (HAProxy)

```yaml
version: '3'
Expand All @@ -356,13 +356,40 @@ services:
proxy:
image: tecnativa/docker-socket-proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
- CONTAINERS=1

```
**Note:** Replace `2375` with the port of your proxy.

##### CetusGuard

```yaml
version: '3'
services:
netdata:
image: netdata/netdata
# ... rest of your config ...
ports:
- 19999:19999
environment:
- DOCKER_HOST=cetusguard:2375
cetusguard:
image: hectorm/cetusguard:v1
read_only: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
CETUSGUARD_BACKEND_ADDR: unix:///var/run/docker.sock
CETUSGUARD_FRONTEND_ADDR: tcp://:2375
CETUSGUARD_RULES: |
! Inspect a container
GET %API_PREFIX_CONTAINERS%/%CONTAINER_ID_OR_NAME%/json
```

You can run the socket proxy in its own Docker Compose file and leave it on a private network that you can add to
other services that require access.

#### Giving group access to the Docker socket (less safe)

> :warning: Caution
Expand Down