- Notifications
You must be signed in to change notification settings - Fork0
philschatz/nextcloud-kubernetes-pi
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Table of Contents
First, purchase the following:
- a Raspberry Pi 4
- an SD card (8+ Gb but 16+ is preferable)
- optionally at least one hard drive or USB key to store all that data
Note: The extra storage is strongly encouraged because SD cards are not designed to be constantly written to and degrade quickly.
Flash the SD card withRaspberry PI OS Lite
The Lite version is recommended because we will not need a user interface, screen, a web browsers, etc.
The services can optionally be customized by editing the yaml files in./deployments.
Note: If you change any of the usernames or passwords in the yaml files you will need to completelyreset.sh because both the database and nextcloud server read the environment variables only when their data directories are empty.
The installation is mostly automated using theinstall.sh script. So far it has been tested on Ubuntu but Pull Requests are welcome!
In general the steps are:
- Configure SD card (optionally inject WiFi and ssh keys)
- ssh into machine and install OS dependencies
- Install packages that reduce the churn on the SD card
- Install local helpers (k3sup)
- Install k3s
- Verify k3s is up
- Mount storage drive (so SD card lasts longer)
- Deploy apps to k3s
- Start proxy tunnel for Cluster dashboard
- Perform backup
- Uninstall apps
Once the apps are deployed, visithttps://cloud (orhttps://cloud.local orhttps://cloud.lan). Sign in with usernameadmin and passwordpassword unless you changed it earlier.
You can SCP thebackup.sh file to the server and run it to perform a backup.
It backs up the following:
- the Postgres database for nextcloud
- all volumes in the cluster
- the k8s configuration (including secrets and keys)
To optionally back up the SD card perform the following:
- turn off the pi
- remove the SD card and insert it into a laptop
- use the "Disk Utility" to resize the main partition down to around 4Gb. If you skip this then the image will be however large your SD card is
- run
sudo dd status=progress if=/dev/sdX | gzip > cloud-backup.img.gzwhere sdX is your SD card. Sometimes it is/dev/mmcblk0 - run
sudo dd status=progress if=/dev/sdX bs=1M count=5120 | gzip > cloud-backup.img.gzto limit the image size to 5GB (assuming you shrunk it in the Disk Utility)https://stackoverflow.com/a/26909977 - resize the partition back to the full size using the "Disk Utility"
Install the following Nextcloud Apps by clicking your login on the top-right and then clicking "Apps":
Then, on your Android phone, install the following:
- NextCloud
- DAVx5 andconfiguration instructions
- Etar Calendar
- Tasks
- Notes
- Set yourseedvault backup to use nextcloud too!
- Passman. Instructions because passman needs a root CA and some type of domain (e.g.
.lan):- Ensure
cloud.lanresolves by your router - Copy the tls-root-ca.crt to your Android phone's "Download" directory
- On android, visit Settings -> Security -> Encryption & Credentials -> Install a certificate -> CA certificate
- select the tls-root-ca.crt file
- In Passman, use the URL
cloud.lan/nextcloud - To debug:
- To verify the root CA works, try visitinghttps://cloud.lan in Chromium. You should not need to accept a certificate
- use
adb logcatto view client logs andtail -f ./data/nextcloud.logby clickingExecon anextcloud-serverinstance in the Kuberneted Dashboard (run theproxycommand in the CLI to start it up) - To use a different TLD other than
.lan, search-and-replace.lanin this repo
- Ensure
(steps)
curl -SLfs https://github.com/OpenMediaVault-Plugin-Developers/installScript/raw/master/install| sudo bash -x# Set the port to something other than 80: https://openmediavault.readthedocs.io/en/5.x/various/advset.htmlomv-firstaidsudo reboot# important for the nfs service to start up
Your phone can connect tohttps://cloud from another location if you have one other machine:
- Enable ssh access to your home network. This usually involves setting up your router to talk to a DDNS provider and then enabling port forwarding on your router to a bastion machine inside your network.
- Forward the port to a local machine:
sudo ssh -i ~/.ssh/id_rsa -L 0.0.0.0:cloud:443 username@myhomeaddress.comThe 0.0.0.0 ensures other devices can see the local port and thesudoallows you to listen to ports below 1024 - Set the hostname of your laptop to be
cloud
There are 4 causes for not finding the cloud:
- the pi is not powered on. Check for a light
- the Operating System is not properly flashed onto the SD card. Plug it into a computer and run the install script.
- The WiFi information is incorrect. Re-run the script or use an ethernet cable to plug the pi directly into the router
Some modern routers do not support local DNS so you may need to associate the namecloud with the IP address your router gives the machine. Here's how it's done with some common routers:
https://www.scivision.dev/raspberry-pi-wifi-avahi/
Use this command tofind all the machines on the network (might need to run a couple of times because of timeouts)nmap -sn 192.168.1.0/24 | grep cloud
This is not super useful but shows all the zeroconf computers on your network:
avahi-browse --all --terminate --resolveerror: yaml: line 30: mapping values are not allowed in this context: Set KUBECONFIG= to the absolute path to thekubeconfigfiles (generated during thek3sup install ...step)- If you see "Service Unavailable" then kubernetes may still be downloading images. Check the dashboard to see the status
- If you see "Bad Gateway" nextcloud may still be starting up (it took 3 minutes for me).
- See the logs in the dashboard by clicking the
nextcloud-server-a1b2c3Pod (not Deployment) and then clicking the Logs button - The logs will end with
AH00163: Apache/2.4.38 (Debian) PHP/7.4.16 configured -- resuming normal operationswhen it is complete
- See the logs in the dashboard by clicking the
- If you get a browser error then try running
ping cloud.local. If there is no answer then use the pis hostname and update thenextcloud-ingress.yamlandnextcloud-server.yamlfiles.
If it does not load up you can view the logs by visiting the k8s dashboard,
photoprism no longer builds 32-bit and 64-bit images under the same name. That means that 64-bit images can be referenced by immutable tags while the 32bit image needs to use thearmv7 tag
photoprism/photoprism:20211203 # This is the last version that works with 32bit and 64bit raspberry piRunphp occ log:watch as thewww-data user. Open a shell to nextcloud-server instance and run:
su www-data -s /bin/bashcs /var/www/html/php occ log:watch # <-- shows stack tracesAbout
Resources
Uh oh!
There was an error while loading.Please reload this page.