minikube: configmap values created --from-file aren't set in shell (eg. echo $MY_VAR returns blank) but do appear when I run the env command

BUG REPORT

Environment:

  • Minikube version (use minikube version): minikube version: v0.23.0
  • OS (e.g. from /etc/os-release): Darwin 16.7.0
  • VM Driver (e.g. cat ~/.minikube/machines/minikube/config.json | grep DriverName): xhyve
  • ISO version (e.g. cat ~/.minikube/machines/minikube/config.json | grep -i ISO or minikube ssh cat /etc/VERSION): minikube-v0.23.6.iso

What happened:

I’m running

kubectl create configmap all-settings --from-file=all-settings.properties

where all-settings.properties looks like:

CLUSTER_NAME=minikube
CLOUD_PROVIDER=local
..

Then in my config I have:

kind: Deployment
apiVersion: extensions/v1beta1
..
      containers:
      - name: my-container
        envFrom:
          - configMapRef:
              name: all-settings

This deploys a Docker image that starts with

FROM debian:jessie

When I deploy to minikube and open a bash shell inside the pod, I can run env and see the keys/values as expected:

CLUSTER_NAME=minikube
CLOUD_PROVIDER=local
..

but if I echo any of these vars (eg. echo $CLUSTER_NAME) or use them in my scripts, the variable doesn’t appear to be set - it returns blank. I can, though, echo vars that are set by kubernetes (such as *_PORT or *_HOST) and also vars that are set one-by-one in the deployment config env: section - for example

        env:
        - name: CLUSTER_NAME
          value: "{{ CLUSTER_NAME }}"

If I run /bin/sh, I still see the same thing - the vars are listed in env but I can’t echo them or use them in my script.

What you expected to happen:

since I’m seeing the values when I run env, I expected to be able to use them on the command line and in my scripts, but the vars don’t appear to exist outside of env.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 25 (9 by maintainers)

Most upvoted comments

Ok. I worked out my issue. Turns out that “sh” strips out envVars that contain dots (used for spring boot’s application.properties). I switched to “bash”, and things are working as expected; variables are passed on to the child processes.