updated usage docs and install methods

This commit is contained in:
afeiszli 2021-04-20 08:34:58 -04:00
parent 7d333fc676
commit 2226f51f02
5 changed files with 154 additions and 36 deletions

View file

@ -27,5 +27,5 @@ COPY --from=builder /app/config config
EXPOSE 8081 EXPOSE 8081
EXPOSE 50051 EXPOSE 50051
CMD ["./app"] CMD ["./app", "--clientmode=off"]

View file

@ -16,7 +16,7 @@ services:
container_name: netmaker container_name: netmaker
depends_on: depends_on:
- mongodb - mongodb
image: gravitl/netmaker:v0.1-hotfix image: gravitl/netmaker:v0.2
ports: ports:
- "8081:8081" - "8081:8081"
- "50051:50051" - "50051:50051"
@ -27,7 +27,7 @@ services:
container_name: netmaker-ui container_name: netmaker-ui
depends_on: depends_on:
- netmaker - netmaker
image: gravitl/netmaker-ui:v0.1 image: gravitl/netmaker-ui:v0.2
ports: ports:
- "80:80" - "80:80"
environment: environment:

View file

@ -2,22 +2,6 @@
This guide covers advanced usage of Netmaker. If you are just looking to get started quickly, check out the Quick Start in the [README](../README.md). This guide covers advanced usage of Netmaker. If you are just looking to get started quickly, check out the Quick Start in the [README](../README.md).
## Index
- Config
- Server Config
- Agent Config
- UI Config
- Creating Your Network
- Creating Networks
- Creating Keys
- Creating Nodes
- Managing Your Network
- Cleaning up
- Non-Docker Installation
- Building
- Testing
## Server Config ## Server Config
Netmaker settings can be set via Environment Variables or Config file. There are also a couple of runtime arguments that can optionally be set. Netmaker settings can be set via Environment Variables or Config file. There are also a couple of runtime arguments that can optionally be set.
@ -63,26 +47,63 @@ Stored as config/environments/*.yaml. Default used is dev.yaml
**clientmode**: (default=on) E.x.: `sudo netmaker --clientmode=off` Run the Server as a client (node) as well. **clientmode**: (default=on) E.x.: `sudo netmaker --clientmode=off` Run the Server as a client (node) as well.
**defaultnet**: (default=on) E.x.: `sudo netmaker --defaultnet=off` Create a default network on startup. **defaultnet**: (default=on) E.x.: `sudo netmaker --defaultnet=off` Create a default network on startup.
### Running the Backend Components on Different Machines ## Client Config
HTTP, GRPC, MongoDB
### Non-Docker Installation Client config files are stored under /etc/netclient per network as /etc/netclient/netconfig-< network name >
**server:**
address: The address:port of the server
accesskey: The acceess key used to sign up with the server
**node:**
name: a displayname for the node, e.g. "mycomputer"
interface:
network: default
password: $2a$05$HqVV85kuDF5R3DS.sK5hSuYiaYFaszhGXHYy8mpIOhV7TesWOlKWG
macaddress: 12:cc:6f:f4:cb:a1
localaddress: 10.10.10.2
wgaddress: 10.10.10.2
roamingoff: false
islocal: false
allowedips: ""
localrange: ""
postup: iptables -A FORWARD -i nm-default -j ACCEPT; iptables -t nat -A POSTROUTING
-o nm-home -j MASQUERADE
postdown: iptables -D FORWARD -i nm-default -j ACCEPT; iptables -t nat -D POSTROUTING
-o nm-home -j MASQUERADE
port: 51821
keepalive: 20
publickey: WoXfPcBLGwbEVNnxOmS1dnMR+pzvoL5sg+6KuSjEN0M=
privatekey: ""
endpoint: 66.169.21.167
postchanges: "false"
network: ""
## Non-Docker Installation
### MongoDB Setup
1. Install MongoDB on your server. For Ubuntu: `sudo apt install -y mongodb`. For more advanced installation or other operating systems, see the [MongoDB documentation](https://docs.mongodb.com/manual/administration/install-community/).
2. Create a user:
`mongo admin`
`db.createUser({ user: "mongoadmin" , pwd: "mongopass", roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"]})`
### Server Setup ### Server Setup
1. Get yourself a linux server and make sure it has a public IP. 1. **Run the install script:** sudo curl -sfL https://raw.githubusercontent.com/gravitl/netmaker/v0.2/netmaker-server.sh | sh -
2. Deploy MongoDB `docker volume create mongovol && docker run -d --name mongodb -v mongovol:/data/db --network host -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=mongopass mongo --bind_ip 0.0.0.0 ` 2. Check status: `sudo journalctl -u netmaker`
3. Pull this repo: `git clone https://github.com/gravitl/netmaker.git` 2. If any settings are incorrect such as host or mongo credentials, change them under /etc/netmaker/config/environments/ENV.yaml and then run `sudo systemctl restart netmaker`
4. Switch to the directory and source the default env vars `cd netmaker && source defaultvars.sh`
5. Run the server: `go run ./`
### Optional (For Testing): Create Networks and Nodes
1. Create Network: `./test/networkcreate.sh`
2. Create Key: `./test/keycreate.sh` (save the response for step 3)
3. Open ./test/nodescreate.sh and replace ACCESSKEY with value from #2
4. Create Nodes: `./test/nodescreate.sh`
5. Check to see if nodes were created: `curl -H "authorization: Bearer secretkey" localhost:8081/api/skynet/nodes | jq`
### UI Setup ### UI Setup
Please see [this repo](https://github.com/gravitl/netmaker-ui) for instructions on setting up your UI. 1. **Download UI asset files:** `sudo wget -O /usr/share/nginx/html/netmaker-ui.zip https://github.com/gravitl/netmaker-ui/releases/download/latest/netmaker-ui.zip`
2. **Unzip:** `sudo unzip /usr/share/nginx/html/netmaker-ui.zip -d /usr/share/nginx/html`
3. **Copy Config to Nginx:** `sudo cp /usr/share/nginx/html/nginx.conf /etc/nginx/conf.d/default.conf`
4. **Modify Default Config Path:** `sudo sed -i 's/root \/var\/www\/html/root \/usr\/share\/nginx\/html/g' /etc/nginx/sites-available/default`
5. **Change Backend URL:** `sudo sh -c 'BACKEND_URL=http://<YOUR BACKEND API URL>:PORT /usr/share/nginx/html/generate_config_js.sh >/usr/share/nginx/html/config.js'`
6. **Start Nginx:** `sudo systemctl start nginx`
### Agent Setup ### Agent Setup
@ -119,4 +140,3 @@ When making changes to Netmaker, you may wish to create nodes, networks, or keys
**Integration Testing** **Integration Testing**
Similarly, several go scripts have been created under the test directory (*.go) to test out changes to the code base. These will be run automatically when PR's are submitted but can also be run manually using "go test." Similarly, several go scripts have been created under the test directory (*.go) to test out changes to the code base. These will be run automatically when PR's are submitted but can also be run manually using "go test."

53
netmaker-install-clientmode.sh Executable file
View file

@ -0,0 +1,53 @@
#!/bin/sh
set -e
[ -z "$SERVER_DOMAIN" ] && echo "Need to set SERVER_DOMAIN (format: 1.2.3.4 or mybackend.com)" && exit 1;
docker volume create mongovol && docker run -d --name mongodb -v mongovol:/data/db --network host -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=mongopass mongo --bind_ip 0.0.0.0
mkdir -p /etc/netmaker/config/environments
wget -O /etc/netmaker/netmaker https://github.com/gravitl/netmaker/releases/download/latest/netmaker
chmod +x /etc/netmaker/netmaker
cat >/etc/netmaker/config/environments/dev.yaml<<EOL
server:
host: $SERVER_DOMAIN
apiport: "8081"
grpcport: "50051"
masterkey: "secretkey"
allowedorigin: "*"
restbackend: true
agentbackend: true
defaultnetname: "default"
defaultnetrange: "10.10.10.0/24"
createdefault: true
mongoconn:
user: "mongoadmin"
pass: "mongopass"
host: "localhost"
port: "27017"
opts: '/?authSource=admin'
EOL
cat >/etc/systemd/system/netmaker.service<<EOL
[Unit]
Description=Netmaker Server
After=network.target
[Service]
Type=simple
Restart=on-failure
WorkingDirectory=/etc/netmaker
ExecStart=/etc/netmaker/netmaker
[Install]
WantedBy=multi-user.target
EOL
systemctl daemon-reload
systemctl start netmaker.service
docker run -d --name netmaker-ui -p 80:80 -e BACKEND_URL="http://$SERVER_DOMAIN:8081" gravitl/netmaker-ui:v0.2

45
netmaker-server.sh Executable file
View file

@ -0,0 +1,45 @@
#!/bin/sh
set -e
mkdir -p /etc/netmaker/config/environments
wget -O /etc/netmaker/netmaker https://github.com/gravitl/netmaker/releases/download/latest/netmaker
chmod +x /etc/netmaker/netmaker
cat >/etc/netmaker/config/environments/dev.yaml<<EOL
server:
host:
apiport: "8081"
grpcport: "50051"
masterkey: "secretkey"
allowedorigin: "*"
restbackend: true
agentbackend: true
defaultnetname: "default"
defaultnetrange: "10.10.10.0/24"
createdefault: true
mongoconn:
user: "mongoadmin"
pass: "mongopass"
host: "localhost"
port: "27017"
opts: '/?authSource=admin'
EOL
cat >/etc/systemd/system/netmaker.service<<EOL
[Unit]
Description=Netmaker Server
After=network.target
[Service]
Type=simple
Restart=on-failure
WorkingDirectory=/etc/netmaker
ExecStart=/etc/netmaker/netmaker
[Install]
WantedBy=multi-user.target
EOL
systemctl daemon-reload
systemctl start netmaker.service