“error while doing ‘kubectl apply -f …’ apiVersion v1?”

huangapple go评论77阅读模式
英文:

error while doing "kubectl apply -f ..." apiVersion v1?

问题

错误:

>来自服务器的错误(BadRequest):在创建“client-node-port.yaml”时出现错误:无法将版本“v1”中的Service视为Service:严格解码错误:未知字段“spec.ports[0].ports”

apiVersion: v1
kind: Service
metadata:
  name: client-node-port
spec:
  type: NodePort
  ports:
    - ports: 3050
      targetPort: 3000
      nodePort: 31515
  selector:
    component: web

这是文件“client-node-port.yaml”,我还有一个名为“client-pod.yaml”的文件,其中 kind: pod

英文:

the error:

>Error from server (BadRequest): error when creating "client-node-port.yaml": Service in version "v1" cannot be handled as a Service: strict decoding error: unknown field "spec.ports[0].ports"

apiVersion: v1
kind: Service
metadata:
  name: client-node-port
spec:
  type: NodePort
  ports:
    - ports: 3050
      targetPort: 3000
      nodePort: 31515
  selector:
    component: web

this is the file "client-node-port.yaml", I also have a file named "client-pod.yaml" that is kind: pod

答案1

得分: 1

这可能只是一个简单的拼写错误。您定义了ports: 3050而不是port: 3050

英文:

that would be a simple typo. You defined ports: 3050 instead of port: 3050

huangapple
  • 本文由 发表于 2023年5月24日 17:24:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76321987.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定