Kubectl get pod shows ErrImageNeverPull mysql

1/9/2022

According to this docu, i try to lunch mysql with kubernetes:

deployment.yml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: kazi-db
spec:
  selector:
    matchLabels:
      app: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
        - image: mysql:5.6
          name: mysql
          imagePullPolicy: Never
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: db-secret
                  key: password
          ports:
            - containerPort: 3306
              name: mysql
          volumeMounts:
            - name: mysql-persistent-storage
              mountPath: /var/lib/mysql
      volumes:
        - name: mysql-persistent-storage
          persistentVolumeClaim:
            claimName: mysql-pv-claim

mysql-storage.yml:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 20Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi

service.yml:

apiVersion: v1
kind: Service
metadata:
  name: kazi-db
spec:
  ports:
    - port: 3306
  selector:
    app: mysql

db-secret.yml:

apiVersion: v1
kind: Secret
metadata:
  name: kazi-db
type: kubernetes.io/basic-auth
stringData:
  password: xcvas

I have registered all with kubectl apply -f ...

The problem when i call kubectl get pod

kazi-db-758b978ccc-7m29n                                        0/1     ErrImageNeverPull   0          4m48s

I have a docker hub with integrated kubernetes

-- emoleumassi
kubectl
kubernetes
mysql

1 Answer

1/9/2022
  • May be thats because of 1. imagePullPolicy is set to "Never" and 2. image: mysql:5.6 does not seem to be present on the worker node where this pod got scheduled.

  • following are the two possible options:

    • Perform a manual pull of the image: mysql:5.6 on all worker nodes using docker pull mysql:5.6
    • change imagePullPolicy to IfNotPresent.
-- confused genius
Source: StackOverflow