我是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
---
然而...當我執行kubectl創建-f dep_prom.yml
錯誤:誤差變換YAML到JSON:YAML:線47:映射值不允許在此上下文中
47號線是nodeSelector:westporch-kubeminion-1
我認爲YAML文件格式爲n ormal。
給我一些建議。
謝謝。
刪除'westporch-kubeminion-1'。 'nodeSelector'是一個映射,而不是一個單獨的值字段。 – fishi
[Kubectl總是返回一個錯誤:yaml:在此上下文中不允許映射值]的可能重複(https://stackoverflow.com/questions/40435173/kubectl-always-returns-a-error-yaml-mapping-values -are-不被允許功能於這個-CON) – Anthon