You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kubernetes新手求助:创建Nginx Service时出现Strict Decoding错误

问题解决

错误原因

  1. API版本无效:Kubernetes Service不存在v2版本,你配置文件中写的apiVersion: v2是错误的,Service的稳定版本为v1。
  2. 字段拼写错误:错误提示提到的spec.ports[0].protocols(复数)说明实际提交的配置文件里,可能误把protocol(单数)写成了protocols(复数),请确认你本地的yaml文件是否存在这个拼写问题。

修正后的配置文件

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

重新执行部署命令

kubectl apply -f nginx-service.yaml

内容的提问来源于stack exchange,提问作者Suman Mondal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 11:48:11