Kubernetes-client: How to add variable to env without overwriting entire env?

Created on 5 Jun 2020  路  5Comments  路  Source: fabric8io/kubernetes-client

kubernetesClient.apps()
                               .statefulSets()
                               .inNamespace(nameSpace)
                               .withName(statefulSet.getMetadata().getName())
                               .edit()
                               .editMetadata()
                               .addToLabels(labels)
                               .endMetadata()
                               .editSpec()
                               .editTemplate()
                               .editMetadata()
                               .addToLabels(labels)
                               .endMetadata()
                               .editSpec()
                               .editContainer(0)
                               .withImage(newImage)
                               .addToEnvFrom()
                               .withName("BLA")
                               .withValue("VALUE)
                               .endEnv() 
                               .endContainer()
                               .endSpec()
                               .endTemplate()
                               .endSpec()

bit lost with signatures , i want to ensure that I will just add new enviornmental variable and not erase entire env.

Is this correct?

Waiting on feedback question

All 5 comments

@antonalechnovic : looks fine to me. withEnv() call replaces all values. Are you facing any error when you run it?

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

bdw, we also have a addNewEnv() method which you can use to add single EnvVar to current list

Closing this issue since it was asked 6 months ago and both operations are supported (completely replace environment variable list + add a new env variable to an existing list)

Was this page helpful?
0 / 5 - 0 ratings