Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to specify arrays and maps in kubernetes service yaml spec?

I’m trying to send my kubernetes spec a list. My yaml looks like this:

---
apiVersion: v1
kind: Application
metadata:
  name: my-app
spec:
  env:
    - name: ENV1
      value: http://someurl.com
    - name: ENV2
      value: val2

    - name: AN_ENV_LIST
      value:
        - val2
        - val3

But of course I get an error:

invalid type for v1.Application.spec.env.value: got "array", expected "string"

My question is, is this even possible with kubernetes?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How do I specify a list?

And a bonus question – what about maps? Is that possible?

>Solution :

Environment variables are of type string, so you cannot pass an array in a single variable.

You can either encode the array to be a string, but the application must be aware of that encoding. Alternatively pass multiple environment variables, if the application supports that.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading