问题描述
Kubectl命令始终返回以下错误yaml:第2行:在此上下文中不允许使用映射值.即使当我调用普通版本命令,配置命令等时,也不知道是什么原因引起的.
Kubectl command alway returns this error yaml: line 2: mapping values are not allowed in this context. Even when i call normal version command, config command, etc. Not sure whats causing this.
tessact@tessact-sys-1:~$ 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
tessact@tessact-sys-1:~/[some path]$ kubectl create -f kubernetes_configs/frontend.yaml
error: yaml: line 2: mapping values are not allowed in this context
我使用的唯一Yaml文件是
The only yaml file i used is
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 ,它都会返回此错误.我应该怎么做才能解决这个问题?
Whatever I try with kubectl it returns this error. What should I do to solve this?
> tessact@tessact-sys-1:~/developer/trigger-backend-dev/trigger-backend$
> kubectl get service error: yaml: line 2: mapping values are not
> allowed in this context
的输出:
strace kubectl version
在此处
推荐答案
版本命令已引发错误,表明有一些默认的YAML文件正在加载.
That the version command already throws an error indicates that there is some default YAML file that gets loaded.
您可以使用strace kubectl version
来查看打开了什么文件,希望可以在kubectl
引发错误之前完成此操作.我假设它读取了一些全局配置(或者是您当前目录中的默认文件).
You can use strace kubectl version
to see what file was opened, hopefully this is done just before kubectl
throws the error. I assume there is some global config that it reads (or alternatively a default file in your current directory).
当然,在Kubernetes中草率编程不能捕捉到这样的错误,并显示文件名,然后重新引发该错误.
It is of course sloppy programming in kubernetes not to catch such an error, and display the name of the file, and then re-raise the error.
这篇关于Kubectl始终返回错误:yaml:在此上下文中不允许映射值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!