--- apiVersion: v1 data: init.sql: | drop database if exists nextcloud; create database nextcloud default character set utf8 collate utf8_bin; create user 'nextcloud'@'%' identified by 'nextcloud'; grant all on nextcloud.* to 'nextcloud'@'%'; flush privileges; kind: ConfigMap metadata: name: nextcloud-init namespace: kube-public --- apiVersion: apps/v1 kind: StatefulSet metadata: name: nextcloud-mariadb namespace: kube-public labels: app: nextcloud-mariadb spec: replicas: 1 selector: matchLabels: app: nextcloud-mariadb # strategy: # rollingUpdate: # maxSurge: 0 # maxUnavailable: 1 # type: RollingUpdate template: metadata: labels: app: nextcloud-mariadb spec: terminationGracePeriodSeconds: 60 containers: - name: nextcloud-mariadb image: harbor.uenpay.com/base/mariadb:10.5 #image: mariadb:10.5 imagePullPolicy: IfNotPresent ports: - containerPort: 3306 lifecycle: postStart: exec: command: ["/bin/sh", "-c", "mysql -u root -p${MYSQL_ROOT_PASSWORD} < /docker-entrypoint-initdb.d/init.sql"] env: - name: MYSQL_ROOT_PASSWORD value: nextcloud - name: MYSQL_LOG_CONSOLE value: "true" readinessProbe: tcpSocket: port: 3306 initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 30 failureThreshold: 10 livenessProbe: tcpSocket: port: 3306 initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 3 failureThreshold: 1 resources: limits: cpu: 1 memory: 2Gi requests: cpu: 200m memory: 500Mi volumeMounts: - name: init-scripts mountPath: /docker-entrypoint-initdb.d - name: data mountPath: /var/lib/mysql volumes: - name: init-scripts configMap: name: nextcloud-init items: - key: init.sql path: init.sql volumeClaimTemplates: - metadata: name: data spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 30Gi --- apiVersion: v1 kind: Service metadata: name: nextcloud-mariadb namespace: kube-public labels: app: nextcloud-mariadb spec: selector: app: nextcloud-mariadb ports: - name: nextcloud-mariadb port: 3306 protocol: TCP