Background

Today I upgrading my Nextcloud server from version 18 to 19 by simply changing the Docker image version tag like so:

kubectl --record deployment.apps/nextcloud set image deployment.v1.apps/nextcloud nextcloud=nextcloud:19.0.0-apache

After waiting for my Nextcloud pod to start I got a 503 error from Nginx. Hmm I thought, this must be a secrets issue since I usually update the deployment using the following command:

kubectl apply -k ./

I therefore updated the version tag for the Nextcloud image in my YAML file and ran that command and waited for the pod to start. Once I did I saw that my site was in maintenance mode.

Hmm, ok let’s look at the logs. Nothing. Uhhhh, now what?

Solution

I learned that you can turn on maintenance mode in Nextcloud by running an occ command from inside the Nextcloud pod. How does one do that you say?

First, install the Krew plugin for kubectl. This allows you to easily install other plugins, the exec-as plugin. This plugin makes it easy to execute commands within Kubernetes-managed containers as a non-root user.

So first I “tunneled into” my Nextcloud container by running this command:

NC_POD=$(kubectl get pods | grep nextcloud | grep -vi mysql | grep -v svclb | awk '{print $1}')
kubectl exec -it "$NC_POD" -- bash

I’m in! Next I tried turning off maintenance mode like so:

cd /var/www/html
./occ maintenance:mode --off

When I did I got the following response:

Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Maintenance mode disabled

What a great error message! At this point it was clear that the upgrade was not yet done. There’s hope of fixing this thing!

I therefore ran the following command while I was still inside that shell:

./occ upgrade

After this completed successfully I was then able to login!

Even More Scripts!

Naturally, the first thing I did after logging in was to visit this page:

There I saw that I was supposed to run the following scripts:

  • occ db:add-missing-indices
  • occ db:add-missing-columns

I ran those within my pod’s shell again and the upgrade was complete. I then checked the following page to make sure that I covered everything:

Good luck with your upgrade!