error parsing deployment-nginx.yml: error converting YAML to JSON: yaml: line 19 问题解决
·
使用yml文件创建deployment类型的pod时,执行命令报错如下:
error: error parsing deployment-nginx.yml: error converting YAML to JSON: yaml: line 19: did not find expected key
yml文件如下:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: test
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
报错说19行有问题
应该是缩进的问题,于是修改了最后几行的缩进
再次创建
修改后的yml文件
1 apiVersion: apps/v1
2 kind: Deployment
3 metadata:
4 name: nginx-deployment
5 namespace: test
6 labels:
7 app: nginx
8 spec:
9 replicas: 3
10 selector:
11 matchLabels:
12 app: nginx
13 template:
14 metadata:
15 labels:
16 app: nginx
17 spec:
18 containers:
19 - name: nginx
20 image: nginx
21 ports:
22 - containerPort: 80
总结:
属于yml文件格式问题,k8s对于yml/yaml文件格式要求严格,缩进字符数一定要仔细。
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐




所有评论(0)