Skip to content

Commit 3edbdfe

Browse files
committed
WIP
1 parent 057ece6 commit 3edbdfe

5 files changed

Lines changed: 37 additions & 7 deletions

File tree

charts/internal/falco/templates/0helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Return the proper Falco image name
8989
{{- . }}/
9090
{{- end -}}
9191
{{- .Values.image.repository }}:
92-
{{- .Values.image.tag | default (printf "%s" .Chart.AppVersion) -}}
92+
{{- .Values.image.tag | default .Chart.AppVersion -}}
9393
{{- end -}}
9494

9595
{{/*

charts/internal/falco/templates/falco-configmap.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ data:
1212
{{- include "falco.gardenerManagedRules" . }}
1313
{{- end }}
1414
{{- toYaml .Values.falco | nindent 4 }}
15+
{{- include "falco.containerPlugin" . -}}
16+
{{- include "k8smeta.configuration" . -}}
17+
18+

charts/internal/falco/templates/falco-pod-template.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,8 @@ spec:
424424
{{- $securityContext := set $securityContext "privileged" true -}}
425425
{{- end -}}
426426
{{- end -}}
427-
{{- if eq .Values.driver.kind "modern-bpf" -}}
428-
{{- if .Values.driver.modern_bpf.leastPrivileged -}}
427+
{{- if (or (eq .Values.driver.kind "modern_ebpf") (eq .Values.driver.kind "modern-bpf")) -}}
428+
{{- if .Values.driver.modernEbpf.leastPrivileged -}}
429429
{{- $securityContext := set $securityContext "capabilities" (dict "add" (list "BPF" "SYS_RESOURCE" "PERFMON" "SYS_PTRACE")) -}}
430430
{{- else -}}
431431
{{- $securityContext := set $securityContext "privileged" true -}}

charts/internal/falco/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ driver:
202202
# Read more on that here: https://falco.org/docs/event-sources/kernel/#least-privileged-mode-1
203203
leastPrivileged: false
204204
# -- Configuration section for modern bpf driver.
205-
modern_bpf:
205+
modernEbpf:
206206
# -- Constrain Falco with capabilities instead of running a privileged container.
207207
# Ensure the modern bpf driver is enabled (i.e., setting the `driver.kind` option to `modern-bpf`).
208208
# Capabilities used: {CAP_SYS_RESOURCE, CAP_BPF, CAP_PERFMON, CAP_SYS_PTRACE}.
209-
# Read more on that here: https://falco.org/docs/event-sources/kernel/#least-privileged-mode-2
209+
# Read more on that here: https://falco.org/docs/setup/container/#docker-least-privileged-ebpf-probe
210210
leastPrivileged: false
211211
# -- bufSizePreset determines the size of the shared space between Falco and its drivers.
212212
# This shared space serves as a temporary storage for syscall events.

pkg/values/falcovalues.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"strconv"
1616
"strings"
1717

18+
semver3 "github.com/Masterminds/semver/v3"
1819
"github.com/gardener/gardener/extensions/pkg/controller"
1920
"github.com/gardener/gardener/pkg/extensions"
2021
"github.com/go-logr/logr"
@@ -234,8 +235,11 @@ func (c *ConfigBuilder) BuildFalcoValues(ctx context.Context, log logr.Logger, c
234235
"networking.gardener.cloud/to-falcosidekick": "allowed",
235236
},
236237
"priorityClassName": *c.config.Falco.PriorityClassName,
237-
"driver": map[string]string{
238-
"kind": "modern-bpf",
238+
"driver": map[string]any{
239+
"kind": "modern_ebpf",
240+
"loader": map[string]bool{
241+
"enabled": false,
242+
},
239243
},
240244
"image": map[string]string{
241245
"image": falcoImage,
@@ -250,6 +254,12 @@ func (c *ConfigBuilder) BuildFalcoValues(ctx context.Context, log logr.Logger, c
250254
"docker": map[string]bool{
251255
"enabled": false,
252256
},
257+
"containerd": map[string]bool{
258+
"enabled": true,
259+
},
260+
"containerEngine": map[string]bool{
261+
"enabled": false,
262+
},
253263
},
254264
"extra": map[string]interface{}{
255265
"env": []map[string]string{
@@ -300,6 +310,9 @@ func (c *ConfigBuilder) BuildFalcoValues(ctx context.Context, log logr.Logger, c
300310
if err := c.generateHeartbeatRule(falcoChartValues, falcoServiceConfig, falcoVersion); err != nil {
301311
return nil, err
302312
}
313+
if err := c.enableContainerPlugin(falcoChartValues, falcoVersion); err != nil {
314+
return nil, err
315+
}
303316
return falcoChartValues, nil
304317
}
305318

@@ -371,6 +384,19 @@ func (c *ConfigBuilder) generateHeartbeatRule(falcoChartValues map[string]interf
371384
return nil
372385
}
373386

387+
func (c *ConfigBuilder) enableContainerPlugin(falcoChartValues map[string]interface{}, falcoVersion *string) error {
388+
constraint, _ := semver3.NewConstraint(">= 0.41.2")
389+
v, err := semver3.NewVersion(*falcoVersion)
390+
if err != nil {
391+
return fmt.Errorf("invalid falco version %s: %w", *falcoVersion, err)
392+
}
393+
if constraint.Check(v) {
394+
falcoChartValues["collectors"].(map[string]any)["containerEngine"].(map[string]bool)["enabled"] = true
395+
falcoChartValues["collectors"].(map[string]any)["containerd"].(map[string]bool)["enabled"] = false
396+
}
397+
return nil
398+
}
399+
374400
func (c *ConfigBuilder) generateStandardRules(falcoChartValues map[string]interface{}, falcoServiceConfig *apisservice.FalcoServiceConfig, falcoVersion *string) error {
375401
if falcoServiceConfig.Rules.StandardRules != nil {
376402
for _, rule := range *falcoServiceConfig.Rules.StandardRules {

0 commit comments

Comments
 (0)