2017-06-02 13 views
0

私はYAML形式とkubernetesに関する初心者です。このコンテキストではマッピング値は許可されていません

以下は、dep_prom.ymlファイルです。しかし

--- 
apiVersion: extensions/v1beta1 
kind: Deployment 
metadata: 
    labels: 
    name: prometheus-deployment 
    name: prometheus 
    #namespace: prometheus 
spec: 
    replicas: 1 
    template: 
    metadata: 
     labels: 
     app: prometheus 
    spec: 
     containers: 
     - image: prom/prometheus:master 
     name: prometheus 
     command: 
     - "/bin/prometheus" 
     args: 
     - "-config.file=/etc/prometheus/prometheus.yml" 
     - "-storage.local.path=/prometheus" 
     - "-storage.local.retention=24h" 
     ports: 
     - containerPort: 9090 
      protocol: TCP 
     volumeMounts: 
     - mountPath: "/prometheus" 
      name: data 
     - mountPath: "/etc/prometheus" 
      name: config-volume 
     resources: 
      requests: 
      cpu: 100m 
      memory: 100Mi 
      limits: 
      cpu: 500m 
      memory: 2500Mi 
     volumes: 
     - name: data 
     hostPath: 
      path: /data/prometheus 
     - name: config-volume 
     configMap: 
      name: prometheus 
     nodeSelector: westporch-kubeminion-1 
     kubernetes.io/hostname: 10.0.24.52 
--- 

...私は-f dep_prom.ymlに

エラー作成kubectl を実行:JSONにYAMLの変換エラー:YAMLを:行47:マッピング値は、このコンテキストでは許可されません私はYAMLファイル形式がnであることを考えるwestporch-kubeminion-1

ライン47はnodeSelectorですormal。

私にいくつかアドバイスをください。

ありがとうございました。

+1

「westporch-kubeminion-1」を削除してください。 'nodeSelector'はマップであり、単一の値フィールドではありません。 – fishi

+0

[Kubectlの重複の可能性は常にエラーを返します:yaml:このコンテキストではマッピング値は許可されていません](https://stackoverflow.com/questions/40435173/kubectl-always-returns-a-error-yaml-mapping-values -are-not-allowed-in-this-con) – Anthon

答えて

0

前述のように、nodeSelectorにはそのような値を設定することはできません。これは、キーと値のペアのマップを指定することです。具体的な用途については、hereをご覧ください。例えば、nodeSelectorの適切な使用法は次のようになります。

nodeSelector: 
     disktype: ssd 
1

デフォルトでは、「kubernetes.io/hostnameは」ノードの名前の代わりに、そのIPアドレスが含まれていwell known labelです。これは$ kubectl get nodes --show-labelsを実行して確認できます。したがって、次の変更を行うことをお勧めします。

nodeSelector: 
    kubernetes.io/hostname: westporch-kubeminion-1 
関連する問題