incubator-heron
incubator-heron copied to clipboard
Not able to set environment variables in Heron executors
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.
I am talking about shell environment variable not java properties
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));
@nwangtw, Hi, Wang, Are you able to put this feature in soon?
I also agree this would be a great feature.
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 ,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
I see. Sounds like it needs to be in executor then.
@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.
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 , 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?
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.
we have environment variable to define a different cryto key for different deployments(test, staging...).
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?
this won't resolve the issue - that component only accepts env variable and it is out of our scope.
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 .
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.