21

kubectl コマンドは常にこのエラー yaml を返します: line 2: mapping values are not allowed in this context. 通常のバージョンコマンド、configコマンドなどを呼び出しても、何が原因なのかわかりません。

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ファイルは

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で何を試しても、このエラーが返されます。これを解決するにはどうすればよいですか?

> 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

ここにいます

4

5 に答える 5

3

を実行してもエラーが発生するため、デフォルトkubectl versionで にある kubeconfig ファイルに yaml 構文エラーがあると思い~/.kube/configます。

このような yaml バリデーターを使用してコンテンツを検証できます。

于 2016-11-06T11:33:27.150 に答える