Error parsing tls section of nginx ingress file

11/27/2018

I have the following in my ingress

spec:
  tls:
    - hosts:
      - domain.com
      - www.domain.com
      secretName: secret-prod
      - stage.domain.com
      - www.stage.domain.com
      secretName: secret-stage

The format for this I've copied from various examples, but it throws the following error when I try to apply the file in kubectl

error: error parsing nginx/ingress.yml: error converting YAML to JSON: yaml: line 13: did not find expected key

Line 13 is where it says secretName: secret-prod

What's wrong with this format?

-- Ben Gannaway
kubernetes
nginx-ingress
yaml

1 Answer

11/27/2018

You need to separate them like that:

tls:
- secretName: secret-prod
  hosts:
  - domain.com
  - www.domain.com
- secretName: secret-stage
  hosts:
  - stage.domain.com
  - www.stage.domain.com

See https://github.com/kubernetes/contrib/blob/master/ingress/controllers/nginx/examples/multi-tls/multi-tls.yaml for a complete example.

-- Clorichel
Source: StackOverflow