Skip to content

[BUG] Conflicting name assigned to configmap generated for compose referencing ".env" files #1793

@Pratham1812

Description

@Pratham1812

Expected Behavior

Compose files which refer to environment variables from files such as ".env" or ".env.local" in a simple React application should produce a configmap file whose filename follows the appropriate regex rules required by kubernetes.

Actual Behavior

For compose referencing env_files begining with ".env", the generated file name of configmap does not follow appropriate regex rules, which prevents deployment on minikube or any other platform.

Steps To Reproduce

  1. For this docker-compose.yaml
version: '3.8'
services:
  mongodb:
    image: mongo:latest
    restart: always
    expose:
      - 27017
  app:
    depends_on:
      - mongodb
    env_file:
      - ./src/app/.env.local
    build: src/
    ports:
      - "3000:3000"
  1. On running kompose convert -f docker-compose.yaml
  2. File name for configmap < path with '/' replace with '-' >-app--env-configmap.yaml
  3. On minikube run kubectl apply -f app-deployment.yaml
  4. The deployment is not created
    image

Kompose Version

1.31.2 (a92241f79)

Docker-Compose file

version: '3.8'
services:
  mongodb:
    image: mongo:latest
    restart: always
    expose:
      - 27017
  app:
    depends_on:
      - mongodb
    env_file:
      - ./src/app/.env
    build: src/
    ports:
      - "3000:3000"

Anything else?

The issue seems to be in kompose/pkg/transformer/kubernetes/k8sutils.go in the FormatEnvName function where the '.' has been replaced with '-' and can be resolved as shown in the below screen shot .

image

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions