This issue has occurred when NextCloud has been upgraded after deployment. Its source docker container may specify an older version as compared to the running instance. This discrepancy will cause the pod to fail to re-create or start as a new container as show below:
# Pod scheduling status yields 'Error'
kimconnect@k8sController:~$ k get pod
NAME READY STATUS RESTARTS AGE
clamav-0 1/1 Running 0 6d23h
collabora-collabora-code-69d74c979f-jp4p2 1/1 Running 0 6d19h
nextcloud-6cf9c65d85-42dx7 1/2 Error 1 6s
nextcloud-db-postgresql-0 1/1 Running 0 7d1h
# Further examination of the problem...
kimconnect@k8sController:~$ k describe pod nextcloud-6cf9c65d85-l9b99
Name: nextcloud-6cf9c65d85-l9b99
Namespace: default
Priority: 0
Node: workder05/10.10.100.95
Start Time: Fri, 20 Aug 2021 23:48:23 +0000
Labels: app.kubernetes.io/component=app
app.kubernetes.io/instance=nextcloud
app.kubernetes.io/name=nextcloud
pod-template-hash=6cf9c65d85
Annotations: cni.projectcalico.org/podIP: 172.16.90.126/32
cni.projectcalico.org/podIPs: 172.16.90.126/32
Status: Running
IP: 172.16.90.126
IPs:
IP: 172.16.90.126
Controlled By: ReplicaSet/nextcloud-6cf9c65d85
Containers:
nextcloud:
Container ID: docker://4c202d2155dea39739db815feae271fb8f14438f44092049f3d55c70fbf819c0
Image: nextcloud:stable-fpm
Image ID: docker-pullable://nextcloud@sha256:641b1dc10b681e1245c6f5d6d366fa1cd7e018ff787cf690c1aa372ddc108671
Port: <none>
Host Port: <none>
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Fri, 20 Aug 2021 23:54:03 +0000
Finished: Fri, 20 Aug 2021 23:54:03 +0000
Ready: False
Restart Count: 6
Environment:
POSTGRES_HOST: nextcloud-db-postgresql.default.svc.cluster.local
POSTGRES_DB: nextcloud
POSTGRES_USER: <set to the key 'db-username' in secret 'nextcloud-db'> Optional: false
POSTGRES_PASSWORD: <set to the key 'db-password' in secret 'nextcloud-db'> Optional: false
NEXTCLOUD_ADMIN_USER: <set to the key 'nextcloud-username' in secret 'nextcloud'> Optional: false
NEXTCLOUD_ADMIN_PASSWORD: <set to the key 'nextcloud-password' in secret 'nextcloud'> Optional: false
NEXTCLOUD_TRUSTED_DOMAINS: kimconnect.com
NEXTCLOUD_DATA_DIR: /var/www/html/data
Mounts:
/usr/local/etc/php-fpm.d/memory_limit from nextcloud-phpconfig (rw,path="memory_limit")
/usr/local/etc/php-fpm.d/post_max_size from nextcloud-phpconfig (rw,path="post_max_size")
/usr/local/etc/php-fpm.d/upload_max_filesize from nextcloud-phpconfig (rw,path="upload_max_filesize")
/usr/local/etc/php-fpm.d/upload_max_size from nextcloud-phpconfig (rw,path="upload_max_size")
/var/run/secrets/kubernetes.io/serviceaccount from default-token-bdhxv (ro)
/var/www/ from nextcloud-data (rw,path="root")
/var/www/html from nextcloud-data (rw,path="html")
/var/www/html/config from nextcloud-data (rw,path="config")
/var/www/html/custom_apps from nextcloud-data (rw,path="custom_apps")
/var/www/html/data from nextcloud-data (rw,path="data")
/var/www/html/themes from nextcloud-data (rw,path="themes")
/var/www/tmp from nextcloud-data (rw,path="tmp")
nextcloud-nginx:
Container ID: docker://1fae573d1a0591058ad55f939b4762f01c7a5f6e7275d2348ff1bd287e077fe5
Image: nginx:alpine
Image ID: docker-pullable://nginx@sha256:e20c21e530f914fb6a95a755924b1cbf71f039372e94ac5ddcf8c3b386a44615
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Fri, 20 Aug 2021 23:48:26 +0000
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/etc/nginx/nginx.conf from nextcloud-nginx-config (rw,path="nginx.conf")
/var/run/secrets/kubernetes.io/serviceaccount from default-token-bdhxv (ro)
/var/www/ from nextcloud-data (rw,path="root")
/var/www/html from nextcloud-data (rw,path="html")
/var/www/html/config from nextcloud-data (rw,path="config")
/var/www/html/custom_apps from nextcloud-data (rw,path="custom_apps")
/var/www/html/data from nextcloud-data (rw,path="data")
/var/www/html/themes from nextcloud-data (rw,path="themes")
/var/www/tmp from nextcloud-data (rw,path="tmp")
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
nextcloud-data:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: nextcloud-claim
ReadOnly: false
nextcloud-phpconfig:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: nextcloud-phpconfig
Optional: false
nextcloud-nginx-config:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: nextcloud-nginxconfig
Optional: false
default-token-bdhxv:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-bdhxv
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 10m default-scheduler Successfully assigned default/nextcloud-6cf9c65d85-l9b99 to linux05
Normal Pulled 10m kubelet Container image "nginx:alpine" already present on machine
Normal Created 10m kubelet Created container nextcloud-nginx
Normal Started 10m kubelet Started container nextcloud-nginx
Normal Created 9m47s (x4 over 10m) kubelet Created container nextcloud
Normal Started 9m46s (x4 over 10m) kubelet Started container nextcloud
Normal Pulled 8m55s (x5 over 10m) kubelet Container image "nextcloud:stable-fpm" already present on machine
Warning BackOff 18s (x51 over 10m) kubelet Back-off restarting failed container
# Checking the logs
kimconnect@k8sController:~$ k logs nextcloud-6cf9c65d85-l9b99 nextcloud
Can't start Nextcloud because the version of the data (21.0.4.1) is higher than the docker image version (20.0.8.1) and downgrading is not supported. Are you sure you have pulled the newest image version?
Solution:
# a. Create a backup copy of version.php
sudo mount $nfsServer:/volume1/nextcloud /mnt/nextcloud
cd /mnt/nextcloud/html
cp version.php version.php.bak
# b. Edit the version.php file with this content
vim version.php
########
# <?php
# $OC_Version = array(21,0,4,1); # change this value to array(20,0,8,1)
# $OC_VersionString = '21.0.4'; # change this value to '20.0.8'
# $OC_Edition = '';
# $OC_Channel = 'stable';
# $OC_VersionCanBeUpgradedFrom = array (
# 'nextcloud' =>
# array (
# '20.0' => true,
# '21.0' => true,
# ),
# 'owncloud' =>
# array (
# '10.5' => true,
# ),
# );
# $OC_Build = '2021-08-03T15:44:43+00:00 c52fea0b16690b492f6c4175e1ae71d488936244';
# $vendor = 'nextcloud';
########
# c. Recreate the failed pod and verify that it's in 'running status'
kimconnect@k8sController:~$ k delete pod nextcloud-6cf9c65d85-l9b99
pod "nextcloud-6cf9c65d85-l9b99" deleted
kimconnect@k8sController:~$ k get pod
NAME READY STATUS RESTARTS AGE
clamav-0 1/1 Running 0 6d23h
collabora-collabora-code-69d74c979f-jp4p2 1/1 Running 0 6d19h
nextcloud-6cf9c65d85-dmg2s 2/2 Running 0 17s
nextcloud-db-postgresql-0 1/1 Running 0 7d1h
# d. Revert changes to version.php
cd /mnt/nextcloud/html
mv version.php version.php.old
mv version.php.bak version.php
Categories: