Is it possible to not populate a pod with environment variables for known services?

1,557 views
Skip to first unread message

kong...@gmail.com

unread,
Oct 4, 2017, 6:37:34 AM10/4/17
to Kubernetes user discussion and Q&A
As the subject says, I would like to avoid that Kubernetes populates a pod with the environment variables for known services. They interfere with some external container images that I am trying to get up and running on Kubernetes.

As an example, confluentinc/cp-schema-registry:3.3.0-1, exits with an error if SCHEMA_REGISTRY_PORT is defined. See https://github.com/confluentinc/cp-docker-images/blob/3.3.x/debian/schema-registry/include/etc/confluent/docker/configure

Is it somehow possible to deactivate this populate feature? I'd prefer that over e.g. replacing the image's entry script or rolling my own image. I haven't been able to find anything in the official documentation but maybe I've overlooked it?

Best regards,
Jonas Kongslund

shivani...@gmail.com

unread,
Oct 4, 2017, 10:15:59 AM10/4/17
to Kubernetes user discussion and Q&A
Can you try to see if unsetting environment variables using the pod.beta.kubernetes.io/init-containers works (using busybox).

Tim Hockin

unread,
Oct 4, 2017, 12:46:57 PM10/4/17
to Kubernetes user discussion and Q&A
AFAIK there isn't a way to disable these automatic variables. We've
discussed this for a very long time, and maybe it's finally time to
add an optional disable for this? Proposals and patches welcome.
This should be a pretty easy one, honestly.

FWIW, the variables are named `FOOBAR_SERVICE_HOST and
FOOBAR_SERVICE_PORT, so the variable you list should not be a problem.



On Wed, Oct 4, 2017 at 7:15 AM, <shivani...@gmail.com> wrote:
> Can you try to see if unsetting environment variables using the pod.beta.kubernetes.io/init-containers works (using busybox).
>
> --
> You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
> To post to this group, send email to kubernet...@googlegroups.com.
> Visit this group at https://groups.google.com/group/kubernetes-users.
> For more options, visit https://groups.google.com/d/optout.

kong...@gmail.com

unread,
Oct 5, 2017, 12:50:03 AM10/5/17
to Kubernetes user discussion and Q&A
Tim,

That would be great if such an optional feature is included. Could you point me in the right direction code wise? Maybe I would be able to do a PR.

My request for this feature is purely based on functionality but I see that scalability is also a concern according to this Github issue (which you have also been involved in):

Pods need to pre-declare service links iff they want the environment variables created #1768
https://github.com/kubernetes/kubernetes/issues/1768


Regarding environment variables, I also see FOOBAR_PORT:

SCHEMA_REGISTRY_PORT=tcp://10.106.89.94:8081
SCHEMA_REGISTRY_PORT_8081_TCP=tcp://10.106.89.94:8081
SCHEMA_REGISTRY_PORT_8081_TCP_ADDR=10.106.89.94
SCHEMA_REGISTRY_PORT_8081_TCP_PORT=8081
SCHEMA_REGISTRY_PORT_8081_TCP_PROTO=tcp
SCHEMA_REGISTRY_SERVICE_HOST=10.106.89.94
SCHEMA_REGISTRY_SERVICE_PORT=8081
SCHEMA_REGISTRY_SERVICE_PORT_8081=8081

Tim Hockin

unread,
Oct 5, 2017, 12:59:42 AM10/5/17
to Kubernetes user discussion and Q&A
pkg/kubelet/envvars/envvars.go

Simplest change would probably be a new field, default true, saying
"publish env vars for services". we might want to special case
KUBERNETES_SERVICE_HOST and _PORT because that has deeper roots.

A short design proposal would be appropriate.

kong...@gmail.com

unread,
Oct 5, 2017, 2:17:47 AM10/5/17
to Kubernetes user discussion and Q&A
Thanks Tim. I'll give it a shot.
Reply all
Reply to author
Forward
0 new messages