# Server Documentation

Documentation for System Admins on how to give users access to the Raspberry Pi Club's Proxmox Server and anything else related.

# 1.0 Network Diagram 🗺️



# 2.0 Ricochet Access🎾

---

1. Generate and Add SSH Keys to Github ([Refer to this doc](https://wiki.raspberrypiclub.org/books/how-to-ssh/page/10-generate-and-add-ssh-keys-to-github))
2. Edit SSH Config File 
    - Navigate to inside the .ssh folder on the user’s system
    - Create a new file called “config” (unless it already exists) and edit it with Notepad 
        - Remove any file extension from the file (e.g. .txt)
    - Enter the following and save the file:

```
Host [NAME]
    HostName raspberrypiclub.org
    User [USER]
    LocalForward 8006 192.168.1.18:8006
    Port 1666
```

3. Import the User's SSH Key ([Refer to this doc](https://wiki.raspberrypiclub.org/books/how-to-ssh/page/20-import-ssh-keys-on-debian-linux))
4. Add a New Proxmox User ([Refer to this doc](https://wiki.raspberrypiclub.org/books/how-to-proxmox/page/20-proxmox-users-and-groups))
5. Access the Proxmox Server ([Refer to this doc](https://wiki.raspberrypiclub.org/books/how-to-ssh/page/30-using-ssh))

# 3.0 Tailscale Setup 💽

---

1. <span style="color: rgb(0, 0, 0);">[Install Tailscale](https://tailscale.com/download) and create an account</span>
2. <span style="color: rgb(0, 0, 0);">Create new Ubuntu Server VM on the Proxmox server *(Refer to* </span>*[Create a VM](https://wiki.raspberrypiclub.org/books/how-to-proxmox/page/30-create-a-vm)* <span style="color: rgb(0, 0, 0);">*in How to: Proxmox)*</span>
3. <span style="color: rgb(0, 0, 0);">Create a Tailscale Connection (Refer to the </span>[doc](https://wiki.raspberrypiclub.org/books/how-to-tailscale/page/20-creating-a-tailscale-connection)<span style="color: rgb(0, 0, 0);">)</span>

# 4.0 Docker 🐋

---

### Docker Swarm IP Table

<div align="left" dir="ltr" id="bkmrk-docker-swarm-nodes-i"><table border="1" style="height: 99.3907px; width: 100%; border-collapse: collapse; background-color: rgb(255, 255, 255); border-width: 1px;"><colgroup><col style="width: 39.6429%;" width="333"></col><col style="width: 39.6429%;" width="333"></col></colgroup><thead><tr style="height: 29.7969px;"><td style="height: 29.7969px;">Docker Swarm Nodes

</td><td style="height: 29.7969px;">IP Addresses

</td></tr></thead><tbody><tr style="height: 29.7969px;"><td style="height: 29.7969px;">Honeybee

</td><td style="height: 29.7969px;">192.168.1.64

</td></tr><tr style="height: 10px;"><td style="height: 10px;">Bumblebee

</td><td style="height: 10px;">192.168.1.65

</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">Masonbee

</td><td style="height: 29.7969px;">192.168.1.66

</td></tr></tbody></table>

</div>1. Test whether or not the user can connect to each Docker swarm: 
    - Click [here](https://wiki.raspberrypiclub.org/books/how-to-docker/page/20-adding-users-to-docker-group) to learn how to add new users to the Docker group

```
ssh PAT@192.168.1.64
ssh PAT@192.168.1.65
ssh PAT@192.168.1.66
```

# 5.0 Setting Up NFS 📁

#### ****Creating and using NFS with Docker****

<span style="color: rgb(0, 0, 0);">Any stack file that you deploy will have at least one service that will need to store static data. This will become a problem when stand-alone methods are used for volume creation, because the volume will not magically transport to whatever node the container gets deployed to. Enter NFS share volumes to the rescue!!</span>

##### ****Step One - Install NFS****

<span style="color: rgb(0, 0, 0);">Make sure that you have installed NFS on the clients/nodes (including manager nodes)</span>

```
sudo apt install nfs-common
```

<span style="color: rgb(0, 0, 0);">On the Ubuntu NAS (gump.lan or 10.10.1.33 is our BMS file server, as of this writing), install the server components as well</span>

```
sudo apt install nfs-kernel-server
```

##### ****Step Two - Using NFS in A Stack****

****Making an NFS Export****

<span style="color: rgb(0, 0, 0);">Then, as an example, we might set up a share like this:</span>

```
sudo mkdir /pools/pool1/mysharename
sudo chown nobody:nogroup /pools/pool1/mysharename
sudo nano /etc/exports
sudo systemctl restart nfs-kernel-server
```

<span style="color: rgb(0, 0, 0);">The /etc/exports line to add our share and publish it would look something like this:</span>

```
/pools/pool1/mysharename     *(rw,sync,no_subtree_check)
```

<span style="color: rgb(0, 0, 0);">Add no\_root\_squash after no\_subtree\_check if the container wants to change ownership on files during runtime.</span>

****Test The Export****

<span style="color: rgb(0, 0, 0);">To check if the export worked, use these commands. If no errors are reported - it worked!</span>

```
sudo mount 10.10.1.33:/pools/pool1/mysharename /mnt
sudo touch /mnt/testfile
sudo rm /mnt/testfile
sudo umount /mnt
```

##### ****Step Three - Usage in a Stackfile****

<span style="color: rgb(0, 0, 0);">Add the following to the stack.yml file in the volumes definition area:</span>

```
letsencrypt:
  driver_opts:
    type: "nfs"
    o: "addr=10.10.1.33,rw,noatime,rsize=8192,wsize=8192,tcp,timeo=14,nfsvers=4"
    device: ":/pools/pool1/mysharename"
```

##### ****Deploy****

<span style="color: rgb(0, 0, 0);">Deploy the stack, this will create the volume and connect it as it deploys. Using Portainer, you can also browse the content.</span>

# 6.0 Monitoring 📹