Can someone tell me why am I getting this error? The deifinition seems okay as p . . .

debadatta prasad:
Can someone tell me why am I getting this error? The deifinition seems okay as per spec.
root@controlplane:~# cat pod.yml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
containers:
- image: nginx
name: nginx
resources: {}
volumeMounts:
- name: mypvc
mountPath: /var/foo
volumes:
- name: mypvc
ephemeral:
readOnly:
volumeClaimTemplate:
spec:
metadata:
name: mypvc
labels:
app_type: good
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
root@controlplane:~# k create -f pod.yml
error: error validating “pod.yml”: error validating data: ValidationError(Pod.spec.volumes[0].ephemeral.volumeClaimTemplate.spec): unknown field “metadata” in io.k8s.api.core.v1.PersistentVolumeClaimSpec; if you choose to ignore these errors, turn validation off with --validate=false
root@controlplane:~#

Mohamed Ayman:
Check this for the correct syntax for volumeclaimtemplates

https://kubernetes.io/docs/tutorials/stateful-application/_print/|https://kubernetes.io/docs/tutorials/stateful-application/_print/