containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.81k stars 2.42k forks source link

`kube generate` must transform invalid names or throw fatal fault #16542

Open sanmai-NL opened 1 year ago

sanmai-NL commented 1 year ago

/kind bug

Description

podman kube generate takes e.g., volume names as is, but Kubernetes has naming rules that seem to differ from Docker Engine's.

Steps to reproduce the issue:

  1. Create a container using Kubernetes-invalid names for volumes.

  2. Run podman kube generate > manifest.yml.

  3. kubectl apply --filename=manifest.yml.

Describe the results you received:

The Pod "xenodochialmaxwell-pod" is invalid: 
* spec.volumes[0].name: Invalid value: "Users-sanderhan-devel-gitlab.com-han-aim-lern-host-0": 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.volumes[1].name: Invalid value: "Users-sanderhan-.config-git-host-1": 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.volumes[2].name: Invalid value: "lern_vscodeserver-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])?')

Describe the results you expected:

Valid names and ability to apply the Kubernetes manifest. This applies to volume names, indeed to any type name.

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

  podman version
Client:       Podman Engine
Version:      4.3.1
API Version:  4.3.1
Go Version:   go1.18.8
Built:        Wed Nov  9 21:43:58 2022
OS/Arch:      darwin/amd64

Server:       Podman Engine
Version:      4.3.0
API Version:  4.3.0
Go Version:   go1.19.2
Built:        Fri Oct 21 10:09:51 2022
OS/Arch:      linux/amd64

Output of podman info:

Not applicable.

Package info (e.g. output of rpm -q podman or apt list podman or brew info podman):

Not applicable.

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes.

Additional environment details (AWS, VirtualBox, physical, etc.): macOS. Container created is VS Code dev container.

rhatdan commented 1 year ago

Care to open a PR to fix this to make the generated volume names compatibile?

rhatdan commented 1 year ago

@umohnani8 PTAL

rhatdan commented 1 year ago

Could you give us the podman run command you used to generate the container.

sanmai-NL commented 1 year ago

Could you give us the podman run command you used to generate the container.

I'll try to, but the catch 22 is: I generated a running container as created by VS Code Dev Containers. So I didn't control the command line nor used a Compose file.

sanmai-NL commented 1 year ago

Care to open a PR to fix this to make the generated volume names compatibile?

It would be helpful if your team points out where in the source tree to look. Time spent on overhead makes it less attractive to contribute, for some reason. ;)

rhatdan commented 1 year ago

I would start here: pkg/specgen/generate/kube/kube.go

github-actions[bot] commented 1 year ago

A friendly reminder that this issue had no activity for 30 days.

rhatdan commented 1 year ago

@sanmai-NL @umohnani8 Is this still an issue?