1

We've got checked-in YML files which contain our k8s "deployment descriptors" (is there a better name for these things?)

I'm looking at a Service descriptor like...

apiVersion: v1
kind: Service
metadata:
  name: regalia-service
  namespace: sem
spec:
  selector:
    app: "proxy"
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 8080

I look in a different repo that is doing basically the same thing and I notice the spec.selector.app value is missing the quotes. Like...

apiVersion: v1
kind: Service
metadata:
  name: scimitar-service
  namespace: sem
spec:
  selector:
    app: proxy
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 8080

I think these 2 Service descriptors are doing the same thing but how do I know?

Are the quotes significant in k8s descriptors?

Is this a YML thing or a k8s thing?

Bob Kuhar
  • 10,838
  • 11
  • 62
  • 115

1 Answers1

5

As you probably already find out, in yaml syntax strings values rarely need quotes. If the value is quoted, it is always a string, if unquoted it is inspected to be something else but defaults for being a string.

For most the string you can left them unquoted and as you already find out you will have similar results. But there are some cases where the quotes are required such as string started with some special character %#@#$ or contains whitespace or the value looks like a number but in fact should be a string (like 45, true or false

For more reading please have a look this blog post about quoting in yaml.

acid_fuji
  • 6,287
  • 7
  • 22