【排错】error: error parsing recommended.yaml: error converting YAML to JSON: yaml: line 14:的解决方式

在部署k8s的时候,编写k8s的dashboard文件,遇到以下错误,

error: error parsing recommended.yaml: error converting YAML to JSON: yaml: line 14: could not find expected ':'

一查说是缩进的问题,我看了下指南

【排错】error: error parsing recommended.yaml: error converting YAML to JSON: yaml: line 14:的解决方式_第1张图片

 又看看我的yaml文件

【排错】error: error parsing recommended.yaml: error converting YAML to JSON: yaml: line 14:的解决方式_第2张图片

缩进也没问题

重新运行了一次

[root@k8s-master ~]# kubectl apply -f recommended.yaml
namespace/kubernetes-dashboard unchanged
serviceaccount/kubernetes-dashboard unchanged
error: error parsing recommended.yaml: error converting YAML to JSON: yaml: line 14: could not find expected ':'
 

 还是一样的错误,我又查了一下,会不会是空格的问题。因为看到其他地方冒号之后,都有一个空格。

【排错】error: error parsing recommended.yaml: error converting YAML to JSON: yaml: line 14:的解决方式_第3张图片

 改了之后再跑

[root@k8s-master ~]# kubectl apply -f recommended.yaml
namespace/kubernetes-dashboard unchanged
serviceaccount/kubernetes-dashboard unchanged
service/kubernetes-dashboard configured
secret/kubernetes-dashboard-certs unchanged
secret/kubernetes-dashboard-csrf configured
Warning: resource secrets/kubernetes-dashboard-key-holder is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
secret/kubernetes-dashboard-key-holder configured
configmap/kubernetes-dashboard-settings unchanged
role.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
deployment.apps/kubernetes-dashboard unchanged
service/dashboard-metrics-scraper unchanged
deployment.apps/dashboard-metrics-scraper unchanged
 

运行成功了,果然是空格的问题 

你可能感兴趣的:(教程,排错,指南,运维,docker,kubernetes,yaml)