I am trying to create Pod in kubernetes cluster to start the docker image. I used ⁠client-java version 8.0.0 to create pod cluster. I used this doc ⁠kubernetes-client to create Pod cluster. But I couldn't set the environment variables for docker container.

Code:

Map<String, String> attributes = myObject.getAttributes(); //need to set this attributes as environment variables in pod creation
// create pod of a Kubernetes cluster
V1Pod pod = new V1PodBuilder().withNewMetadata().withName(serviceName).endMetadata()
                     .withNewSpec().addNewContainer().withName("www").withImage(dockerImage).endContainer().endSpec()
                        .build();

How to set environment variables (Map<String, String>) for docker container while creating pod?

Any inputs here really appreciated.

1

There are 1 best solutions below

0
On

Use 2n'd example from Your referenced code and add setEnv call to V1Container.