use statefulSets and readinessProbes instead of initContainers
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: nextcloud-db
|
||||
namespace: tools
|
||||
@@ -8,6 +8,8 @@ spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nextcloud-db
|
||||
serviceName: nextcloud-db
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
@@ -36,9 +38,14 @@ spec:
|
||||
- name: MARIADB_AUTO_UPGRADE
|
||||
value: "1"
|
||||
volumeMounts:
|
||||
- name: nextcloud-db-storage
|
||||
- name: nextcloud-db
|
||||
mountPath: /var/lib/mysql
|
||||
volumes:
|
||||
- name: nextcloud-db-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: nextcloud-db-longhorn
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: nextcloud-db
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 2Gi
|
||||
storageClassName: longhorn
|
||||
|
||||
@@ -1,18 +1,3 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: nextcloud-db-longhorn
|
||||
namespace: tools
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
volumeMode: Filesystem
|
||||
resources:
|
||||
requests:
|
||||
storage: 2Gi
|
||||
storageClassName: longhorn
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
|
||||
@@ -38,7 +38,7 @@ spec:
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nextcloud-db-service
|
||||
name: nextcloud-db
|
||||
namespace: tools
|
||||
spec:
|
||||
selector:
|
||||
@@ -47,3 +47,4 @@ spec:
|
||||
- protocol: TCP
|
||||
port: 3306
|
||||
targetPort: 3306
|
||||
clusterIP: None
|
||||
|
||||
@@ -15,20 +15,18 @@ spec:
|
||||
labels:
|
||||
app: nextcloud
|
||||
spec:
|
||||
initContainers:
|
||||
- name: wait-for-db
|
||||
image: busybox
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
until nc -z -v -w30 nextcloud-db-service 3306; do
|
||||
echo "Waiting for database to be ready..."
|
||||
sleep 2
|
||||
done
|
||||
containers:
|
||||
- name: nextcloud
|
||||
image: lscr.io/linuxserver/nextcloud:32.0.3
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- nc -z nextcloud-db.tools.svc.cluster.local 3306
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
failureThreshold: 3
|
||||
ports:
|
||||
- containerPort: 443
|
||||
env:
|
||||
|
||||
Reference in New Issue
Block a user