gpt4 book ai didi

json - 解析 loadbalancer.yaml 时出错 : error converting YAML to JSON: yaml: line 4: found character that cannot start any token

转载 作者:行者123 更新时间:2023-12-03 02:21:56 39 4
gpt4 key购买 nike

我使用 kubectl apply -f loadbalancer.yaml 命令运行此 yaml 文件,但收到“错误解析 loadbalancer.yaml:将 YAML 转换为 JSON 时出错:yaml:第 4 行:找到无法启动任何 token 的字符”错误。有谁知道为什么?仅供引用,对于缩进,我使用空格而不是制表符。先谢谢了!

apiVersion: v1
kind: Service
metadata:
name: lbservice
spec:
type: LoadBalancer
selector:
app: server
ports:
- name: server-port
port: 3200
targetPort: 3000
- name: client-port
port: 3300
targetPort: 3001
---
apiVersion: v1
kind: Pod
metadata:
name: server-pod
labels:
app: server
spec:
containers:
- name: server-container
image: tyunlee/infinite:v1
imagePullPolicy: Always
ports:
- containerPort: 3000
nodeSelector:
disktype: ssd
---
apiVersion: v1
kind: Pod
metadata:
name: client-pod
labels:
app: server
spec:
containers:
- name: client-container
image: tyunlee/infinite:v1
imagePullPolicy: Always
ports:
- containerPort: 3001
nodeSelector:
disktype: ssd

最佳答案

前几次我也遇到过类似的问题。解决方案是您必须使用空格而不是制表符(正好两个空格),因为 YAML 不允许使用制表符 (\t)。

查看讨论here ,你会得到更好的理解。

关于json - 解析 loadbalancer.yaml 时出错 : error converting YAML to JSON: yaml: line 4: found character that cannot start any token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68564992/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com