quick-start.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. ====================
  2. Quick Install
  3. =====================
  4. Introduction
  5. ==============
  6. This is an **opinionated** guide for getting up and running with Netmaker as quickly as possible. If this configuration does not fit your use case, see the Advanced Installation docs.
  7. We assume for this installation that you want all of the features, want your server to be secure, and want it to be accessible from anywhere.
  8. This instance will not be HA, and is not horizontally scalable. However, it should comfortably handle several hundred clients and most average use cases. If you are deploying for an enterprise use case, please contact [email protected] for support.
  9. By the end of this guide, you will have Netmaker installed on a public VM linked to your custom domain, secured behind an Nginx reverse proxy.
  10. 0. Prerequisites
  11. ==================
  12. - **Virtual Machine**
  13. - Preferably from a cloud provider (e.x: DigitalOcean, Linode, AWS, GCP, etc.)
  14. - Public, static IP
  15. - Min 2GB RAM, 1 CPU (4GB RAM, 2CPU preferred)
  16. - 5GB+ of storage
  17. - Ubuntu 20.04 Installed
  18. - **Domain**
  19. - A publicly owned domain (e.x. example.com, mysite.biz)
  20. - Permission and access to modify DNS records via DNS service (e.x: Route53)
  21. #. Docker and Docker Compose installed on the above server. Follow the official `Docker instructions <https://docs.docker.com/engine/install/>`_ for installing Docker and Docker Compose on your system.
  22. #. All network nodes should be systemd-based (see Compatibility under :doc:`Architecture <./architecture>` docs)
  23. 1. Install Dependencies
  24. ========================
  25. ``ssh root@your-host``
  26. Install Docker
  27. ---------------
  28. Begin by installing the community version of Docker and docker-compose (there are issues with the snap version).
  29. ``sudo apt-get remove docker docker-engine docker.io containerd runc``
  30. ``sudo apt-get update``
  31. ``sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release``
  32. ``curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg``
  33. ``echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null``
  34. ``sudo apt-get update``
  35. ``sudo apt-get install docker-ce docker-ce-cli containerd.io``
  36. ``sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose``
  37. ``sudo chmod +x /usr/local/bin/docker-compose``
  38. ``docker --version``
  39. ``docker-compose --version``
  40. At this point Docker should be installed.
  41. Install Dependencies
  42. -----------------------------
  43. ``sudo apt install wireguard wireguard-tools nginx certbot python3-certbot-nginx net-tools``
  44. 2. Prepare VM
  45. ===============================
  46. Prepare Domain
  47. ----------------------------
  48. 1. Choose a base domain or subdomain for Netmaker. If you own **example.com**, this should be something like **netmaker.example.com**
  49. - You must point your wildcard domain to the public IP of your VM, e.x: *.example.com --> <your public ip>
  50. 2. Add an A record pointing to your VM using your DNS service provider for *.netmaker.example.com (inserting your own subdomain of course).
  51. 3. Netmaker will create three subdomains on top of this. For the example above those subdomains would be:
  52. - dashboard.netmaker.example.com
  53. - api.netmaker.example.com
  54. - grpc.netmaker.example.com
  55. Moving forward we will refer to your base domain using **<your base domain>**. Replace these references with your domain (e.g. netmaker.example.com).
  56. 4. ``nslookup host.<your base domain>`` (inserting your domain) should now return the IP of your VM.
  57. 5. Generate SSL Certificates using certbot:
  58. ``sudo certbot certonly --manual --preferred-challenges=dns --email [email protected] --server https://acme-v02.api.letsencrypt.org/directory --agree-tos --manual-public-ip-logging-ok -d "*.<your base domain>"``
  59. The above command (using your domain instead of <your base domain>), will prompt you to enter a TXT record in your DNS service provider. Do this, and **wait one minute** before clicking enter, or it may fail and you will have to run the command again.
  60. Prepare Firewall
  61. -----------------
  62. Make sure firewall settings are appropriate for Netmaker. You need ports 53 and 443. On the server you can run:
  63. ``sudo ufw allow proto tcp from any to any port 443 && sudo ufw allow dns && ``
  64. **Based on your cloud provider, you may also need to set inbound security rules for your server. This will be dependent on your cloud provider. Be sure to check before moving on:**
  65. - allow 443/tcp from all
  66. - allow 1443/tcp from all
  67. - allow 53/udp from all
  68. Prepare for DNS
  69. ----------------------------------------------------------------
  70. On Ubuntu 20.04, by default there is a service consuming port 53 related to DNS resolution. We need port 53 open in order to run our own DNS server. The below steps will disable systemd-resolved, and insert a generic DNS nameserver for local resolution.
  71. 1. ``sudo systemctl stop systemd-resolved``
  72. 2. ``sudo systemctl disable systemd-resolved``
  73. 3. ``sudo vim /etc/systemd/resolved.conf``
  74. * uncomment DNS and add 8.8.8.8 or whatever reachable nameserver is your preference
  75. * uncomment DNSStubListener and set to "no"
  76. 4. ``sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf``
  77. Prepare Nginx
  78. -----------------
  79. Nginx will serve the SSL certificate with your chosen domain and forward traffic to netmaker.
  80. Add the nginx configuration files:
  81. ``wget https://raw.githubusercontent.com/gravitl/netmaker/develop/nginx/netmaker-nginx-template.conf``
  82. ``wget https://raw.githubusercontent.com/gravitl/netmaker/develop/nginx/netmaker-nginx-dns.conf``
  83. Insert your domain in the configuration file and add to nginx:
  84. ``sed -i 's/NETMAKER_BASE_DOMAIN/<your base domain>/g' netmaker-nginx-template.conf ``
  85. ``sudo cp netmaker-nginx-template.conf /etc/nginx/conf.d/<your base domain>.conf && sudo cp netmaker-nginx-dns.conf /etc/nginx/nginx.conf``
  86. ``nginx -t && nginx -s reload``
  87. ``systemctl restart nginx``
  88. Install Netmaker
  89. =================
  90. Prepare Templates
  91. ------------------
  92. ``wget https://raw.githubusercontent.com/gravitl/netmaker/develop/compose/docker-compose.quickstart.yml``
  93. ``sed -i 's/NETMAKER_BASE_DOMAIN/<your base domain>/g' docker-compose.quickstart.yml``
  94. ``sed -i 's/SERVER_PUBLIC_IP/<your server ip>/g' docker-compose.quickstart.yml``
  95. Generate a unique master key and insert it:
  96. ``tr -dc A-Za-z0-9 </dev/urandom | head -c 30 ; echo ''``
  97. ``sed -i 's/REPLACE_MASTER_KEY/<your generated key>/g' docker-compose.quickstart.yml``
  98. Start Netmaker
  99. ----------------
  100. ``sudo docker-compose -f docker-compose.quickstart.yml up -d``
  101. ===========
  102. Quick Start
  103. ===========
  104. Setup
  105. =================
  106. #. Create your admin user, with a username and password.
  107. #. Login with your new user
  108. #. Examine the **default** network. Click on DEFAULT under NETWORK DETAILS
  109. .. image:: images/default-net.png
  110. :width: 80%
  111. :alt: Create User Screen
  112. :align: center
  113. This displays information about the **default** network, which is created on server startup. You can delete this network if you do not need it, but for standard use cases this network should be enough to get started. Nodes will get an address from the network address range (ADDRESSRANGE). If the range conflicts with a pre-existing private network on your devices, you may want to change this, or make a new network instead. Nodes will also get default settings from here for unset configurations. For instance, the DEFAULTKEEPALIVE field will set the PersistenKeepAlive for nodes.
  114. To get started quickly, we can just use the existing default network.
  115. Create Key
  116. ------------
  117. #. Click on the ACCESS KEYS tab and select the DEFAULT network.
  118. #. Click ADD NEW ACCESS KEY
  119. #. Give it a name (ex: "mykey") and a number of uses (ex: 25)
  120. #. Click CREATE KEY (**Important:** Do not click out of the following screen until you have saved your key details. It will appear only once.)
  121. #. Copy the bottom command under "Your agent install command with access token" and save it somewhere locally. E.x: ``curl -sfL https://raw.githubusercontent.com/gravitl/netmaker/v0.5/scripts/netclient-install.sh | KEY=vm3ow4thatogiwnsla3thsl3894ths sh -``. **A change is required here. Change netclient-install.sh in this command to netclient-install.slim.sh, EX:**
  122. ``curl -sfL https://raw.githubusercontent.com/gravitl/netmaker/v0.5/scripts/netclient-install.slim.sh | KEY=vm3ow4thatogiwnsla3thsl3894ths sh -``
  123. .. image:: images/access-key.png
  124. :width: 80%
  125. :alt: Access Key Screen
  126. :align: center
  127. You will use this command to install the netclient on your nodes. There are three different values for three different scenarios:
  128. * The **Access Key** value is the secret string that will allow your node to authenticate with the Netmaker network. This can be used with existing netclient installations where additional configurations (such as setting the server IP manually) may be required. This is not typical. E.g. ``netclient -c install -k <access key> -s 1.2.3.4 -p 50052``
  129. * The **Access Token** value is a base64 encoded string that contains the server IP and grpc port, as well as the access key. This is decoded by the netclient and can be used with existing netclient installations like this: ``netclient -c install -t <access token>``. You should use this method for adding a network to a node that is already on a network. For instance, Node A is in the **mynet** network and now you are adding it to **default**.
  130. <<<<<<< HEAD
  131. =======
  132. * The **install command** value is a curl command that can be run on Linux systems. It is a simple script that downloads the netclient binary and runs the install command all in one. However, this script is tailored for Secure GRPC Mode and contains an additional (unnecessary) command: **netclient register -k keyvalue**. This command will not work without secure GRPC enabled and will return a 500 error.
  133. >>>>>>> c360eb1878a4fe89538235ab240da6f6890934a1
  134. Networks can also be enabled to allow nodes to sign up without keys at all. In this scenario, nodes enter a "pending state" and are not permitted to join the network until an admin approves them.
  135. Deploy Nodes
  136. =================
  137. 1. SSH to each machine
  138. 2. ``sudo su -``
  139. 3. **Prerequisite Check:** Every Linux machine on which you run the netclient must have WireGuard and systemd installed
  140. * ``which wg`` (should show wg binary present)
  141. * ``pidof systemd && echo "systemd found" || echo "systemd not found"``
  142. 4. Run the install command, Ex: ``curl -sfL https://raw.githubusercontent.com/gravitl/netmaker/v0.5/scripts/netclient-install.slim.sh | KEY=vm3ow4thatogiwnsla3thsl3894ths sh -``
  143. You should get output similar to the below. The netclient retrieves local settings, submits them to the server for processing, and retrieves updated settings. Then it sets the local network configuration. For more information about this process, see the :doc:`client installation <./client-installation>` documentation. If this process failed and you do not see your node in the console (see below), then reference the :doc:`troubleshooting <./troubleshoot>` documentation.
  144. .. image:: images/nc-install-output.png
  145. :width: 80%
  146. :alt: Output from Netclient Install
  147. :align: center
  148. .. image:: images/nm-node-success.png
  149. :width: 80%
  150. :alt: Node Success
  151. :align: center
  152. Repeat the above steps for every machine you would like to add to your network. You can re-use the same install command so long as you do not run out of uses on your access key (after which it will be invalidated and deleted).
  153. Once installed on all nodes, you can test the connection by pinging the private address of any node from any other node.
  154. .. image:: images/ping-node.png
  155. :width: 80%
  156. :alt: Node Success
  157. :align: center
  158. Manage Nodes
  159. ===============
  160. Your machines should now be visible in the control pane.
  161. .. image:: images/nodes.png
  162. :width: 80%
  163. :alt: Node Success
  164. :align: center
  165. You can view/modify/delete any node by selecting it in the NODES tab. For instance, you can change the name to something more sensible like "workstation" or "api server". You can also modify network settings here, such as keys or the WireGuard port. These settings will be picked up by the node on its next check in. For more information, see Advanced Configuration in the :doc:`Using Netmaker <./usage>` docs.
  166. .. image:: images/node-details.png
  167. :width: 80%
  168. :alt: Node Success
  169. :align: center
  170. Nodes can be added/removed/modified on the network at any time. Nodes can also be added to multiple Netmaker networks. Any changes will get picked up by any nodes on a given network, and will take aboue ~30 seconds to take effect.
  171. Uninstalling the netclient
  172. =============================
  173. 1. To remove your nodes from the default network, run the following on each node: ``sudo netclient leave -n default``
  174. 2. To remove the netclient entirely from each node, run ``sudo rm -rf /etc/netclient`` (after running the first step)
  175. Uninstalling Netmaker
  176. ===========================
  177. To uninstall Netmaker from the server, simply run ``docker-compose down`` or ``docker-compose down --volumes`` to remove the docker volumes for a future installation.