diff --git a/charts/agent/templates/_helpers.tpl b/charts/agent/templates/_helpers.tpl index c96aaee12..c0cff5649 100644 --- a/charts/agent/templates/_helpers.tpl +++ b/charts/agent/templates/_helpers.tpl @@ -224,13 +224,13 @@ it can act like a boolean {{- end -}} {{- define "agent.universalEbpfEnforced" -}} - {{- if (and (eq "true" (include "agent.ebpfEnabled" .)) (eq "universal" .Values.ebpf.kind )) -}} + {{- if (and (eq "true" (include "agent.ebpfEnabled" .)) (or (eq "universal" .Values.ebpf.kind ) (eq "universal_ebpf" .Values.ebpf.kind ))) -}} true {{- end -}} {{- end -}} {{- define "agent.legacyEbpfEnforced" -}} - {{- if (and (eq "true" (include "agent.ebpfEnabled" .)) (eq "legacy" .Values.ebpf.kind )) -}} + {{- if (and (eq "true" (include "agent.ebpfEnabled" .)) (or (eq "legacy" .Values.ebpf.kind ) (eq "legacy_ebpf" .Values.ebpf.kind ))) -}} true {{- end -}} {{- end -}} diff --git a/charts/agent/tests/universal_ebpf_test.yaml b/charts/agent/tests/universal_ebpf_test.yaml index 1d003bf0a..917840a68 100644 --- a/charts/agent/tests/universal_ebpf_test.yaml +++ b/charts/agent/tests/universal_ebpf_test.yaml @@ -30,6 +30,7 @@ tests: - isNull: path: spec.template.spec.containers[*].env[?(@.name == "SYSDIG_AGENT_DRIVER")] + # TODO: remove before merge - it: Ensure that when the eBPF is enabled and we specify to use the "legacy" driver we create the sysdig container with the SYSDIG_BPF_PROBE and with SYSDIG_AGENT_DRIVER environment variables set: ebpf: @@ -47,6 +48,24 @@ tests: path: spec.template.spec.containers[*].env[?(@.name == "SYSDIG_AGENT_DRIVER")].value value: legacy_ebpf + - it: Ensure that when the eBPF is enabled and we specify to use the "legacy_ebpf" driver we create the sysdig container with the SYSDIG_BPF_PROBE and with SYSDIG_AGENT_DRIVER environment variables + set: + ebpf: + enabled: true + kind: legacy + asserts: + - isEmpty: + path: spec.template.spec.initContainers[*].env[?(@.name == "SYSDIG_BPF_PROBE")].value + - equal: + path: spec.template.spec.initContainers[*].env[?(@.name == "SYSDIG_AGENT_DRIVER")].value + value: legacy_ebpf + - isEmpty: + path: spec.template.spec.containers[*].env[?(@.name == "SYSDIG_BPF_PROBE")].value + - equal: + path: spec.template.spec.containers[*].env[?(@.name == "SYSDIG_AGENT_DRIVER")].value + value: legacy_ebpf + + # TODO: remove before merge - it: Ensure that when the eBPF is enabled and we specify to use the "universal" driver we create the sysdig container without the SYSDIG_BPF_PROBE and with the SYSDIG_AGENT_DRIVER environment variables set: ebpf: @@ -59,6 +78,28 @@ tests: path: spec.template.spec.containers[*].env[?(@.name == "SYSDIG_AGENT_DRIVER")].value value: universal_ebpf + - it: Ensure that when the eBPF is enabled and we specify to use the "universal_ebpf" driver we create the sysdig container without the SYSDIG_BPF_PROBE and with the SYSDIG_AGENT_DRIVER environment variables + set: + ebpf: + enabled: true + kind: universal_ebpf + asserts: + - isNull: + path: spec.template.spec.containers[*].env[?(@.name == "SYSDIG_BPF_PROBE")] + - equal: + path: spec.template.spec.containers[*].env[?(@.name == "SYSDIG_AGENT_DRIVER")].value + value: universal_ebpf + + - it: Ensure that when the eBPF is enabled and we specify to use the "universal_ebpf" driver we don't create the init container + set: + ebpf: + enabled: true + kind: universal_ebpf + asserts: + - isNull: + path: spec.template.spec.initContainers + + # TODO: remove before merge - it: Ensure that when the eBPF is enabled and we specify to use the "universal" driver we don't create the init container set: ebpf: @@ -68,6 +109,17 @@ tests: - isNull: path: spec.template.spec.initContainers + - it: Ensure that when the eBPF is enabled and we specify to use the "legacy_ebpf" driver we create the init container + set: + ebpf: + enabled: true + kind: legacy_ebpf + asserts: + - matchRegex: + path: spec.template.spec.initContainers[*].image + pattern: quay.io/sysdig/agent-kmodule:.* + + # TODO: remove before merge - it: Ensure that when the eBPF is enabled and we specify to use the "legacy" driver we create the init container set: ebpf: @@ -78,6 +130,17 @@ tests: path: spec.template.spec.initContainers[*].image pattern: quay.io/sysdig/agent-kmodule:.* + - it: Ensure that when the eBPF is enabled and we specify to use the "universal_ebpf" driver we use the slim container + set: + ebpf: + enabled: true + kind: universal_ebpf + asserts: + - matchRegex: + path: spec.template.spec.containers[*].image + pattern: quay.io/sysdig/agent-slim:.* + + # TODO: remove before merge - it: Ensure that when the eBPF is enabled and we specify to use the "universal" driver we use the slim container set: ebpf: @@ -88,6 +151,19 @@ tests: path: spec.template.spec.containers[*].image pattern: quay.io/sysdig/agent-slim:.* + - it: Ensure that when the eBPF is enabled and we specify to use the "universal_ebpf" driver we use the slim container also if is slim container is not enabled + set: + slim: + enabled: false + ebpf: + enabled: true + kind: universal_ebpf + asserts: + - matchRegex: + path: spec.template.spec.containers[*].image + pattern: quay.io/sysdig/agent-slim:.* + + # TODO: remove before merge - it: Ensure that when the eBPF is enabled and we specify to use the "universal" driver we use the slim container also if is slim container is not enabled set: slim: diff --git a/charts/agent/values.schema.json b/charts/agent/values.schema.json index 012f92cef..6543c02fc 100644 --- a/charts/agent/values.schema.json +++ b/charts/agent/values.schema.json @@ -20,7 +20,9 @@ "enum": [ "auto", "legacy", - "universal" + "universal", + "legacy_ebpf", + "universal_ebpf" ] } } diff --git a/charts/agent/values.yaml b/charts/agent/values.yaml index bbb30b77b..96dd0838a 100644 --- a/charts/agent/values.yaml +++ b/charts/agent/values.yaml @@ -170,7 +170,7 @@ ebpf: # Enable eBPF support for Sysdig Agent enabled: false - # Define the kind of eBPF driver that can be used in the agent. Can be `auto`, `legacy` or `universal` + # Define the kind of eBPF driver that can be used in the agent. Can be `auto`, `legacy_ebpf` or `universal_ebpf` kind: auto slim: