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

相关文章
|
23天前
|
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问题如何处理
51 5
|
2月前
|
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问题处理
99 0
|
5天前
|
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
|
2月前
|
应用服务中间件 nginx
yum 安装报错 No package nginx available Error:Nothing to do
yum 安装报错 No package nginx available Error:Nothing to do
94 1
|
2月前
|
应用服务中间件 nginx Docker
Docker中报错 Error response from daemon: Conflict. The container name “/nginx01“ is already in use
在尝试运行 `docker run -d --name nginx01 -p 3344:80 nginx` 时遇到错误。问题源于已有名为 nginx01 的容器未正确终止,造成命名冲突。解决方法:首先使用 `docker ps -a` 查看所有容器,然后删除现有 nginx01 容器,执行 `docker rm <container_id>`(替换 `<container_id>` 为实际容器ID),最后再运行 `docker run` 命令即可。
|
2月前
|
JSON JavaScript API
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 错误分析
本文探讨了Python中处理JSON数据时遇到的`JSONDecodeError`,该错误通常由JSON格式错误或数据源问题引起。解决方法包括检查数据源、使用异常处理机制和调试日志记录。示例代码展示了如何从文件和API读取JSON并处理异常。注意事项涉及验证JSON规范、处理特殊字符和选择合适解析器。通过这些步骤,可以有效解决JSON解码错误,确保数据正确解析。
89 0
|
2月前
|
应用服务中间件 nginx 容器
error: a container name must be specified for pod pod-base, choose one of: [nginx busybox]
error: a container name must be specified for pod pod-base, choose one of: [nginx busybox]
41 0
|
2月前
|
JSON 数据格式
“JSON parse error: Unexpected character (‘1‘ (code 49))的解决方式
“JSON parse error: Unexpected character (‘1‘ (code 49))的解决方式
|
2月前
|
存储 应用服务中间件 nginx
【各种问题处理】nginx报错nginx: [error] open() “/run/nginx.pid” failed (2: No such file or directory)
【1月更文挑战第13天】【各种问题处理】nginx报错nginx: [error] open() “/run/nginx.pid” failed (2: No such file or directory)
|
2月前
|
JavaScript
【Vue Error】Virtual script not found, may missing <script lang=“ts“> “allowJs“: true / jsconfig.json
【Vue Error】Virtual script not found, may missing <script lang=“ts“> “allowJs“: true / jsconfig.json