How to set array structure property in env for k8s?

5/7/2020

To define clients in secret to store client name and password, how to define a client array in env and secret to store these data?

It should be like this in application.yml:

app:
  clients:
    client1: password1
    client2: password2
      ......

I tried to define this in app-deployment.yml, but it didn't seem to be allowed

env:
  - name: APPLICATION_CLIENTS
    value:
      - name: client1
        valueFrom:
          secretKeyRef:
            name: clients
            key: client1-password
      - name: client2
        valueFrom:
          secretKeyRef:
            name: clients
            key: client2-password

Error:

invalid type for io.k8s.api.core.v1.EnvVar.value: got "array" expected "string"
-- zm999999
configmap
kubernetes
kubernetes-secrets

1 Answer

5/7/2020

Create a secret and mount that in pod as env and then in code read that env var to get the password value And approach for user name but instead of creating config map or secret directly define it as env var in pod

-- Mandeep Singh
Source: StackOverflow