-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add core code to support namespace based CRDs #344
Conversation
f776292
to
6344cc7
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #344 +/- ##
==========================================
+ Coverage 27.18% 28.13% +0.94%
==========================================
Files 88 128 +40
Lines 7786 11202 +3416
==========================================
+ Hits 2117 3152 +1035
- Misses 5460 7768 +2308
- Partials 209 282 +73
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
d903f0a
to
5b34117
Compare
@Billy99, this pull request is now in conflict and requires a rebase. |
5b34117
to
3850b25
Compare
e67530f
to
41b175b
Compare
41b175b
to
b545665
Compare
b545665
to
bb76968
Compare
e03103a
to
896aa16
Compare
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 looks great! I'm still planning to test it, but I only saw one minor thing on the review.
apis/v1alpha1/tcNsProgram_types.go
Outdated
|
||
// Containers identifies the set of containers in which to attach the eBPF | ||
// program. | ||
Containers *ContainerNsSelector `json:"containers"` |
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.
Since Containers is required for the namespaced crds, it shouldn't be a pointer. This applies to all of them. Then, you don't need to check for nil in the controller code.
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.
Done.
I did the following test: Deploy nginx:
Apply some sample programs:
Delete the nginx deployment:
The programs should get deleted because there aren't any matching containers anymore. tcx and uprobes get deleted fine, but, I'm seeing errors like the following for tc and xdp:
This is due to a bug in my bpfman netns pr where I can't find the NSID after I've deleted the pods, but it's part of the dispatcher id and I need to figure that out so I can delete it. So, I'm going to have to figure that one out, but I won't hold this pr up for it. |
896aa16
to
059a202
Compare
bpfman/bpfman#1362 opened for nginx delete issue described above. |
internal.BpfNsProgramTypePredicate(internal.Xdp.String()), | ||
internal.BpfProgramNodePredicate(r.NodeName)), | ||
), | ||
). |
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.
). | |
). | |
// Watch for changes in Pod resources in case we are using a container selector. | |
Watches( | |
&v1.Pod{}, | |
&handler.EnqueueRequestForObject{}, | |
builder.WithPredicates(podOnNodePredicate(r.NodeName)), | |
). |
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.
Done
Also, I'm seeing some errors when deleting the programs:
Then, in the logs, I see errors like the following:
I haven't tried to debug it yet, but could it be a missing permission for the namespace scoped crd, or the role? The deletes all succeed despite the error messages. |
@Billy99 did u use operator-sdk to create those NS objects ? |
Actually, it looks like the code is trying to do the final update on the status, but the object is gone, so I suspect it's a finalizer issue. |
059a202
to
e4978c9
Compare
- get | ||
- apiGroups: | ||
- bpfman.io | ||
# resources: ['xdpnsprograms'] |
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.
Delete comment?
- create | ||
- delete | ||
- get | ||
- list |
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.
Adding watch here is what fixed it:
- list | |
- list | |
- watch |
resources: | ||
- bpfnsprograms/status | ||
verbs: | ||
- get |
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 didn't make a difference for the error I was seeing, but why not include list and watch?
- get | |
- get | |
- list | |
- watch |
For security reasons, cluster admins may want to limit certain applications to only loading eBPF programs within a given namespace. Currently, all bpfman Custom Resource Definitions (CRDs) are Cluster scoped. To provide cluster admins with tighter controls on eBPF program loading, some of the bpfman CRDs also need to be Namespace scoped. See Design Doc: bpfman/bpfman#1359 Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
e4978c9
to
7bfea5c
Compare
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.
/LGTM
For security reasons, cluster admins may want to limit certain applications to only loading eBPF programs within a given namespace. Currently, all bpfman Custom Resource Definitions (CRDs) are Cluster scoped. To provide cluster admins
with tighter controls on eBPF program loading, some of the bpfman CRDs also need to be Namespace scoped.
See Design Doc: bpfman/bpfman#1359