-
Notifications
You must be signed in to change notification settings - Fork 699
Subscribe to container engine API for published ports #4021
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
base: master
Are you sure you want to change the base?
Conversation
2792bfd
to
6e5e4a6
Compare
Seems overengineering. |
go.mod
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many new dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, there are many indirect dependencies being used for just a few direct ones. However, I went ahead and compared the guest agent sizes from the master build and my PR, and I’m happy to share the results below:
total 231384
-rw-r--r-- 1 ninok wheel 55M Sep 11 10:27 guestagent_master
-rw-r--r-- 1 ninok wheel 58M Sep 11 10:26 guestagent_pr
return ipPorts, nil | ||
} | ||
// If the label is not present, we check the network config in the following path: | ||
// <DATAROOT>/<ADDRHASH>/containers/<NAMESPACE>/<CID>/network-config.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file isn't expected to be parsed externally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue is that since containerd/nerdctl#4290 the information is no longer available via labels. How are you expected to get the port mapping information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expectation is not to depend on container engine implementations; audit events or eBPF should work (see my comments below)
There are no event watchers for docker or containerd; we rely on polling See e.g. abiosoft/colima#71 This PR is basically a port of the event watchers from Rancher Desktop on Windows, which does not suffer from this issue. |
We also monitor audit events: lima/pkg/guestagent/guestagent_linux.go Line 33 in 69538a7
Maybe the audit monitor has a bug ? |
There is also a proposal to use eBPF to monitor ports cc @balajiv113 |
In addition to what @jandubois also pointed out, the current implementation |
This PR is in response to #2536 I thought I read a note from @balajiv113 that the audit approach didn't work out because most cloud images did not have the required kernel modules for it installed, but can't find the reference right now. And #3067 also sounds like it doesn't work anymore for Kubernetes. |
#1855 may explain why audit monitoring doesn't seem to work. |
Monitor container creation and deletion events by subscribing to the container engine's API. Upon receiving a container creation or deletion event, the system immediately forwards the port mappings through the aggregated channel. This ensures that the ports are opened on the host without any latency. Signed-off-by: Nino Kodabande <[email protected]>
6e5e4a6
to
2a0d45d
Compare
This PR aims to capture the published ports within the VM for various container engines. It directly subscribes to the corresponding container engine APIs (Docker, containerd and Kubernetes) to detect published ports immediately as a container is created.
I'm also planning to move the iptables and procnet settings under the portMonitor property; however, that will be addressed in a follow-up PR.