[BUG] Enhance handling of x-shared-env
Expected Behavior
I expected Kompose to handle x-shared-env in a way that minimizes duplication by converting it into a shared list of environment variables (e.g., a ConfigMap) and then referencing that shared configuration in each relevant container. Instead, it duplicates the variables across containers, which defeats the purpose of centralizing environment variable management.
Actual Behavior
When attempting to convert the docker-compose.yaml file for Dify, I noticed that the x-shared-env block is being duplicated across all containers. This leads to an unnecessarily long list of environment variables being added to each of the three containers in the generated files. This approach is inefficient, as it redundantly duplicates environment variables, making tasks like updating API keys cumbersome—requiring changes in three locations instead of a single, centralized place.
Steps To Reproduce
-
Download the
docker-compose.yamlfile: Get thedocker-compose.yamlfile from the official Dify repository by visiting this URL: https://github.com/langgenius/dify/blob/main/docker/docker-compose.yaml . -
Convert the docker-compose.yaml file to Kubernetes manifests: Use Kompose to convert the Docker Compose file into Kubernetes manifests. Run the following command:
kompose convert -f docker-compose.yaml
-
Review the generated Kubernetes manifests: After the conversion, notice that Kompose generates separate files for each container, and each file includes a complete list of environment variables copied from
x-shared-env. -
Identify the issue: Instead of centralizing shared environment variables into a Kubernetes ConfigMap and referencing it across containers, Kompose replicates the variables in every container manifest. This duplication makes it harder to manage updates (e.g., API keys), as changes would need to be applied to multiple containers instead of being managed in a single shared ConfigMap.
Kompose Version
Latest
Docker-Compose file
Anything else?
No response