How can I unset an environment variable in Kubernetes?

7/18/2017

When launching my Kubernetes deployment for Flower (Celery monitoring service), the following environment variables are generated in the Flower pod by Kubernetes:

FLOWER_PORT=tcp://10.67.97.89:5555
FLOWER_PORT_5555_TCP=tcp://10.67.97.89:5555
FLOWER_PORT_5555_TCP_ADDR=10.67.97.89
FLOWER_PORT_5555_TCP_PORT=5555
FLOWER_PORT_5555_TCP_PROTO=tcp
FLOWER_SERVICE_HOST=10.67.97.89
FLOWER_SERVICE_PORT=5555
FLOWER_SERVICE_PORT_5555=5555

This is due to the Flower service which is started shortly before the deployment. However, Flower expects an integer in FLOWER_PORT and aborts.

How can I prevent these environment variables from being created?

-- Torsten Bronger
environment-variables
kubernetes
unset

1 Answer

7/18/2017

You can not prevent creation of these, but you can overwrite them with your own values by setting them explicitly in your deployments pod template. So, if you ie. expect the default value of FLOWER_PORT to be say 80 instead of tcp://..., all you need to do is put

env:
- name: FLOWER_PORT
  value: "80"

and that's it.

-- Radek 'Goblin' Pieczonka
Source: StackOverflow