Closed ghost closed 3 years ago
Sorry I meant to highlight the code snippet where I think this happens: https://github.com/containers/podman/blob/381ab48c2586a96932701a1fe270ebd2c32a04d4/libpod/network/cni/run.go#L192-L205
This is new code which is not yet included in any released podman version. As you can see it only sets K8S_POD_NAME
because this is used by the dnsname plugin.
Looking at your linked code it needs both K8S_POD_NAMESPACE
and K8S_POD_NAME
to bet set so with the new networking code it will work.
The old code used OCICNI which sets all K8s vars: https://github.com/cri-o/ocicni/blob/b38844812e649006b07a9063e2e7c4fa1a97d9b0/pkg/ocicni/ocicni.go#L803-L808
The next version which includes the new network code will be 4.0. It will be released in January/February.
That's good news - thanks !
Given that this is fixed in the main branch I am going to close this issue.
I think you can overwrite the env var to an empty string if you set this CNI_ARGS=K8S_POD_NAME=
/kind bug
Description
All containers launched via Podman/libpod pass a
K8S_*
environment variables, likeK8S_POD_NAME
to the underlying CNI. This causes CNI's like Calico to assume they are running within a Kubernetes context when they are not, which breaks things. It's not an unreasonable assumption either.Podman shouldn't be setting these envvars, it's not a Kubernetes application. At the very least it should at least check it is also running in a Kubernetes context first if there is a use case for that.
Steps to reproduce the issue:
Describe the results you received:
Container fails to be created as the CNI is being passed K8S variables when not in a K8s environment
Describe the results you expected:
Podman should not be setting K8S specific variables
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info --debug
:Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/master/troubleshooting.md)
Yes
Additional environment details (AWS, VirtualBox, physical, etc.): Physical