error parsing deployment-nginx.yml: error converting YAML to JSON: yaml: line 19 问题解决

简介: 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

1a9527e82f8b4c629a97165c0faafec6.png

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行有问题

7578bef1660c423fafe1c2751930600f.png

应该是缩进的问题,于是修改了最后几行的缩进

48183168c74e4d3cb182e04c90f7f022.png

再次创建

d88764ae9bb34b3db2af0d015b7d155d.png

修改后的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文件格式要求严格,缩进字符数一定要仔细。

相关文章
|
6月前
|
监控 数据挖掘 API
快应用报错Module Error 分包要求 app.json#minPlatformVersion 不小于 1061, 当前值为 21解决方案-优雅草卓伊凡
快应用报错Module Error 分包要求 app.json#minPlatformVersion 不小于 1061, 当前值为 21解决方案-优雅草卓伊凡
177 0
|
JSON 数据格式
Uncaught SyntaxError: JSON.parse: expected property name or '}' at line 1 column 14 of the JSON data问题如何处理
【6月更文挑战第15天】Uncaught SyntaxError: JSON.parse: expected property name or '}' at line 1 column 14 of the JSON data问题如何处理
792 5
|
JSON 数据格式
Uncaught SyntaxError: JSON.parse: expected property name or '}' at line 1 column 14 of the JSON data问题处理
【5月更文挑战第14天】Uncaught SyntaxError: JSON.parse: expected property name or '}' at line 1 column 14 of the JSON data问题处理
701 0
|
Kubernetes 应用服务中间件 nginx
k8s学习--YAML资源清单文件托管服务nginx
k8s学习--YAML资源清单文件托管服务nginx
378 2
k8s学习--YAML资源清单文件托管服务nginx
|
网络协议 应用服务中间件 nginx
FFmpeg错误笔记(一):nginx-rtmp-module推流出现 Server error: Already publishing
这篇文章讨论了在使用nginx-rtmp-module进行RTMP推流时遇到的“Server error: Already publishing”错误,分析了错误原因,并提供了详细的解决办法,包括修改nginx配置文件和终止异常的TCP连接。
715 0
FFmpeg错误笔记(一):nginx-rtmp-module推流出现 Server error: Already publishing
|
应用服务中间件 nginx
nginx error日志 client intended to send too large body: 1434541 bytes 如何处理?
【8月更文挑战第27天】nginx error日志 client intended to send too large body: 1434541 bytes 如何处理?
1043 6
|
JSON 前端开发 JavaScript
JSON parse error: Cannot deserialize value of type `java.lang.Integer` from Boolean value
这篇文章讨论了前端Vue应用向后端Spring Boot服务传输数据时发生的类型不匹配问题,即后端期望接收的字段类型为`int`,而前端实际传输的类型为`Boolean`,导致无法反序列化的问题,并提供了问题的诊断和解决方案。
JSON parse error: Cannot deserialize value of type `java.lang.Integer` from Boolean value
|
JavaScript
NodeJs——Parsing error: Cannot read file '.../tsconfig.json'.eslint
NodeJs——Parsing error: Cannot read file '.../tsconfig.json'.eslint
258 0
|
应用服务中间件 nginx
yum 安装报错 No package nginx available Error:Nothing to do
yum 安装报错 No package nginx available Error:Nothing to do
1251 1
|
JSON Java 数据格式
JSON parse error: Unexpected character (‘t‘ (code 116)): was expecting double-quote to start field n
JSON parse error: Unexpected character (‘t‘ (code 116)): was expecting double-quote to start field n

热门文章

最新文章