将 YAML 转换为 JSON 时出错:yaml:第 13 行:未找到预期的密钥
Error converting YAML to JSON: yaml: line 13: did not find expected key
我正在尝试部署这个 yaml 来为 6 个不同的 grok-exporters 部署创建一个服务,每当我尝试部署这个清单时,我都会在下面看到这个错误:
error converting YAML to JSON: yaml: line 13: did not find expected key and i can't figure out the issue
yaml 清单:
apiVersion: v1
kind: Service
metadata:
name: grok-exporter-centralized-service
spec:
type: ClusterIP
ports:
- name: cluster-autoscaler-grok-exporter-metrics
protocol: TCP
targetPort: 9144
port: 9148
selector:
app: cluster-autoscaler-grok-exporter
- name: evicted-pods-grok-exporter
protocol: TCP
targetPort: 9144
port: 9149
selector:
app: evicted-pods-grok-exporter
- name: flux-hr-grok-exporter
protocol: TCP
targetPort: 9144
port: 9144
selector:
app: flux-hr-grok-exporter
- name: flux-system-grok-exporter
protocol: TCP
targetPort: 9144
port: 9145
selector:
app: flux-system-grok-exporter
- name: ha-proxy-grok-exporter
protocol: TCP
targetPort: 9144
port: 9146
selector:
app: ha-proxy-grok-exporter
- name: spot-requests-grok-exporter
protocol: TCP
targetPort: 9144
port: 9147
selector:
app: spot-requests-grok-exporter
我在这里检查了类似的问题,但不幸的是,我无法使该脚本正常工作,因此非常感谢您的帮助。
谢谢大家!
您的问题是每个 spec.ports
之后都有一些 spec.selector.app
。应该只有一个选择器,端口数组应该列出所有没有中断的端口
apiVersion: v1
kind: Service
metadata:
name: grok-exporter-centralized-service
spec:
type: ClusterIP
ports:
- name: cluster-autoscaler-grok-exporter-metrics
protocol: TCP
targetPort: 9144
port: 9148
- name: evicted-pods-grok-exporter
protocol: TCP
targetPort: 9144
port: 9149
- name: flux-hr-grok-exporter
protocol: TCP
targetPort: 9144
port: 9144
- name: flux-system-grok-exporter
protocol: TCP
targetPort: 9144
port: 9145
- name: ha-proxy-grok-exporter
protocol: TCP
targetPort: 9144
port: 9146
- name: spot-requests-grok-exporter
protocol: TCP
targetPort: 9144
port: 9147
selector:
app: spot-requests-grok-exporter
第二次:假设我们想要一个指向多个导出器的服务,由不同的部署驱动。并且所有这些出口商都将在同一个端口上监听,9144
。
除了在您的部署上配置的当前标签之外,我们还会添加一个新标签,在所有这些导出器/部署之间共享。说 foo=bar
.
现在,我可以创建一个“导出器”服务,其端点将指向我的所有导出器端口:
apiVersion: v1
kind: Service
metadata:
name: generic-exporter
spec:
type: ClusterIP
ports:
- name: generic-exporter
protocol: TCP
targetPort: 9144
port: 9144
selector:
foo: bar
我正在尝试部署这个 yaml 来为 6 个不同的 grok-exporters 部署创建一个服务,每当我尝试部署这个清单时,我都会在下面看到这个错误:
error converting YAML to JSON: yaml: line 13: did not find expected key and i can't figure out the issue
yaml 清单:
apiVersion: v1
kind: Service
metadata:
name: grok-exporter-centralized-service
spec:
type: ClusterIP
ports:
- name: cluster-autoscaler-grok-exporter-metrics
protocol: TCP
targetPort: 9144
port: 9148
selector:
app: cluster-autoscaler-grok-exporter
- name: evicted-pods-grok-exporter
protocol: TCP
targetPort: 9144
port: 9149
selector:
app: evicted-pods-grok-exporter
- name: flux-hr-grok-exporter
protocol: TCP
targetPort: 9144
port: 9144
selector:
app: flux-hr-grok-exporter
- name: flux-system-grok-exporter
protocol: TCP
targetPort: 9144
port: 9145
selector:
app: flux-system-grok-exporter
- name: ha-proxy-grok-exporter
protocol: TCP
targetPort: 9144
port: 9146
selector:
app: ha-proxy-grok-exporter
- name: spot-requests-grok-exporter
protocol: TCP
targetPort: 9144
port: 9147
selector:
app: spot-requests-grok-exporter
我在这里检查了类似的问题,但不幸的是,我无法使该脚本正常工作,因此非常感谢您的帮助。
谢谢大家!
您的问题是每个 spec.ports
之后都有一些 spec.selector.app
。应该只有一个选择器,端口数组应该列出所有没有中断的端口
apiVersion: v1
kind: Service
metadata:
name: grok-exporter-centralized-service
spec:
type: ClusterIP
ports:
- name: cluster-autoscaler-grok-exporter-metrics
protocol: TCP
targetPort: 9144
port: 9148
- name: evicted-pods-grok-exporter
protocol: TCP
targetPort: 9144
port: 9149
- name: flux-hr-grok-exporter
protocol: TCP
targetPort: 9144
port: 9144
- name: flux-system-grok-exporter
protocol: TCP
targetPort: 9144
port: 9145
- name: ha-proxy-grok-exporter
protocol: TCP
targetPort: 9144
port: 9146
- name: spot-requests-grok-exporter
protocol: TCP
targetPort: 9144
port: 9147
selector:
app: spot-requests-grok-exporter
第二次:假设我们想要一个指向多个导出器的服务,由不同的部署驱动。并且所有这些出口商都将在同一个端口上监听,9144
。
除了在您的部署上配置的当前标签之外,我们还会添加一个新标签,在所有这些导出器/部署之间共享。说 foo=bar
.
现在,我可以创建一个“导出器”服务,其端点将指向我的所有导出器端口:
apiVersion: v1
kind: Service
metadata:
name: generic-exporter
spec:
type: ClusterIP
ports:
- name: generic-exporter
protocol: TCP
targetPort: 9144
port: 9144
selector:
foo: bar