首页 > 解决方案 > Service: v1.Service.Spec: v1.ServiceSpec.Selector: ReadString: expects " or n, but found t

问题描述

kubectl create -f redis.yaml
Error from server (BadRequest): error when creating "redis.yaml": Service in version "v1" cannot be handled as a Service: v1.Service.Spec: v1.ServiceSpec.Selector: ReadString: expects " or n, but found t, error found in #10 byte of ...|service":true}}}
|..., bigger context ...|79,"protocol":"TCP"}],"selector":{"redisservice":true}}}
|...

What does this error mean?

apiVersion: v1
kind: Service
metadata:
  name: redis
spec:
  selector:
    redis-service: yes
  ports:
  - protocol: TCP
    port: 6379
  - protocol: TCP
    port: 26379
  - protocol: TCP
    port: 16379

标签: kubernetes

解决方案


Yamlyes值计算为布尔值。所以应该引用...

redis-service: "yes"

推荐阅读