在 Kubernetes 中应用时如何修复线格式数据错误

问题描述 投票:0回答:2

我有以下 yaml 文件:

#deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2 
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
      - containerPort: 80

我正在尝试使用此命令来应用:

kubectl apply -f deployment.yaml

我已经检查过是否可能有缩进,替换了空格的制表符,但我不断收到此错误

error: proto: cannot parse invalid wire-format data

我从模板申请时也有同样的错误

kubectl apply -f https://k8s.io/examples/application/deployment.yaml

kubernetes yaml
2个回答
1
投票

在您的代码片段中,

.spec.template.spec.containers
部分存在一些缩进问题。你的缩进应该是这样的:

  containers:
    - name: nginx
      image: nginx:1.14.2
      ports:
        - containerPort: 80

0
投票

你是如何解决这个问题的?谢谢你:)

© www.soinside.com 2019 - 2024. All rights reserved.