<p>I created .yaml file to create mysql service on kubernetes for my internal application, but it's unreachable. I can reach application and also phpmyadmin to reach database but it's not working properly. I'm stuck with pending status on mysql pod.</p>
<p>.yaml file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
  namespace: cust
  labels:
    app: db
spec:
  replicas: 1
  selector:
    matchLabels:
      app: db
  template:
    metadata:
      labels:
        app: db
    spec:
      containers:
      - name: mysql
        image: mysql
        imagePullPolicy: Never
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: flaskapi-cred
              key: db_root_password
        ports:
        - containerPort: 3306
          name: db-container
        volumeMounts:
          - name: mysql-persistent-storage
            mountPath: /var/lib/mysql
      volumes:
        - name: mysql-persistent-storage
          persistentVolumeClaim:
            claimName: mysql-pv-claim


---
apiVersion: v1
kind: Service
metadata:
  name: mysql
  namespace: cust
  labels:
    app: db
spec:
  ports:
  - port: 3306
    protocol: TCP
    name: mysql
  selector:
    app: db
  type: LoadBalancer
</code></pre>
<p>kubectl get all output is:</p>
<pre><code>NAME                                         READY   STATUS    RESTARTS   AGE
pod/flaskapi-deployment-59bcb745ff-gl8xn     1/1     Running   0          117s
pod/mysql-99fb77bf4-sbhlj                    0/1     Pending   0          118s
pod/phpmyadmin-deployment-5fc964bf9d-dk59t   1/1     Running   0          118s

NAME                                    READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/flaskapi-deployment     1/1     1            1           117s
deployment.apps/mysql                   0/1     1            0           118s
deployment.apps/phpmyadmin-deployment   1/1     1            1           118s
</code></pre>
<p>I already did docker pull mysql.</p>
<p>Edit</p>
<pre><code>Name:           mysql-99fb77bf4-sbhlj
Namespace:      z2
Priority:       0
Node:           &lt;none&gt;
Labels:         app=db
                pod-template-hash=99fb77bf4
Annotations:    &lt;none&gt;
Status:         Pending
IP:
IPs:            &lt;none&gt;
Controlled By:  ReplicaSet/mysql-99fb77bf4
Containers:
  mysql:
    Image:      mysql
    Port:       3306/TCP
    Host Port:  0/TCP
    Environment:
      MYSQL_ROOT_PASSWORD:  &lt;set to the key 'db_root_password' in secret 'flaskapi-secrets'&gt;  Optional: false
    Mounts:
      /var/lib/mysql from mysql-persistent-storage (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-gmbnd (ro)
Conditions:
  Type           Status
  PodScheduled   False
Volumes:
  mysql-persistent-storage:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  mysql-pv-claim
    ReadOnly:   false
  default-token-gmbnd:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-gmbnd
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  &lt;none&gt;
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason            Age    From               Message
  ----     ------            ----   ----               -------
  Warning  FailedScheduling  3m44s  default-scheduler  persistentvolumeclaim &quot;mysql-pv-claim&quot; not found
  Warning  FailedScheduling  3m44s  default-scheduler  persistentvolumeclaim &quot;mysql-pv-claim&quot; not found
</code></pre>

<p>you are missing the volume to attach with the pod or deployment. PVC is required as your deployment configuration is using it.</p>
<p><strong>you can see clearly : persistentvolumeclaim &quot;mysql-pv-claim&quot; not found</strong></p>
<p>you can apply below YAML and try.</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 20Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: &quot;/mnt/data&quot;
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
</code></pre>
