kubernetes / kompose

Convert Compose to Kubernetes
http://kompose.io
Apache License 2.0
9.5k stars 749 forks source link

[BUG] underscores in compose service name are not replaced with dashes in kubernetes Service metadata.name #1897

Open jancespivo opened 3 months ago

jancespivo commented 3 months ago

Expected Behavior

kompose convert should replace underscores with dashes in kubernetes Service metadata.name when compose service name contains underscores

apiVersion: v1
kind: Service
metadata:
  labels:
    io.kompose.service: myservice-api
  name: myservice-api  # THIS IS OK
spec:
  ports:
    - name: "8000"
      port: 8000
      targetPort: 8000
  selector:
    io.kompose.service: myservice-api

Actual Behavior

It generates:

apiVersion: v1
kind: Service
metadata:
  labels:
    io.kompose.service: myservice-api
  name: myservice_api  # <-- THIS IS NOT VALID name
spec:
  ports:
    - name: "8000"
      port: 8000
      targetPort: 8000
  selector:
    io.kompose.service: myservice-api

metadata.name is not valid (it contains underscore instead of dash)

Steps To Reproduce

No response

Kompose Version

1.34.0

Docker-Compose file

No response

Anything else?

No response

k8s-triage-robot commented 1 week ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

jancespivo commented 6 days ago

/remove-lifecycle stale