use statefulSets and readinessProbes instead of initContainers
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: StatefulSet
|
||||||
metadata:
|
metadata:
|
||||||
name: nextcloud-db
|
name: nextcloud-db
|
||||||
namespace: tools
|
namespace: tools
|
||||||
@@ -8,6 +8,8 @@ spec:
|
|||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: nextcloud-db
|
app: nextcloud-db
|
||||||
|
serviceName: nextcloud-db
|
||||||
|
replicas: 1
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
@@ -36,9 +38,14 @@ spec:
|
|||||||
- name: MARIADB_AUTO_UPGRADE
|
- name: MARIADB_AUTO_UPGRADE
|
||||||
value: "1"
|
value: "1"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: nextcloud-db-storage
|
- name: nextcloud-db
|
||||||
mountPath: /var/lib/mysql
|
mountPath: /var/lib/mysql
|
||||||
volumes:
|
volumeClaimTemplates:
|
||||||
- name: nextcloud-db-storage
|
- metadata:
|
||||||
persistentVolumeClaim:
|
name: nextcloud-db
|
||||||
claimName: nextcloud-db-longhorn
|
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
|
apiVersion: v1
|
||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ spec:
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: nextcloud-db-service
|
name: nextcloud-db
|
||||||
namespace: tools
|
namespace: tools
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
@@ -47,3 +47,4 @@ spec:
|
|||||||
- protocol: TCP
|
- protocol: TCP
|
||||||
port: 3306
|
port: 3306
|
||||||
targetPort: 3306
|
targetPort: 3306
|
||||||
|
clusterIP: None
|
||||||
|
|||||||
@@ -15,20 +15,18 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: nextcloud
|
app: nextcloud
|
||||||
spec:
|
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:
|
containers:
|
||||||
- name: nextcloud
|
- name: nextcloud
|
||||||
image: lscr.io/linuxserver/nextcloud:32.0.3
|
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:
|
ports:
|
||||||
- containerPort: 443
|
- containerPort: 443
|
||||||
env:
|
env:
|
||||||
|
|||||||
Reference in New Issue
Block a user