Does anyone have a small Typescript example on how...
# kubernetes
l
Does anyone have a small Typescript example on how correctly add an environment variable to a container in a
Deployment
using a transformation? I seem to fail on setting it the correct way.
f
Maybe I don't understand this correctly, but can't you just add the env variables directly in the definition ? I use something like:
Copy code
spec: {
              containers: [
                {
                  name: `${serviceName}`,
                  image: image,
                  ports: [
                    {
                      containerPort: deploymentOptions.containerPort || 80,
                      hostPort: deploymentOptions.hostPort || 80,
                    },
                  ],
                  imagePullPolicy: "Always",
                  env: envArgs, <<<---- These are env set to the pod
                },
              ],
            },
l
@future-refrigerator-88869 that's the thing I don't want to do at the moment. Given separation of concerns, I am decoupling e.g. my deployment from the db connection. I modelled the db connection separately and want to pass a transformation function from my db connection abstraction to my deployment. That transformation only adds what is needed for configuring the db connection to the deployment when a connection needs to be set up. So in my case, I want to extend the
env
with additional values only when needed.