Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kafnevod opened this issue Jan 16, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@kafnevod
Copy link

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 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 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

@kafnevod kafnevod added the enhancement New feature or request label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant