0

I have s stateful set which status is showing CrashLoopBackOff. All other components are working fine. When I run kubectl -n magento get po I see pod status in CrashLoopBackOff, and logs show

Initializing database
2020-07-22T11:57:25.498116Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-07-22T11:57:25.499540Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2020-07-22T11:57:25.499578Z 0 [ERROR] Aborting

This is the Kubernetes manifest:

apiVersion: v1
kind: Service
metadata:
  name: db
  labels:
    app: db
    k8s-app: magento
spec:
  selector:
    app: db
  ports:
  - name: db
    port: 3306

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: db
  namespace: magento
spec:
  selector:
    matchLabels:
      app: db
  serviceName: db
  template:
    metadata:
      labels:
        app: db
        k8s-app: magento
    spec:
      containers:
      - args:
        - --max_allowed_packet=134217728
        volumeMounts:
        - mountPath: /var/lib/mysql
          name: data
        env:
        - name: MYSQL_DATABASE
          valueFrom:
            configMapKeyRef:
              name: config
              key: DB_NAME
        - name: MYSQL_PASSWORD
          valueFrom:
            configMapKeyRef:
              name: config
              key: DB_PASS
        - name: MYSQL_USER
          valueFrom:
            configMapKeyRef:
              name: config
              key: DB_USER
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            configMapKeyRef:
              name: config
              key: DB_ROOT_PASS
        image: percona:5.7
        name: db
        resources:
          requests:
            cpu: 100m
            memory: 256Mi
      restartPolicy: Always
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 10Gi
derkoe
  • 5,649
  • 2
  • 23
  • 31
  • Seems you are using a volume `/var/lib/mysql` and when your container is trying to start, there are already files there. Most probably you need to set it in advance otherwise every new startup will try to initialize and fall. – Sergio Santiago Jul 22 '20 at 12:23
  • The error has now changed to following when I added argts to ignore lost+found Initializing database mysqld: Can't create/write to file '/var/lib/mysql/is_writable' (Errcode: 13 - Permission denied) 2020-07-22T13:57:01.533730Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2020-07-22T13:57:01.535256Z 0 [ERROR] --initialize specified but the data directory exists and is not writable. Aborting. 2020-07-22T13:57:01.535269Z 0 [ERROR] Aborting –  Jul 22 '20 at 14:03
  • Now it seems a permission issue. Maybe lack of permission in this folder? – Sergio Santiago Jul 22 '20 at 19:59
  • Check this link https://stackoverflow.com/q/54507881/1563297 – Sergio Santiago Jul 22 '20 at 20:03
  • one of the most probable causes is that it uses `mysql` user to run the container and not the `root` user. Please check permissions for files under `var/lib/mysql` – Nick Jul 23 '20 at 10:28

0 Answers0