Kubernetes task error -mysql-deploymet.yml

Hi Team,
I have been trying to fix the issues with mysqk_deployment.yml , hwever the task failed with the objects not existing error.
I could see all the volumes n containers existing as is and in running state

@Inderpreet @mmumshad @rahul456

hi @akhila , can you please share your yml template ?

@Inderpreet @rahul456 @mmumshad
the task validation
This looks like an error in
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv
labels:
app: mysql-app
spec:
storageClassName: standard
capacity:
storage: 250Mi
accessModes:
- ReadWriteOnce
hostPath:
path: /mnt/data
persistentVolumeReclaimPolicy: Retain

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
labels:
app: mysql-app
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 250Mi

apiVersion: v1
kind: Service
metadata:
name: mysql
labels:
app: mysql-app
spec:
type: NodePort
ports:
- targetPort: 3306
port: 3306
nodePort: 30011
selector:
app: mysql-app
tier: mysql

apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-deployment
labels:
app: mysql-app
spec:
selector:
matchLabels:
app: mysql-app
tier: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql-app
tier: mysql
spec:
containers:
- image: mysql:5.6
name: mysql
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
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-pv
mountPath: /var/lib/mysql
volumes:
- name: mysql-pv
persistentVolumeClaim:
claimName: mysql-pv-claimstrong text

Hi,
I am also facing similar error. unable to create deployment file.
#############
thor@jump_host ~$ kubectl apply -f deploy.yaml
error: error parsing deploy.yaml: error converting YAML to JSON: yaml: line 40: did not find expected key
thor@jump_host ~$ cat deploy.yaml | grep -A 6 MYSQL_DATABASE
- name: MYSQL_DATABASE
valueFrom:
secretKeyRef:
name: mysql-db-url
key: database
ports:
- containerPort: 3306
thor@jump_host ~$ kubectl get secret mysql-db-url -o yaml
apiVersion: v1
data:
database: a29kZWtsb3VkX2RiNQ==
kind: Secret
metadata:
#############

Any one knows what else could be the error about this " did not find expected key"

Please check in line 40.

Can you please take help from this k8s docs example?
Check the alignment —

    env:
      - name: MYSQL_DATABASE
        valueFrom:
          secretKeyRef:
            name: mysql-db-url
            key: database

Hi,
The section which I provided is correctly alignment. The reason why it showing without any alignmnet is due to the usage of ‘cat’ in my query. I have found the issue,
section port was not aligned with container section and is fixed now.
Thank you