incubator-heron icon indicating copy to clipboard operation
incubator-heron copied to clipboard

Not able to set environment variables in Heron executors

Open sautran opened this issue 6 years ago • 16 comments

I use heron kubernetes deployment. My application requires an environment variable set in the task container. I can't find a way to do that.

sautran avatar Feb 01 '19 15:02 sautran

I am talking about shell environment variable not java properties

sautran avatar Feb 01 '19 16:02 sautran

in the AppsV1beta1Controller.java, can we support more user defined env variable? // setup the environment variables for the container final V1EnvVar envVarHost = new V1EnvVar(); envVarHost.name(KubernetesConstants.ENV_HOST) .valueFrom(new V1EnvVarSource() .fieldRef(new V1ObjectFieldSelector() .fieldPath(KubernetesConstants.POD_IP)));

final V1EnvVar envVarPodName = new V1EnvVar();
envVarPodName.name(KubernetesConstants.ENV_POD_NAME)
    .valueFrom(new V1EnvVarSource()
        .fieldRef(new V1ObjectFieldSelector()
            .fieldPath(KubernetesConstants.POD_NAME)));
container.setEnv(Arrays.asList(envVarHost, envVarPodName));

sautran avatar Feb 01 '19 16:02 sautran

@nwangtw, Hi, Wang, Are you able to put this feature in soon?

sautran avatar Feb 05 '19 16:02 sautran

I also agree this would be a great feature.

spennymac avatar Feb 05 '19 16:02 spennymac

We dont use k8s internally so it is hard for me to tell the exact case although it does make sense to me and I feel it shouldn't be too hard to support.

Is it possible to set the vars in the open() function of each component? or it is different from your case? I am just trying to understand the differences.

@kramasamy @jerrypeng you guys have any input or time on this?

nwangtw avatar Feb 05 '19 17:02 nwangtw

@nwangtw ,if I understand correctly, open() is in jvm level. need to set it in the shell. outside of jvm. Bear with me if i am wrong

sautran avatar Feb 05 '19 17:02 sautran

I see. Sounds like it needs to be in executor then.

nwangtw avatar Feb 05 '19 20:02 nwangtw

@nwangtw, in fact, this is not only for container also for standard deployment. I also have a aurora/mesos cluster. There is no configuration that we can set environment variables in the executors.

I worked around by change heron.aurora file add some shell scripts in it.

sautran avatar Feb 21 '19 16:02 sautran

As far as I am aware environment variables don't work well with the way containers are managed in Heron. From my experience any configuration I need is typically passed via command line. Is this still considered an issue?

joshfischer1108 avatar May 21 '19 03:05 joshfischer1108

@joshfischer1108 , yes, this is still an major blocking issue for our deployment. The configuration passed through from command line are for java properties set. I don't know we can pass environment variables. Might be I miss that. Could you please guide me through?

sautran avatar May 21 '19 13:05 sautran

Can you describe to me your use case? It would help if I knew the actual problem you are trying to solve to help get you to a working solution. At the end of the day an environment variable and java properties just hold a value of some sort. I'd like to understand the difference between the two in your scenario.

joshfischer1108 avatar May 21 '19 14:05 joshfischer1108

we have environment variable to define a different cryto key for different deployments(test, staging...).

sautran avatar May 21 '19 14:05 sautran

Ok.. Assuming you don't want the individuals deploying topologies to see the keys. You could automate deployments using some type of CI/CD tool and dynamically retrieve those secrets / keys during the build. Then once that key is passed via topology submission as a CLI arg you could set them via a java property of some sort. There may be some customization needed for the components you are running. Would this resolve your issue?

joshfischer1108 avatar May 21 '19 14:05 joshfischer1108

this won't resolve the issue - that component only accepts env variable and it is out of our scope.

sautran avatar May 21 '19 14:05 sautran

Setting env variables in aurora config seems to be a valid option. Does it solve your problem or it is still missing something. Is it polluting the host environment?

Adding new executor parameter to set env variables should be doable. But we need to understand better the requirements, such as value types, local to the processes or not, etc .

nwangtw avatar May 21 '19 16:05 nwangtw

Setting it in aurora config is a workaround for that aurora deployment. However, with the k8 on aws etc, cloud providers..this would still be an issue.

sautran avatar May 21 '19 20:05 sautran