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

Regarding adding an interface to retrieve the netns of a Pod object #124924

Open
jiayoukun opened this issue May 17, 2024 · 9 comments
Open

Regarding adding an interface to retrieve the netns of a Pod object #124924

jiayoukun opened this issue May 17, 2024 · 9 comments
Assignees
Labels
area/kubelet kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/node Categorizes an issue or PR as relevant to SIG Node.

Comments

@jiayoukun
Copy link

jiayoukun commented May 17, 2024

What would you like to be added?

I want to extend the gRPC interface in kubelet that retrieves pod resources to include an interface for obtaining the pod netns using the pod UID. This way, it would be possible to retrieve a pod object and perform operations on its netns after querying it using the pod UID.

Is this a good idea? Or are there perhaps better options?
Here is the proto path:
kubernetes\staging\src\k8s.io\kubelet\pkg\apis\podresources\v1\api.proto

Why is this needed?

In the current overlay network, there are many scenarios where the IP of a Pod's network interface needs to be forwarded in and out. This may involve using OVS, VPP, or other tools to perform IP SNAT, DNAT, and redirect operations.

For Pod objects, etcd does not store the netns of a Pod, and kubelet manages the sandbox state of each Pod using PodSandboxID. Both PodSandboxID and netns are not publicly accessible, which is very unfriendly to developers who want to manipulate the dynamic network of a Pod.

@jiayoukun jiayoukun added the kind/feature Categorizes issue or PR as related to a new feature. label May 17, 2024
@k8s-ci-robot k8s-ci-robot added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 17, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@jiayoukun
Copy link
Author

/sig api-machinery

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 17, 2024
@cici37
Copy link
Contributor

cici37 commented May 30, 2024

/sig node
/remove-sig api-machinery

@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. and removed sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels May 30, 2024
@aojea
Copy link
Member

aojea commented May 30, 2024

@jiayoukun you can use the container runtime directly for this using NRI plugins, that is supported by containerd and crio, see containerd/nri#82

@aojea
Copy link
Member

aojea commented May 30, 2024

/sig network

@k8s-ci-robot k8s-ci-robot added the sig/network Categorizes an issue or PR as relevant to SIG Network. label May 30, 2024
@jiayoukun
Copy link
Author

@aojea I have read the introduction to NRI plugins, and the functionality does not align with my intended purpose. What I need is an interface to query the Pod's netns using the Pod object's UID. The obtained netns from the query can allow me to extend the network more flexibly.

In fact, for developers using NRI plugins, this interface to query the netns is even more necessary! For Pods with multiple network devices, more fine-grained routing and redirection capabilities are required. Without this interface to obtain the Pod's netns, it is impossible for external components to access and manipulate the Pod's network.

What are your thoughts on this?

@shaneutt
Copy link
Member

shaneutt commented Jun 6, 2024

/assign @thockin

@thockin thockin added area/kubelet and removed sig/network Categorizes an issue or PR as relevant to SIG Network. labels Jun 6, 2024
@thockin
Copy link
Member

thockin commented Jun 6, 2024

This is a container-runtime (sig-node) topic, but... It's not a guarantee that runtimes use network namespaces at all. It's what most implementations do, but it's not a REQUIREMENT. AFAICT "which netns" is not covered by CRI today, which is probably step 1 and not exactly clear if or how we would want to represent that.

SIG-node - what's the current doctrine on exposing that level of detail?

@jiayoukun
Copy link
Author

This is a container-runtime (sig-node) topic, but... It's not a guarantee that runtimes use network namespaces at all. It's what most implementations do, but it's not a REQUIREMENT. AFAICT "which netns" is not covered by CRI today, which is probably step 1 and not exactly clear if or how we would want to represent that.

SIG-node - what's the current doctrine on exposing that level of detail?

Does this involve the specification of netns by CRI? I haven't found any theories about exposing details at this level. It would take a long time to form a specification for netns for all CRIs, right? In the current situation, my understanding is to make a judgment based on most container runtimes that support netns. Something like using a select case to determine the container runtime type? After the specification is completed later, refactor and merge it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/node Categorizes an issue or PR as relevant to SIG Node.
Projects
None yet
Development

No branches or pull requests

6 participants