我对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 create -f dep_prom.yml时
错误:将YAML转换为JSON出错:yaml: 第47行:在此上下文中不允许映射值
第47行是nodeSelector:westporch-kubeminion-1
我认为YAML文件格式是正常的。
是什么导致了这个错误?
westporch-kubeminion-1
。nodeSelector
是一个映射而不是单值字段。 - fishi0x01