Deploy MySQL on Kubernetes - Task Failed with no reason

I have created all resources but still task got failed also not getting the reason why it is failed. Kindly let me what mistake is there.

Below is my yaml file details.
1.) Create a PersistentVolume mysql-pv, its capacity should be 250Mi, set other parameters as per your preference.
[email protected]_host ~$ cat pv.yml
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv
spec:
storageClassName: manual
capacity:
storage: 250Mi
accessModes:
- ReadWriteMany
hostPath:
path: “/mnt/data”
[email protected]_host ~$

2.) Create a PersistentVolumeClaim to request this PersistentVolume storage. Name it as mysql-pv-claim and request a 250Mi of storage. Set other parameters as per your preference.

[email protected]_host ~$ cat pvc.yml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 250Mi
[email protected]_host ~$

3.) Create a deployment named mysql-deployment, use any mysql image as per your preference. Mount the PersistentVolume at mount path /var/lib/mysql.

apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: mysql-deployment
name: mysql-deployment
spec:
replicas: 2
selector:
matchLabels:
app: mysql-deployment
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: mysql-deployment
spec:
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: mysql-pv-claim
containers:
- image: mysql:latest
name: mysql
resources: {}
volumeMounts:
- mountPath: /var/lib/mysql
name: task-pv-storage
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-root-pass
key: password
- name: MYSQL_DATABASE
valueFrom:
secretKeyRef:
name: mysql-db-url
key: database
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: mysql-user-pass
key: username
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-user-pass
key: password

4.) Create a NodePort type service named mysql and set nodePort to 30007.

[email protected]_host ~$ cat svc.yml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: mysql-deployment
name: mysql
spec:
ports:

  • port: 3306
    protocol: TCP
    targetPort: 3306
    nodePort: 30007
    selector:
    app: mysql-deployment
    type: NodePort
    status:
    loadBalancer: {}

5.) Create a secret named mysql-root-pass having a key pair value, where key is password and its value is YUIidhb667,
create another secret named mysql-user-pass having some key pair values, where frist key is username and its value is kodekloud_rin, second key is password and value is GyQkFRVNr3,
create one more secret named mysql-db-url, key name is database and value is kodekloud_db10

kubectl create secret generic mysql-root-pass --from-literal=password=YUIidhb667
kubectl create secret generic mysql-user-pass --from-literal=username=kodekloud_rin --from-literal=password=GyQkFRVNr3
kubectl create secret generic mysql-db-url --from-literal=database=kodekloud_db10

6.) Define some Environment variables within the container:

a) name: MYSQL_ROOT_PASSWORD, should pick value from secretKeyRef name: mysql-root-pass and key: password

b) name: MYSQL_DATABASE, should pick value from secretKeyRef name: mysql-db-url and key: database

c) name: MYSQL_USER, should pick value from secretKeyRef name: mysql-user-pass key key: username

d) name: MYSQL_PASSWORD, should pick value from secretKeyRef name: mysql-user-pass and key: password

Hi @nithyaks,
If the due date is not yet past, please mark it to review and share the link here.

Regard

Same issue happened for another person. For him they told below reason.
Thanks for reporting this. Looks like some minor glitch. This is marked pending for you, please try this again.

I have given the yaml files and output of resources. All are running state only. Also not showing what error it is so that I can try to fix it. Seems some issue in background. Can someone help on it.

Hi @nithyaks,
Where do you see this?

In Community channel only. " Deploy mysql on kubernetes".

It’s quite an old post, and the KKE team may have already fixed that.

I checked this task and didn’t find any issues.