containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.59k stars 2.4k forks source link

Allow podman run with --configmap or podman kube play with environment files #24345

Open mildred opened 2 days ago

mildred commented 2 days ago

Feature request description

When using podman kube play to run pods, environment variables are stored inside configmaps and it is not possible to use environment variables from environment files

When using podman run to run single containers, environment can come from an environment file but not a configmap.

I believe a common use case it to execute containers in a pod for long-running services that have runtime dependencies, but to execute single containers for simpler commands that needs to run once like data migrations. In this case, it is not possible to run a container using the same environment variables from the same file.

Suggest potential solution

Either allow configmaps to reference environment files, it could be solething like:

apiVersion: v1
kind: ConfigMapEnvironmentFile
metadata:
  name: foo
data:
    env_file: path/to/some/file.env

Or allow podman run to reference configmaps:

podman run --configmap=path/to/configmap.yml,name=configmap_name ...

The same way it is possible to declare which configmap name to use in a kube pod, it should be possible to tell which configmap to use in podman run when the configmap is a multi document yaml file.

Have you considered any alternatives?

Duplicating the environment variables in both a configmap and env file, but this can cause errors in case one of the files becomes out of sync

Additional context

No response

rhatdan commented 2 days ago

Interested in opening a PR? I would guess the difficulty here would be priority.

Making sure that --envfile and --configmap have equal waiting. later options override earlier. and --env having priority over these.

Luap99 commented 1 day ago

I am not sure it makes sense to add config map parsing to podman run. In particular how would that work with podman-remote, who would parse the file, how does it look at the API level... That sounds like a lot of complication for no good reason.

Adding the env file path inside the config map yaml has the same issue regarding the remote client where would send the remote client over but not the env file. Maybe we could work around the API level by translating the normal env file to a valid config map on the client then it needs no API changes whatsoever.

rhatdan commented 1 day ago

I would think we parse the envfile and config-map on the client side and just send the list of env to the server side.