containers / containers/podman-compose

podman-compose as a tool for migrating docker-compose solutions to kubernetes

Open
#822 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
6.2k
Forks
622
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
I'm using `podman-compose` to migrate docker-composite solutions to `kubernetes` via:

podman kube generate <podId> 

podman-compose uses the `_` character as a delimiter when generating volume and container names.
For example, when starting a service stack
[hello-python](https://github.com/containers/podman-compose/blob/devel/examples/hello-python/docker-compose.yaml) in POD:
# cd examples/hello-python

# podman-compose --in-pod hello-python up -d

we get a pod with container names `hello-python_redis_1,``hello-python_web_1`:
# podman pod ls --ctr-names

POD ID NAME STATUS CREATED INFRA ID NAMES
6bc55962dc29 pod_hello-python Running 2 minutes ago hello-python_redis_1,hello-python_web_1

and volume name `hello-python_redis`
# podman volume ls | grep hello-python

hello-python_redis

After generating the kube- manifest
# podman kube generate pod_hello-python > ./kube.yml


and trying to run it,
# kubectl apply -f ./kube.yml


we receive an error message:
The Pod "podhello-python" is invalid: 

* spec.volumes[1].name: Invalid value: "hello-python_redis-pvc": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')
* spec.containers[0].volumeMounts[0].name: Not found: "hello-python_redis-pvc"
...

**Describe the solution you'd like**
I created a pull request [Support for migrating docker-compose solutions to kubernetes ](https://github.com/containers/podman-compose/pull/820) that solves this problem.
**This pull request supports the `--kubecompat` flag, which when specified uses the `-` separator character when generating names of containers and volumes.**
When `podman-compose` called with a flag `--kubecompat`

podman-compose --kubecompat --in-pod hello-python up -d

we get a pod with container names **hello-python-redis-1**, **hello-python-web-1**:
# podman pod ls --ctr-names

POD ID NAME STATUS CREATED INFRA ID NAMES
87c28523698a pod_hello-python Running 59 minutes ago hello-python-redis-1,hello-python-web-1

and volume name **hello-python-redis**
# podman volume ls | grep hello-python

hello-python-redis

After generating the kube- manifest
# podman kube generate pod_hello-python > ./kube.yml


and trying to run it,
# kubectl apply -f ./kube.yml


we get a correctly deployed pod:
# kubectl apply -f ./kube.yml 

pod/podhello-python created
# kubectl get pod/podhello-python -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
podhello-python 2/2 Running 0 47s 10.88.0.21 host-8

**Describe alternatives you've considered**
_The reason for using the `_` character as a delimiter is not obvious to me.
Maybe it's worth using the `-` character as a default separator?_

**Additional context**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.