error validating data: [ValidationError(Pod): unknown field "containers" in io.k8s.api.core.v1.Pod
12,120
I am not sure about the exact issue but it got resolved with proper space indentation
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx
It worked for me now with proper spaces. Mybad
Related videos on Youtube
Author by
Rocky Hai
Updated on June 04, 2022Comments
-
Rocky Hai almost 2 years
I am trying to create some sample kubernetes pod file.
cat << EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx EOF
But on executing this I am getting below error.
error: error validating "pod.yaml": error validating data: [ValidationError(Pod): unknown field "containers" in io.k8s.api.core.v1.Pod, ValidationError(Pod): unknown field "na me" in io.k8s.api.core.v1.Pod]; if you choose to ignore these errors, turn validation off with --validate=false
-
Shudipta Sharma over 5 yearsIf the exact format you have presented in the statement is true, then I have to say that the problem is in the format. See kubernetes.io/docs/concepts/workloads/pods/pod-overview/….
-
Rocky Hai over 5 yearsThanks @ShudiptaSharma. Its the issue with format. After observing the error for sometime i came to know it is clearly displaying that which fields in pod are not in right space indentation. Oberservation helps :)
-
-
Anthon over 5 yearsBoth version are valid YAML documents. In your question
spec
is a key in the root level mapping of the YAML file and has the value null, similarcontainers
is a key in that same mapping with as value a list with one entry. In your answer the the value forspec
is a mapping which has a keycontainers
. As Kubernetes doesn't know about a root level keycontainers
, it throws an error.