server-installation.rst 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. =================================
  2. Advanced Server Installation
  3. =================================
  4. This section outlines installing the Netmaker server, including Netmaker, Netmaker UI, rqlite, and CoreDNS
  5. System Compatibility
  6. ====================
  7. Netmaker will require elevated privileges to perform network operations. Netmaker has similar limitations to :doc:`netclient <./client-installation>` (client networking agent).
  8. Typically, Netmaker is run inside of containers (Docker). To run a non-docker installation, you must run the Netmaker binary, CoreDNS binary, database, and a web server directly on the host. Each of these components have their own individual requirements.
  9. The quick install guide is recommended for first-time installs.
  10. The following documents are meant for special cases like Kubernetes and LXC, or for more advanced setups.
  11. Server Configuration Reference
  12. ==========================================
  13. Netmaker sets its configuration in the following order of precendence:
  14. 1. Defaults
  15. 2. Config File
  16. 3. Environment Variables
  17. Variable Description
  18. ----------------------
  19. VERBOSITY:
  20. **Default:** 0
  21. **Description:** Specify level of logging you would like on the server. Goes up to 3 for debugging.
  22. GRPC_SSL:
  23. **Default:** "off"
  24. **Description:** Specifies if GRPC is going over secure GRPC or SSL. This is a setting for the clients and is passed through the access token. Can be set to "on" and "off". Set to on if SSL is configured for GRPC.
  25. SERVER_API_CONN_STRING
  26. **Default:** ""
  27. **Description:** Allows specification of the string used to connect to the server api. Format: IP:PORT or DOMAIN:PORT. Defaults to SERVER_HOST if not specified.
  28. SERVER_GRPC_CONN_STRING
  29. **Default:** ""
  30. **Description:** Allows specification of the string used to connect to grpc. Format: IP:PORT or DOMAIN:PORT. Defaults to SERVER_HOST if not specified.
  31. SERVER_HOST: *(depreciated, use SERVER_API_CONN_STRING and SERVER_GRPC_CONN_STRING)*
  32. **Default:** Server will perform an IP check and set automatically unless explicitly set, or DISABLE_REMOTE_IP_CHECK is set to true, in which case it defaults to 127.0.0.1
  33. **Description:** Sets the SERVER_HTTP_HOST and SERVER_GRPC_HOST variables if they are unset. The address where traffic comes in.
  34. SERVER_HTTP_HOST: *(depreciated, use SERVER_API_CONN_STRING and SERVER_GRPC_CONN_STRING)*
  35. **Default:** Equals SERVER_HOST if set, "127.0.0.1" if SERVER_HOST is unset.
  36. **Description:** Set to make the HTTP and GRPC functions available via different interfaces/networks.
  37. SERVER_GRPC_HOST: *(depreciated, use SERVER_API_CONN_STRING and SERVER_GRPC_CONN_STRING)*
  38. **Default:** Equals SERVER_HOST if set, "127.0.0.1" if SERVER_HOST is unset.
  39. **Description:** Set to make the HTTP and GRPC functions available via different interfaces/networks.
  40. API_PORT:
  41. **Default:** 8081
  42. **Description:** The HTTP API port for Netmaker. Used for API calls / communication from front end.
  43. GRPC_PORT:
  44. **Default:** 50051
  45. **Description:** The GRPC port for Netmaker. Used for communications from nodes.
  46. MASTER_KEY:
  47. **Default:** "secretkey"
  48. **Description:** The admin master key for accessing the API. Change this in any production installation.
  49. CORS_ALLOWED_ORIGIN:
  50. **Default:** "*"
  51. **Description:** The "allowed origin" for API requests. Change to restrict where API requests can come from.
  52. REST_BACKEND:
  53. **Default:** "on"
  54. **Description:** Enables the REST backend (API running on API_PORT at SERVER_HTTP_HOST). Change to "off" to turn off.
  55. AGENT_BACKEND:
  56. **Default:** "on"
  57. **Description:** Enables the AGENT backend (GRPC running on GRPC_PORT at SERVER_GRPC_HOST). Change to "off" to turn off.
  58. DNS_MODE:
  59. **Default:** "off"
  60. **Description:** Enables DNS Mode, meaning config files will be generated for CoreDNS.
  61. DATABASE:
  62. **Default:** "sqlite"
  63. **Description:** Specify db type to connect with. Currently, options include "sqlite", "rqlite", and "postgres".
  64. SQL_CONN:
  65. **Default:** "http://"
  66. **Description:** Specify the necessary string to connect with your local or remote sql database.
  67. SQL_HOST:
  68. **Default:** "localhost"
  69. **Description:** Host where postgres is running.
  70. SQL_PORT:
  71. **Default:** "5432"
  72. **Description:** port postgres is running.
  73. SQL_DB:
  74. **Default:** "netmaker"
  75. **Description:** DB to use in postgres.
  76. SQL_USER:
  77. **Default:** "postgres"
  78. **Description:** User for posgres.
  79. SQL_PASS:
  80. **Default:** "nopass"
  81. **Description:** Password for postgres.
  82. CLIENT_MODE:
  83. **Default:** "on"
  84. **Description:** Specifies if server should deploy itself as a node (client) in each network. May be turned to "off" for more restricted servers.
  85. RCE:
  86. **Default:** "off"
  87. **Description:** The server enables you to set PostUp and PostDown commands for nodes, which is standard for WireGuard with wg-quick, but is also **Remote Code Execution**, which is a critical vulnerability if the server is exploited. Because of this, it's turned off by default, but if turned on, PostUp and PostDown become editable.
  88. SERVER_GRPC_WIREGUARD
  89. **Depreciated:** no longer in use
  90. DISPLAY_KEYS
  91. **Default:** "on"
  92. **Description:** If "on", will allow you to always show the key values of "access keys". This could be considered a vulnerability, so if turned "off", will only display key values once, and it is up to the users to store the key values locally.
  93. NODE_ID
  94. **Default:** <system mac addres>
  95. **Description:** This setting is used for HA configurations of the server, to identify between different servers. Nodes are given ID's like netmaker-1, netmaker-2, and netmaker-3. If the server is not HA, there is no reason to set this field.
  96. TELEMETRY
  97. **Default:** "on"
  98. **Description:** If "on", the server will send anonymous telemetry data once daily, which is used to improve the product. Data sent includes counts (integer values) for the number of nodes, types of nodes, users, and networks. It also sends the version of the server.
  99. Config File Reference
  100. -----------------------
  101. A config file may be placed under config/environments/<env-name>.yml. To read this file at runtime, provide the environment variable NETMAKER_ENV at runtime. For instance, dev.yml paired with ENV=dev. Netmaker will load the specified Config file. This allows you to store and manage configurations for different environments. Below is a reference Config File you may use.
  102. .. literalinclude:: ../config/environments/dev.yaml
  103. :language: YAML
  104. Compose File - Annotated
  105. --------------------------------------
  106. All environment variables and options are enabled in this file. It is the equivalent to running the "full install" from the above section. However, all environment variables are included, and are set to the default values provided by Netmaker (if the environment variable was left unset, it would not change the installation). Comments are added to each option to show how you might use it to modify your installation.
  107. .. literalinclude:: ../compose/docker-compose.reference.yml
  108. :language: YAML
  109. Available docker-compose files
  110. ---------------------------------
  111. The default options for docker-compose can be found here: https://github.com/gravitl/netmaker/tree/master/compose
  112. The following is a brief description of each:
  113. - `docker-compose.contained.yml <https://github.com/gravitl/netmaker/blob/master/compose/docker-compose.contained.yml>`_ - This is the default docker-compose, used in the quick start and deployment script in the README on GitHub. It deploys Netmaker with all options included (Caddy and CoreDNS) and has "self-contained" netclients, meaning they do not affect host networking.
  114. - `docker-compose.coredns.yml <https://github.com/gravitl/netmaker/blob/master/compose/docker-compose.coredns.yml>`_ - This is a simple compose used to spin up a standalone CoreDNS server. Can be useful if, for instance, you are unning Netmaker on baremetal but need CoreDNS.
  115. - `docker-compose.hostnetwork.yml <https://github.com/gravitl/netmaker/blob/master/compose/docker-compose.hostnetwork.yml>`_ - This is similar to the docker-compose.contained.yml but with a key difference: it has advanced permissions and mounts host volumes to control networking on the host level.
  116. - `docker-compose.nocaddy.yml <https://github.com/gravitl/netmaker/blob/master/compose/docker-compose.nocaddy.yml>`_ -= This is the same as docker-compose.contained.yml but without Caddy, in case you need to use a different proxy like Nginx, Traefik, or HAProxy.
  117. - `docker-compose.nodns.yml <https://github.com/gravitl/netmaker/blob/master/compose/docker-compose.nodns.yml>`_ - This is the same as docker-compose.contained.yml but without CoreDNS, in which case you will not have the Private DNS feature.
  118. - `docker-compose.reference.yml <https://github.com/gravitl/netmaker/blob/master/compose/docker-compose.reference.yml>`_ - This is the same as docker-compose.contained.yml but with all variable options on display and annotated (it's what we show right above this section). Use this to determine which variables you should add or change in your configuration.
  119. - `docker-compose.yml <https://github.com/gravitl/netmaker/blob/master/compose/docker-compose.yml>`_ - This is a renamed docker-compose.contained.yml. It is meant only to act as a placeholder for what we consider the "primary" docker-compose that users should work with.
  120. DNS Mode Setup
  121. ====================================
  122. If you plan on running the server in DNS Mode, know that a `CoreDNS Server <https://coredns.io/manual/toc/>`_ will be installed. CoreDNS is a light-weight, fast, and easy-to-configure DNS server. It is recommended to bind CoreDNS to port 53 of the host system, and it will do so by default. The clients will expect the nameserver to be on port 53, and many systems have issues resolving a different port.
  123. However, on your host system (for Netmaker), this may conflict with an existing process. On linux systems running systemd-resolved, there is likely a service consuming port 53. The below steps will disable systemd-resolved, and replace it with a generic (e.g. Google) nameserver. Be warned that this may have consequences for any existing private DNS configuration.
  124. With the latest docker-compose, it is not necessary to perform these steps. But if you are running the install and find that port 53 is blocked, you can perform the following steps, which were tested on Ubuntu 20.04 (these should be run prior to deploying the docker containers).
  125. .. code-block::
  126. systemctl stop systemd-resolved
  127. systemctl disable systemd-resolved
  128. vim /etc/systemd/resolved.conf
  129. * uncomment DNS and add 8.8.8.8 or whatever reachable nameserver is your preference *
  130. * uncomment DNSStubListener and set to "no" *
  131. ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
  132. Port 53 should now be available for CoreDNS to use.
  133. Docker Compose Install
  134. =======================
  135. The most simple (and recommended) way of installing Netmaker is to use one of the provided `Docker Compose files <https://github.com/gravitl/netmaker/tree/master/compose>`_. Below are instructions for several different options to install Netmaker via Docker Compose, followed by an annotated reference Docker Compose in case your use case requires additional customization.
  136. Test Install - No DNS, No Secure GRPC
  137. --------------------------------------------------------
  138. This install will run Netmaker on a server without HTTPS using an IP address. This is not secure and not recommended, but can be helpful for testing.
  139. It also does not run the CoreDNS server, to simplify the deployment
  140. **Prerequisites:**
  141. * server ports 80, 8081, and 50051 are not blocked by firewall
  142. **Notes:**
  143. * You can change the port mappings in the Docker Compose if the listed ports are already in use.
  144. Assuming you have Docker and Docker Compose installed, you can just run the following, replacing **< Insert your-host IP Address Here >** with your host IP (or domain):
  145. .. code-block::
  146. wget -O docker-compose.yml https://raw.githubusercontent.com/gravitl/netmaker/master/scripts/docker-compose.test.yml
  147. sed -i ‘s/HOST_IP/< Insert your-host IP Address Here >/g’ docker-compose.yml
  148. docker-compose up -d`
  149. Traefik Proxy
  150. ------------------------
  151. To install with Traefik, rather than Nginx or the default Caddy, check out this repo: https://github.com/bsherman/netmaker-traefik
  152. No DNS - CoreDNS Disabled
  153. ----------------------------------------------
  154. DNS Mode is currently limited to clients that can run resolvectl (systemd-resolved, see :doc:`Architecture docs <./architecture>` for more info). You may wish to disable DNS mode for various reasons. This installation option gives you the full feature set minus CoreDNS.
  155. To run without DNS, follow the :doc:`Quick Install <./quick-start>` guide, omitting the steps for DNS setup. In addition, when the guide has you pull (wget) the Netmaker docker-compose template, use the following link instead:
  156. #. ``wget -O docker-compose.yml https://raw.githubusercontent.com/gravitl/netmaker/master/scripts/docker-compose.nodns.yml``
  157. This template is equivalent but omits CoreDNS.
  158. .. _NoDocker:
  159. Linux Install without Docker
  160. =============================
  161. Most systems support Docker, but some do not. In such environments, there are many options for installing Netmaker. Netmaker is available as a binary file, and there is a zip file of the Netmaker UI static HTML on GitHub. Beyond the UI and Server, you may want to optionally install a database (sqlite is embedded, rqlite or postgres are supported) and CoreDNS (also optional).
  162. Once this is enabled and configured for a domain, you can continue with the below. The recommended server runs Ubuntu 20.04.
  163. Database Setup (optional)
  164. --------------------------
  165. You can run the netmaker binary standalone and it will run an embedded sqlite server. Data goes in the data/ directory. Optionally, you can run PostgreSQL or rqlite. Instructions for rqlite are below.
  166. 1. Install rqlite on your server: https://github.com/rqlite/rqlite
  167. 2. Run rqlite: rqlited -node-id 1 ~/node.1
  168. If using rqlite or postgres, you must change the DATABASE environment/config variable and enter connection details.
  169. Server Setup
  170. -------------
  171. 1. **Run the install script:**
  172. ``sudo curl -sfL https://raw.githubusercontent.com/gravitl/netmaker/master/scripts/netmaker-server.sh | sh -``
  173. 2. Check status: ``sudo journalctl -u netmaker``
  174. 3. If any settings are incorrect such as host or mongo credentials, change them under /etc/netmaker/config/environments/< your env >.yaml and then run ``sudo systemctl restart netmaker``
  175. UI Setup
  176. -----------
  177. The following uses Nginx as an http server. You may alternatively use Apache or any other web server that serves static web files.
  178. 1. Download and Unzip UI asset files
  179. 2. Copy Config to Nginx
  180. 3. Modify Default Config Path
  181. 4. Change Backend URL
  182. 5. Start Nginx
  183. .. code-block::
  184. sudo wget -O /usr/share/nginx/html/netmaker-ui.zip https://github.com/gravitl/netmaker-ui/releases/download/latest/netmaker-ui.zip
  185. sudo unzip /usr/share/nginx/html/netmaker-ui.zip -d /usr/share/nginx/html
  186. sudo cp /usr/share/nginx/html/nginx.conf /etc/nginx/conf.d/default.conf
  187. sudo sed -i 's/root \/var\/www\/html/root \/usr\/share\/nginx\/html/g' /etc/nginx/sites-available/default
  188. 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'
  189. sudo systemctl start nginx
  190. CoreDNS Setup (optional)
  191. ----------------------------
  192. CoreDNS is only required if you want private DNS features. Once installed, you must set the CoreDNS variables in the env settings of the server.
  193. See https://coredns.io/manual/toc/#installation
  194. Proxy / Load Balancer
  195. ------------------------
  196. You will need to proxy connections to your UI and Server. By default the ports are 8081, 8082, and 50051 (grpc). This proxy should handle SSL certificates. We recommend Caddy or Nginx (you can follow the Nginx guide in these docs). The proxy must be able to handle gRPC connections.
  197. .. _KubeInstall:
  198. Kubernetes Install
  199. =======================
  200. Server Install
  201. --------------------------
  202. This template assumes your cluster uses Nginx for ingress with valid wildcard certificates. If using an ingress controller other than Nginx (ex: Traefik), you will need to manually modify the Ingress entries in this template to match your environment.
  203. This template also requires RWX storage. Please change references to storageClassName in this template to your cluster's Storage Class.
  204. ``wget https://raw.githubusercontent.com/gravitl/netmaker/master/kube/netmaker-template.yaml``
  205. Replace the NETMAKER_BASE_DOMAIN references to the base domain you would like for your Netmaker services (ui,api,grpc). Typically this will be something like **netmaker.yourwildcard.com**.
  206. ``sed -i ‘s/NETMAKER_BASE_DOMAIN/<your base domain>/g’ netmaker-template.yaml``
  207. Now, assuming Ingress and Storage match correctly with your cluster configuration, you can install Netmaker.
  208. .. code-block::
  209. kubectl create ns nm
  210. kubectl config set-context --current --namespace=nm
  211. kubectl apply -f netmaker-template.yaml -n nm
  212. In about 3 minutes, everything should be up and running:
  213. ``kubectl get ingress nm-ui-ingress-nginx``
  214. Netclient Daemonset
  215. --------------------------
  216. The following instructions assume you have Netmaker running and a network you would like to add your cluster into. The Netmaker server does not need to be running inside of a cluster for this.
  217. .. code-block::
  218. wget https://raw.githubusercontent.com/gravitl/netmaker/master/kube/netclient-template.yaml
  219. sed -i ‘s/ACCESS_TOKEN_VALUE/< your access token value>/g’ netclient-template.yaml
  220. kubectl apply -f netclient-template.yaml
  221. For a more detailed guide on integrating Netmaker with MicroK8s, `check out this guide <https://itnext.io/how-to-deploy-a-cross-cloud-kubernetes-cluster-with-built-in-disaster-recovery-bbce27fcc9d7>`_.
  222. Nginx Reverse Proxy Setup with https
  223. ======================================
  224. The `Swag Proxy <https://github.com/linuxserver/docker-swag>`_ makes it easy to generate a valid ssl certificate for the config bellow. Here is the `documentation <https://docs.linuxserver.io/general/swag>`_ for the installation.
  225. The following file configures Netmaker as a subdomain. This config is an adaption from the swag proxy project.
  226. ./netmaker.subdomain.conf:
  227. .. code-block:: nginx
  228. server {
  229. listen 443 ssl;
  230. listen [::]:443 ssl;
  231. server_name netmaker.*; # The external URL
  232. client_max_body_size 0;
  233. # A valid https certificate is needed.
  234. include /config/nginx/ssl.conf;
  235. location / {
  236. # This config file can be found at:
  237. # https://github.com/linuxserver/docker-swag/blob/master/root/defaults/proxy.conf
  238. include /config/nginx/proxy.conf;
  239. # if you use a custom resolver to find your app, needed with swag proxy
  240. # resolver 127.0.0.11 valid=30s;
  241. set $upstream_app netmaker-ui; # The internal URL
  242. set $upstream_port 80; # The internal Port
  243. set $upstream_proto http; # the protocol that is being used
  244. proxy_pass $upstream_proto://$upstream_app:$upstream_port; # combine the set variables from above
  245. }
  246. }
  247. server {
  248. listen 443 ssl;
  249. listen [::]:443 ssl;
  250. server_name backend-netmaker.*; # The external URL
  251. client_max_body_size 0;
  252. underscores_in_headers on;
  253. # A valid https certificate is needed.
  254. include /config/nginx/ssl.conf;
  255. location / {
  256. # if you use a custom resolver to find your app, needed with swag proxy
  257. # resolver 127.0.0.11 valid=30s;
  258. set $upstream_app netmaker; # The internal URL
  259. set $upstream_port 8081; # The internal Port
  260. set $upstream_proto http; # the protocol that is being used
  261. proxy_pass $upstream_proto://$upstream_app:$upstream_port; # combine the set variables from above
  262. # Forces the header to be the one that is visible from the outside
  263. proxy_set_header Host backend.netmaker.example.org; # Please cange to your URL
  264. # Pass all headers through to the backend
  265. proxy_pass_request_headers on;
  266. }
  267. }
  268. .. _HAInstall:
  269. Highly Available Installation (Kubernetes)
  270. ==================================================
  271. Netmaker comes with a Helm chart to deploy with High Availability on Kubernetes:
  272. .. code-block::
  273. helm repo add netmaker https://gravitl.github.io/netmaker-helm/
  274. helm repo update
  275. Requirements
  276. ---------------
  277. To run HA Netmaker on Kubernetes, your cluster must have the following:
  278. - RWO and RWX Storage Classes (RWX is only required if running Netmaker with DNS Management enabled).
  279. - An Ingress Controller and valid TLS certificates
  280. - This chart can currently generate ingress for Nginx or Traefik Ingress with LetsEncrypt + Cert Manager
  281. - If LetsEncrypt and CertManager are not deployed, you must manually configure certificates for your ingress
  282. Furthermore, the chart will by default install and use a postgresql cluster as its datastore.
  283. Recommended Settings:
  284. ----------------------
  285. A minimal HA install of Netmaker can be run with the following command:
  286. `helm install netmaker --generate-name --set baseDomain=nm.example.com`
  287. This install has some notable exceptions:
  288. - Ingress **must** be manually configured post-install (need to create valid Ingress with TLS)
  289. - Server will use "userspace" WireGuard, which is slower than kernel WG
  290. - DNS will be disabled
  291. Example Installations:
  292. ------------------------
  293. An annotated install command:
  294. .. code-block::
  295. helm install netmaker/netmaker --generate-name \ # generate a random id for the deploy
  296. --set baseDomain=nm.example.com \ # the base wildcard domain to use for the netmaker api/dashboard/grpc ingress
  297. --set replicas=3 \ # number of server replicas to deploy (3 by default)
  298. --set ingress.enabled=true \ # deploy ingress automatically (requires nginx or traefik and cert-manager + letsencrypt)
  299. --set ingress.className=nginx \ # ingress class to use
  300. --set ingress.tls.issuerName=letsencrypt-prod \ # LetsEncrypt certificate issuer to use
  301. --set dns.enabled=true \ # deploy and enable private DNS management with CoreDNS
  302. --set dns.clusterIP=10.245.75.75 --set dns.RWX.storageClassName=nfs \ # required fields for DNS
  303. --set postgresql-ha.postgresql.replicaCount=2 \ # number of DB replicas to deploy (default 2)
  304. The below command will install netmaker with two server replicas, a coredns server, and ingress with routes of api.nm.example.com, grpc.nm.example.com, and dashboard.nm.example.com. CoreDNS will be reachable at 10.245.75.75, and will use NFS to share a volume with Netmaker (to configure dns entries).
  305. .. code-block::
  306. helm install netmaker/netmaker --generate-name --set baseDomain=nm.example.com \
  307. --set replicas=2 --set ingress.enabled=true --set dns.enabled=true \
  308. --set dns.clusterIP=10.245.75.75 --set dns.RWX.storageClassName=nfs \
  309. --set ingress.className=nginx
  310. The below command will install netmaker with three server replicas (the default), **no coredns**, and ingress with routes of api.netmaker.example.com, grpc.netmaker.example.com, and dashboard.netmaker.example.com. There will be one UI replica instead of two, and one database instance instead of two. Traefik will look for a ClusterIssuer named "le-prod-2" to get valid certificates for the ingress.
  311. .. code-block::
  312. helm3 install netmaker/netmaker --generate-name \
  313. --set baseDomain=netmaker.example.com --set postgresql-ha.postgresql.replicaCount=1 \
  314. --set ui.replicas=1 --set ingress.enabled=true \
  315. --set ingress.tls.issuerName=le-prod-2 --set ingress.className=traefik
  316. Below, we discuss the considerations for Ingress, Kernel WireGuard, and DNS.
  317. Ingress
  318. ----------
  319. To run HA Netmaker, you must have ingress installed and enabled on your cluster with valid TLS certificates (not self-signed). If you are running Nginx as your Ingress Controller and LetsEncrypt for TLS certificate management, you can run the helm install with the following settings:
  320. - `--set ingress.enabled=true`
  321. - `--set ingress.annotations.cert-manager.io/cluster-issuer=<your LE issuer name>`
  322. If you are not using Nginx or Traefik and LetsEncrypt, we recommend leaving ingress.enabled=false (default), and then manually creating the ingress objects post-install. You will need three ingress objects with TLS:
  323. - `dashboard.<baseDomain>`
  324. - `api.<baseDomain>`
  325. - `grpc.<baseDomain>`
  326. If deploying manually, the gRPC ingress object requires special considerations. Look up the proper way to route grpc with your ingress controller. For instance, on Traefik, an IngressRouteTCP object is required.
  327. There are some example ingress objects in the kube/example folder.
  328. Kernel WireGuard
  329. ------------------
  330. If you have control of the Kubernetes worker node servers, we recommend **first** installing WireGuard on the hosts, and then installing HA Netmaker in Kernel mode. By default, Netmaker will install with userspace WireGuard (wireguard-go) for maximum compatibility, and to avoid needing permissions at the host level. If you have installed WireGuard on your hosts, you should install Netmaker's helm chart with the following option:
  331. - `--set wireguard.kernel=true`
  332. DNS
  333. ----------
  334. By Default, the helm chart will deploy without DNS enabled. To enable DNS, specify with:
  335. - `--set dns.enabled=true`
  336. This will require specifying a RWX storage class, e.g.:
  337. - `--set dns.RWX.storageClassName=nfs`
  338. This will also require specifying a service address for DNS. Choose a valid ipv4 address from the service IP CIDR for your cluster, e.g.:
  339. - `--set dns.clusterIP=10.245.69.69`
  340. **This address will only be reachable from hosts that have access to the cluster service CIDR.** It is only designed for use cases related to k8s. If you want a more general-use Netmaker server on Kubernetes for use cases outside of k8s, you will need to do one of the following:
  341. - bind the CoreDNS service to port 53 on one of your worker nodes and set the COREDNS_ADDRESS equal to the public IP of the worker node
  342. - Create a private Network with Netmaker and set the COREDNS_ADDRESS equal to the private address of the host running CoreDNS. For this, CoreDNS will need a node selector and will ideally run on the same host as one of the Netmaker server instances.
  343. Values
  344. ---------
  345. To view all options for the chart, please visit the README in the code repo `here <https://github.com/gravitl/netmaker/tree/master/kube/helm#values>`_ .
  346. Highly Available Installation (VMs/Bare Metal)
  347. ==================================================
  348. For an enterprise Netmaker installation, you will need a server that is highly available, to ensure redundant WireGuard routing when any server goes down. To do this, you will need:
  349. 1. A load balancer
  350. 2. 3+ Netmaker server instances
  351. 3. rqlite or PostgreSQL as the backing database
  352. These documents outline general HA installation guidelines. Netmaker is highly customizable to meet a wide range of enterprise environments. If you would like support with an enterprise-grade Netmaker installation, you can `schedule a consultation here <https://gravitl.com/book>`_ .
  353. The main consideration for this document is how to configure rqlite. Most other settings and procedures match the standardized way of making applications HA: Load balancing to multiple instances, and sharing a DB. In our case, the DB (rqlite) is distributed, making HA data more easily achievable.
  354. If using PostgreSQL, follow their documentation for `installing in HA mode <https://www.postgresql.org/docs/14/high-availability.html>`_ and skip step #2.
  355. 1. Load Balancer Setup
  356. ------------------------
  357. Your load balancer of choice will send requests to the Netmaker servers. Setup is similar to the various guides we have created for Nginx, Caddy, and Traefik. SSL certificates must also be configured and handled by the LB.
  358. 2. RQLite Setup
  359. ------------------
  360. RQLite is the included distributed datastore for an HA Netmaker installation. If you have a different corporate database you wish to integrate, Netmaker is easily extended to other DB's. If this is a requirement, please contact us.
  361. Assuming you use Rqlite, you must run it on each Netmaker server VM, or alongside that VM as a container. Setup a config.json for database credentials (password supports BCRYPT HASHING) and mount in working directory of rqlite and specify with `-auth config.json` :
  362. .. code-block::
  363. [{
  364. "username": "netmaker",
  365. "password": "<YOUR_DB_PASSWORD>",
  366. "perms": ["all"]
  367. }]
  368. Once your servers are set up with rqlite, the first instance must be started normally, and then additional nodes must be added with the "join" command. For instance, here is the first server node:
  369. .. code-block::
  370. sudo docker run -d -p 4001:4001 -p 4002:4002 rqlite/rqlite -node-id 1 -http-addr 0.0.0.0:4001 -raft-addr 0.0.0.0:4002 -http-adv-addr 1.2.3.4:4001 -raft-adv-addr 1.2.3.4:4002 -auth config.json
  371. And here is a joining node:
  372. .. code-block::
  373. sudo docker run -d -p 4001:4001 -p 4002:4002 rqlite/rqlite -node-id 2 -http-addr 0.0.0.0:4001 -raft-addr 0.0.0.0:4002 -http-adv-addr 2.3.4.5:4001 -raft-adv-addr 2.3.4.5:4002 -join https://netmaker:<YOUR_DB_PASSWORD>@1.2.3.4:4001
  374. - reference for rqlite setup: https://github.com/rqlite/rqlite/blob/master/DOC/CLUSTER_MGMT.md#creating-a-cluster
  375. - reference for rqlite security: https://github.com/rqlite/rqlite/blob/master/DOC/SECURITY.md
  376. Once rqlite instances have been configured, the Netmaker servers can be deployed.
  377. 3. Netmaker Setup
  378. ------------------
  379. Netmaker will be started on each node with default settings, except with DATABASE=rqlite (or DATABASE=postgress) and SQL_CONN set appropriately to reach the local rqlite instance. Rqlite will maintain consistency with each Netmaker backend.
  380. If deploying HA with PostgreSQL, you will connect with the following settings:
  381. .. code-block::
  382. SQL_HOST = <sql host>
  383. SQL_PORT = <port>
  384. SQL_DB = <designated sql DB>
  385. SQL_USER = <your user>
  386. SQL_PASS = <your password>
  387. DATABASE = postgres
  388. 4. Other Considerations
  389. ------------------------
  390. This is enough to get a functioning HA installation of Netmaker. However, you may also want to make the Netmaker UI or the CoreDNS server HA as well. The Netmaker UI can simply be added to the same servers and load balanced appropriately. For some load balancers, you may be able to do this with CoreDNS as well.