0

I was facing the issue during deployment:

# kubectl apply -f myfile.yaml
error: error validating "myfile.yaml": error validating data: [ValidationError(Deployment): unknown field "\u00a0 name" in io.k8s.api.apps.v1.Deployment, ValidationError(Deployment): unknown field "\u00a0 replicas" in io.k8s.api.apps.v1.Deployment, ValidationError(Deployment): unknown field "\u00a0 \u00a0 app" in io.k8s.api.apps.v1.Deployment, ValidationError(Deployment): unknown field "\u00a0 \u00a0 \u00a0 - name" in io.k8s.api.apps.v1.Deployment, ValidationError(Deployment): unknown field "\u00a0 \u00a0 \u00a0 app" in io.k8s.api.apps.v1.Deployment, ValidationError(Deployment): unknown field "

Trying to validate it with yamllint was no help either:

# yamllint myfile.yaml
myfile.yaml
  1:1       warning  missing document start "---"  (document-start)

2 Answers2

2

The actual deployment file is irrelevant, as I actually found the solution and pasting here for reference.

Turned out the issue is with unicode spaces, which are impossible to spot when checking the file with vi but IMHO should be spotted when checked with yamllint. Anyway converting the file as described in bash - Remove all Unicode Spaces and replace with Normal Space alleviates the issue.

# perl -CSDA -plE 's/\s/ /g' myfile.yaml > myfile2.yaml
# kubectl apply -f myfile2.yaml
deployment.apps/xxx created

Hope that helps someone.

0

There seems to be some invisible special character in your yaml file. I highly recommend to use :set list command of vi/vim editor. Its very useful to spot special characters, especially when you working with kubernetes manifests yaml files.

  • I tried the `:set list` command in vi to spot the issue, but looks like it does not work in that case. Providing the files for reference: https://github.com/rbogusze/oracleinfrastructure/tree/master/scripto/k3s/bad_yaml where `myfile.yaml` is the one with invisible unicode spaces and `myfile2.yaml` is the cleaned version. – remigiusz boguszewicz Jun 26 '20 at 13:15
  • you have a syntax error on line 26. you are missing extra spaces before configMap volumes: - name: html-volume configMap: name: mydog-html – Biganashvili Jun 26 '20 at 15:31