netbird/management/README.md

115 lines
4.5 KiB
Markdown
Raw Permalink Normal View History

# netbird Management Server
netbird management server will control and synchronize peers configuration within your Netbird account and network.
2021-07-20 18:09:26 +02:00
## Command Options
The CLI accepts the command **management** with the following options:
```shell
start Netbird Management Server
Usage:
netbird-mgmt management [flags]
Flags:
2022-05-22 18:53:47 +02:00
--cert-file string Location of your SSL certificate. Can be used when you have an existing certificate and don't want a new certificate be generated automatically. If letsencrypt-domain is specified this property has no effect
--cert-key string Location of your SSL certificate private key. Can be used when you have an existing certificate and don't want a new certificate be generated automatically. If letsencrypt-domain is specified this property has no effect
--datadir string server data directory location
-h, --help help for management
--letsencrypt-domain string a domain to issue Let's Encrypt certificate for. Enables TLS using Let's Encrypt. Will fetch and renew certificate, and run the server with TLS
--port int server port to listen on (default 33073)
2022-05-22 18:53:47 +02:00
Global Flags:
2022-05-22 18:53:47 +02:00
--config string Netbird config file location to write new config to (default "/etc/netbird")
--log-file string sets Netbird log path. If console is specified the the log will be output to stdout (default "/var/log/netbird/management.log")
2022-05-22 18:53:47 +02:00
--log-level string (default "info")
```
2021-07-22 12:32:04 +02:00
## Run Management service (Docker)
You can run service in 2 modes - with TLS or without (not recommended).
### Run with TLS (Let's Encrypt).
By specifying the **--letsencrypt-domain** the daemon will handle SSL certificate request and configuration.
2021-07-22 12:32:04 +02:00
In the following example ```33073``` is the management service **default** port, and ```443``` will be used as port for Let's Encrypt challenge and HTTP API.
> The server where you are running a container has to have a public IP (for Let's Encrypt certificate challenge).
2021-07-22 12:32:04 +02:00
Replace <YOUR-DOMAIN> with your server's public domain (e.g. mydomain.com or subdomain sub.mydomain.com).
```bash
# create a volume
docker volume create netbird-mgmt
# run the docker container
docker run -d --name netbird-management \
2021-07-22 12:32:04 +02:00
-p 33073:33073 \
-p 443:443 \
-v netbird-mgmt:/var/lib/netbird \
-v ./config.json:/etc/netbird/config.json \
2022-05-22 18:53:47 +02:00
netbirdio/management:latest \
--letsencrypt-domain <YOUR-DOMAIN>
2021-07-22 12:32:04 +02:00
```
> An example of config.json can be found here [management.json](../infrastructure_files/management.json.tmpl)
2021-07-22 12:32:04 +02:00
Trigger Let's encrypt certificate generation:
```bash
curl https://<YOUR-DOMAIN>
```
The certificate will be persisted in the ```datadir/letsencrypt/``` folder (e.g. ```/var/lib/netbird/letsencrypt/```) inside the container.
Make sure that the ```datadir``` is mapped to some folder on a host machine. In case you used the volume command, you can run the following to retrieve the Mountpoint:
```shell
docker volume inspect netbird-mgmt
[
{
"CreatedAt": "2021-07-25T20:45:28Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/mgmt/_data",
"Name": "netbird-mgmt",
"Options": {},
"Scope": "local"
}
]
2021-07-22 12:32:04 +02:00
```
Consequent restarts of the container will pick up previously generated certificate so there is no need to trigger certificate generation with the ```curl``` command on every restart.
2021-07-22 12:32:04 +02:00
### Run without TLS.
```bash
# create a volume
docker volume create netbird-mgmt
# run the docker container
docker run -d --name netbird-management \
2021-07-22 12:32:04 +02:00
-p 33073:33073 \
-v netbird-mgmt:/var/lib/netbird \
-v ./config.json:/etc/netbird/config.json \
2022-05-22 18:53:47 +02:00
netbirdio/management:latest
2021-07-22 12:32:04 +02:00
```
### Debug tag
We also publish a docker image with the debug tag which has the log-level set to default, plus it uses the ```gcr.io/distroless/base:debug``` image that can be used with docker exec in order to run some commands in the Management container.
```shell
shell $ docker run -d --name netbird-management-debug \
-p 33073:33073 \
-v netbird-mgmt:/var/lib/netbird \
-v ./config.json:/etc/netbird/config.json \
2022-05-22 18:53:47 +02:00
netbirdio/management:debug-latest
2021-07-22 12:32:04 +02:00
shell $ docker exec -ti netbird-management-debug /bin/sh
container-shell $
```
2021-07-22 12:32:04 +02:00
## For development purposes:
2021-07-20 18:09:26 +02:00
Install golang gRpc tools:
```bash
#!/bin/bash
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
```
2021-07-22 12:32:04 +02:00
Generate gRpc code:
2021-07-20 18:09:26 +02:00
```bash
#!/bin/bash
protoc -I proto/ proto/management.proto --go_out=. --go-grpc_out=.
```
2021-07-22 12:32:04 +02:00