error converting YAML to JSON
kubectl turns each manifest into JSON before it sends it to the API server. When the YAML does not parse, that step fails, and the real cause is the text after the last colon.
Reading the message
The error has three parts. The first two are always the same. Only the end changes.
error: error converting YAML to JSON: yaml: line 7: found character that cannot start any token
error converting YAML to JSON says the file is not valid YAML. line 7 is where the parser gave up, which can be one line after the actual mistake. The last part names the problem.
The common endings
found character that cannot start any token: a tab used as indentation, or a value that starts with@or a backtick. See Found character that cannot start any token.mapping values are not allowed in this context: an unquoted value that contains:, or a key indented under a value. See Mapping values are not allowed here.did not find expected key: usually a line that does not line up with its siblings, often a list item undercontainersorenv, or a quoted value followed by more text.could not find expected ':': a key without its colon, or a plain value that was continued on the next line at the wrong indent.
The example
The second item under containers is indented one space less than the first.
spec:
containers:
- name: app
image: nginx
- name: sidecarThe Kubernetes YAML check reports Document 1: A block sequence may not be used as an implicit map key at line 5, column 1. Move - name: sidecar right by one space so its dash sits under the first dash.
Files with more than one document
A manifest can hold several resources separated by ---. kubectl parses them one at a time, and the line in its message can be counted from the start of that resource rather than the start of the file. ConfigKit names the document and counts lines from the top of the file, so Document 2 at line 7 means line 7 of what you pasted.
The edge case
Valid YAML can still be rejected by Kubernetes. This passes every YAML check, because 8080 is a valid number:
env:
- name: PORT
value: 8080The API server expects value to be a string and refuses the number. Quote it as "8080". ConfigKit checks syntax only. It does not know which fields a Deployment or Service needs, so run kubectl apply --dry-run=server -f manifest.yaml against a cluster to check the fields as well.
Paste the manifest into the Kubernetes YAML check to find the line, or into YAML to JSON to see the JSON kubectl would build from a single document.