Kubectl命令一直返回此錯誤yaml:第2行:此上下文中不允許映射值。即使我調用普通版本命令,配置命令等,不知道是什麼造成這種情況。Kubectl總是返回一個錯誤:yaml:在此上下文中不允許映射值
[email protected]:~$ kubectl version
Client Version: version.Info{Major:"1", Minor:"4",
GitVersion:"v1.4.4",
GitCommit:"3b417cc4ccd1b8f38ff9ec96bb50a81ca0ea9d56",
GitTreeState:"clean", BuildDate:"2016-10-21T02:48:38Z",
GoVersion:"go1.6.3", Compiler:"gc", Platform:"linux/amd64"}
error: yaml: line 2: mapping values are not allowed in this context
[email protected]:~/[some path]$ kubectl create -f kubernetes_configs/frontend.yaml
error: yaml: line 2: mapping values are not allowed in this context
我使用的唯一的yaml文件是
apiVersion: v1
kind: ReplicationController
metadata:
name: frontend
labels:
name: frontend
spec:
replicas: 3
template:
metadata:
labels:
name: frontend
spec:
containers:
- name: trigger
# Replace with your project ID or use `make template`
image: asia.gcr.io/trigger-backend/trigger-backend
# This setting makes nodes pull the docker image every time before
# starting the pod. This is useful when debugging, but should be turned
# off in production.
imagePullPolicy: Always
ports:
- containerPort: 8080
apiVersion: v1
kind: Service
metadata:
name: frontend
labels:
name: frontend
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
selector:
name: frontend
無論我嘗試用kubectl它返回此錯誤。我該怎麼做才能解決這個問題?
> [email protected]:~/developer/trigger-backend-dev/trigger-backend$
> kubectl get service error: yaml: line 2: mapping values are not
> allowed in this context
的輸出:
strace kubectl version
是here
你應該改正你的YAML。您可能正在使用製表符,刪除這些字符,然後檢查正確的縮進。請用文本替換文章中的屏幕截圖(以便將其編入索引)幷包含YAML文件的相關行(從開頭到第3行)。 – Anthon
yaml文件如何影響「kubectl版本」命令 – StarLord
您是否嘗試過使用這些網址?哪一個看起來像一個破損的YAML文件?破碎文件的內容究竟是什麼? – Anthon