Lighting Lab - Question 5

Q: A new deployment called alpha-mysql has been deployed in the alpha namespace. However, the pods are not running. Troubleshoot and fix the issue. The deployment should make use of the persistent volume alpha-pv to be mounted at /var/lib/mysql and should use the environment variable MYSQL_ALLOW_EMPTY_PASSWORD=1 to make use of an empty root password.
Important: Do not alter the persistent volume.

controlplane ~ ➜ k get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
alpha-pv 1Gi RWO Retain Available slow 87s

controlplane ~ ➜ k get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
alpha-claim Pending

controlplane ~ ➜ k describe deployments.apps alpha-mysql

Mounts:
/var/lib/mysql from mysql-data (rw)
Volumes:
mysql-data:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: mysql-alpha-pvc
ReadOnly: false

Seems logical to change the claimName to the provided PVC alpha-claim. When I edit this and change the ClaimName: alpha-claim it throws no errors. I then wait for the pod to recreate or even if I delete them and they recreate I still have the error : 0/2 nodes are available: 2 persistentvolumeclaim “mysql-alpha-pvc” not found.
Where is this hiding? What am I missing?

Best Regards

Hello johdaniels,
the error is 0/2 nodes are available: 2 persistentvolumeclaim “mysql-alpha-pvc” not found. preemption: 0/2 nodes are available: 2 Preemption is not helpful for scheduling. So, you have to create a PVC called mysql-alpha-pvc, not alpha-claim. Check the full yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-alpha-pvc
  namespace: alpha
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: slow

Thanks for the response.
So it is more correct to create a new PVC than change the claimName for the pods?

when you create the right PVC, it will be attached to the pods automatically.