Closed gchamon closed 1 year ago
I've tested this, some things that may not be perfect:
Ok, the rebase is done, I manually changed the permissions on the folder and tested and the rest works perfectly, so just check the othe points and it will be perfect.
Many thanks for all the contributions!
* On the example on the .md, we could keep a smaller docker-compose.yml example, with the minimum required, and the complete one, with the exporter, to avoid confusion. * The friendly_json is also being created in the clients .conf files, this is not needed for the exporter. * The permissions on the ./subspace-data/ gave me a lot of problems, the exporter wouldn´t lauch, the docker-compose wouldn´t restart, etc.
I wonder if maybe setting the volume map on the exporter for read only would preserve the original permissions from subspace
@agonbar I tested with read only permissions for the exporter and had zero issues. Here is my complete docker-compose.yml
file:
version: "3.3"
services:
subspace:
image: subspace-local
build: ./subspace
container_name: subspace
volumes:
- ./subspace-data:/data
- ./dnsmasq.d:/etc/dnsmasq.d
restart: always
environment:
- SUBSPACE_HTTP_HOST=192.168.0.4
- SUBSPACE_LETSENCRYPT=false
- SUBSPACE_HTTP_INSECURE=true
- SUBSPACE_HTTP_ADDR=":80"
- SUBSPACE_NAMESERVERS=1.1.1.1,8.8.8.8
- SUBSPACE_LISTENPORT=51820
- SUBSPACE_IPV4_POOL=10.99.97.0/24
- SUBSPACE_IPV6_POOL=fd00::10:97:0/64
- SUBSPACE_DISABLE_DNS=0
- SUBSPACE_IPV6_NAT_ENABLED=1
cap_add:
- NET_ADMIN
network_mode: "host"
prometheus_exporter:
image: mindflavor/prometheus-wireguard-exporter
container_name: prometheus_exporter
volumes:
- ./subspace-data:/data:ro
restart: always
cap_add:
- NET_ADMIN
network_mode: "host"
command: "-a -n /data/wireguard/server.conf"
Can you help me replicate your issue?
EDIT: I think I understand now. You mean to make it so that the entrypoint deals with the permission issues on the data folder? I could do that easily, if my understanding is correct.
Also, regarding the readme. I am not sure what I am supposed to change. Should I make the example with the prometheus exporter shorter? Or is it the other way around?
@agonbar another thing that came to mind. If you are upgrading a running subspace server, newer client configs will be populated with the friendly_json
field, but older ones will lack it. We should think of a routine to migrate older configs to newer configs.
However, this behaviour is not exclusive to this PR. Any changes made to the server configs (like IPV6, DNS and so on) will not reflect in the already created client configs.
I think this warrants an issue of its own and shouldn't impact this feature. Do you also share this POV?
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
1 Code Smell
No Coverage information
0.0% Duplication
Fixed a problem with updating from a long running subspace service. Updating would cause server.conf to be recreated after the wg0 interface is set during startup, causing any peers created before updating to be missed.
To circumvent it, I added the method Sync to the WireguardServerConfig struct that calls wg syncconf
with the updated server.conf. This will effectively delegate both the recreation of the wireguard config and refresh of the wg0 interface to subspace.
to: @subspacecommunity/subspace-maintainers cc: @subspacecommunity/subspace-maintainers related to: resolves: https://github.com/subspacecommunity/subspace/issues/139
Background
Prometheus wireguard exporter allows for friendly names to be exported along with wireguard specific info. This pull request aims to support the comment that enables the exporter to do that, thus making monitoring subspace with Prometheus easier for SecOps teams.
Changes
# friendly_json
tag to both client and peer configsserver.conf
generation fromentrypoint.sh
to both routes/profile/add
and/profile/delete
MutexBash
that allows for synchronized bash executionserver.conf
generation is hidden behindServerConfig
struct, that usesMutexBash
to update the server configuration synchronouslydocker-compose
example that enables the prometheus exporterTesting
docker-compose.yml
docker-compose build
docker-compose up
http://localhost
cat ./subspace-data/wireguard/server.conf
. The config file should be update as soon as you create a profile. It should also contain thefriendly_json
tag with the correct valuesuser_type
is correctly set toclient
curl http://localhost:9586/metrics
should display prometheus metrics with the correct key=value pairs fromfriendly_json
Next steps