K8s create resource yaml error troubleshooting ideas

How to troubleshoot errors when k8s creates yaml

The experience summary
report error content is as follows

[root@k8s-master ~/k8s_1.19_yaml]# kubectl create -f pod-xiangxipeizhi.yaml
error: error validating "pod-xiangxipeizhi.yaml": error validating data: [ValidationError(Pod.spec.containers[0].env): invalid type for io.k8s.api.core.v1.Container.env: got "map", expected "array", ValidationError(Pod.spec.containers[0]): unknown field "imagepullPolicy" in io.k8s.api.core.v1.Container, ValidationError(Pod.spec.containers[0].livenessProbe.httpGet): unknown field "prot" in io.k8s.api.core.v1.HTTPGetAction, ValidationError(Pod.spec.containers[0].livenessProbe.httpGet): missing required field "port" in io.k8s.api.core.v1.HTTPGetAction, ValidationError(Pod.spec.containers[0]): unknown field "nodeName" in io.k8s.api.core.v1.Container, ValidationError(Pod.spec.containers[0].readinessProbe.httpGet): unknown field "prot" in io.k8s.api.core.v1.HTTPGetAction, ValidationError(Pod.spec.containers[0].readinessProbe.httpGet): missing required field "port" in io.k8s.api.core.v1.HTTPGetAction]; if you choose to ignore these errors, turn validation off with --validate=false

analysis of idea:

1. Check line by line

2. Mainly look at the specific prompt information in the curly brackets, you can analyze the specific code configuration problem

Specific investigation

1) The first error point

You can extract the information near the first curly brace where the error is reported. You can see the prompt in the curly braces Pod.spec.containers[0].env. In fact, it also shows that there is an error near env. For details, see whether there is a problem with the configuration of env environment variables in the yaml file.

error: error validating "pod-xiangxipeizhi.yaml": error validating data: 
[ValidationError(Pod.spec.containers[0].env):
invalid type for io.k8s.api.core.v1.Container.env: got "map", expected "array", 

2) The second error point

In the same way, extract the information near the second curly brackets, you can see the specific configuration items prompted in the curly brackets, and the nearby prompts say that imagepullPolicythere is no such parameter, then you can see that the configuration parameters are incorrectly written at a glance

ValidationError(Pod.spec.containers[0]): unknown field "imagepullPolicy" in io.k8s.api.core.v1.Container, 

3) The third error point

In the same way, take out the eight wrong information near the third curly brace, follow the prompts to (Pod.spec.containers[0].livenessProbe.httpGet): unknown field "prot"get the key information, and you can see that the configuration item is wrong.

ValidationError(Pod.spec.containers[0].livenessProbe.httpGet): unknown field "prot" in io.k8s.api.core.v1.HTTPGetAction, 

4) The fourth error point

Follow the prompts, ignore the same prompts, find the error message that you haven't seen before, which is the last one, and then look at the prompt message. This shows r(Pod.spec.containers[0]): unknown field "nodeName"that it cannot be at the same level as the container, and a solution can also be found.

ValidationError(Pod.spec.containers[0]): unknown field "nodeName" in io.k8s.api.core.v1.Container,

Summary: Be sure to look at the output content in detail, specifically look at the curly braces and the prompts of a nearby piece of text. Finally, you can find out how the error occurred.

Guess you like

Origin blog.csdn.net/weixin_44953658/article/details/114463672