-
Notifications
You must be signed in to change notification settings - Fork 475
Description
Hi all! With this issue, I would like to understand the best way to update a TracingPolicy without losing protection.
Let's say I have a policy like this deployed in my cluster
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
name: "policy-1"
spec:
podSelector:
matchLabels:
app: "my-deployment-1"
kprobes:
- call: "security_bprm_creds_for_exec"
syscall: false
args:
- index: 0
type: "linux_binprm"
selectors:
- matchArgs:
- index: 0
operator: "NotEqual"
values:
- "/usr/bin/sleep"
- "/usr/bin/cat"
- "/usr/bin/my-server-1"
matchActions:
- action: Override
argError: -1
options:
- name: disable-kprobe-multi
value: "1"At a certain point, I need to add a new value to my list (e.g., /usr/bin/ls).
If I update the TracingPolicy CR, what should happen is that the collection associated with the policy is deleted (so all the ebpf progs are detached), and then a new collection with new values is deployed
tetragon/pkg/watcher/crdwatcher/tracingpolicy.go
Lines 97 to 110 in 9dea416
| update := func(oldTp, newTp tracingpolicy.TracingPolicy) { | |
| var namespace string | |
| if oldTpNs, ok := oldTp.(tracingpolicy.TracingPolicyNamespaced); ok { | |
| namespace = oldTpNs.TpNamespace() | |
| } | |
| if err := s.DeleteTracingPolicy(ctx, oldTp.TpName(), namespace); err != nil { | |
| log.Warn("updateTracingPolicy: failed to remove old policy", "old-name", oldTp.TpName(), logfields.Error, err) | |
| return | |
| } | |
| if err := s.AddTracingPolicy(ctx, newTp); err != nil { | |
| log.Warn("updateTracingPolicy: failed to add new policy", "new-name", newTp.TpName(), logfields.Error, err) | |
| return | |
| } |
So, if I understand the code well, there is a short interval in which the policy is no longer enforced in the system.
An alternative could be to create a new policy with a different name, with the updated list, and only when the new one is created, we delete the old one.
Does Tetragon provide an out-of-the-box solution for this kind of situation? Is using 2 policies the best solution to solve this issue?