Kubectlコマンドは常にこのエラーを返します。yaml:2行目:このコンテキストではマッピング値は許可されません。たとえ私が普通のバージョンのコマンド、configコマンドなどを呼び出すときでも、これを引き起こしていることは分かりません。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ファイルは、このエラーを返すものは何でも、私はkubectlてみてください
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
です。これを解決するにはどうすればよいですか?
> [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
はversionコマンドがすでにロードされるいくつかのデフォルトのYAMLファイルがあることを示すエラーをスローするhere
YAMLを修正する必要があります。タブ文字を使用していて、タブ文字を削除してから、正しいインデントを確認している可能性があります。あなたの記事のスクリーンショットをテキストで置き換えて(索引付けできるように)、YAMLファイルの関連する行を含めてください(最初から少なくとも3行目まで)。 – Anthon
yamlファイルはどのように "kubectl version"コマンドに影響しますか – StarLord
これらのURLを手で試しましたか?どちらが壊れたYAMLファイルのようなものを返しますか?壊れたファイルの内容はどういうものですか? – Anthon