Skip to content

Commit ad978cb

Browse files
authored
Adds falcosidekick to the integration test (#17)
The falcosidekick helm chart doesn't pass any arguments to falcosidekick, but we've set the --help as the default argument, meaning that it won't start up as intended. falcosidekick helm chart also creates a deployment with readOnlyRootFilesystem=True set, which means that Pebble won't be able to copy its necessary files. We can use the Pebble mutating webhook to solve this issue.
1 parent 606d024 commit ad978cb

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

falcosidekick/2.29.0/rockcraft.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ services:
2828
startup: enabled
2929
# falcosidekick user and group is created, and the workdir is set in its home.
3030
# https://github.com/falcosecurity/falcosidekick/blob/2.29.0/Dockerfile#L14
31-
command: "/home/falcosidekick/app/falcosidekick [ --help ]"
31+
command: "/home/falcosidekick/app/falcosidekick"
3232
on-success: shutdown
3333
on-failure: shutdown
3434

35-
entrypoint-service: falcosidekick
36-
3735
parts:
3836
# https://github.com/falcosecurity/falcosidekick/blob/2.29.0/Dockerfile#L8
3937
falcosidekick-user:

tests/integration/test_falco.py

+66
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ def _get_event_generator_helm_cmd():
3434
)
3535

3636

37+
def _get_falcosidekick_helm_cmd():
38+
falcosidekick_rock = env_util.get_build_meta_info_for_rock_version(
39+
"falcosidekick", "2.29.0", "amd64"
40+
)
41+
42+
images = [
43+
k8s_util.HelmImage(falcosidekick_rock.image),
44+
]
45+
46+
set_configs = [
47+
"webui.enabled=true",
48+
]
49+
50+
return k8s_util.get_helm_install_command(
51+
"falcosidekick",
52+
"falcosidekick",
53+
namespace="falco",
54+
repository="https://falcosecurity.github.io/charts",
55+
images=images,
56+
set_configs=set_configs,
57+
split_image_registry=True,
58+
)
59+
60+
3761
def _get_falco_helm_cmd(falco_version: str):
3862
falco_rock = env_util.get_build_meta_info_for_rock_version(
3963
"falco", falco_version, "amd64"
@@ -69,6 +93,33 @@ def _get_falco_helm_cmd(falco_version: str):
6993
)
7094

7195

96+
def _assert_falcosidekick_up(instance: harness.Instance):
97+
# Assert that falcosidekick is responsive. It has a ping method, to which we should get pong.
98+
# The falcosidekick image does not have curl or wget, but the falco image does.
99+
LOG.info("Checking if Falco detected irregularities.")
100+
process = instance.exec(
101+
[
102+
"k8s",
103+
"kubectl",
104+
"--namespace",
105+
"falco",
106+
"exec",
107+
f"{constants.K8S_DAEMONSET}/falco",
108+
"--",
109+
"curl",
110+
"-s",
111+
"http://falcosidekick:2801/ping",
112+
],
113+
check=True,
114+
capture_output=True,
115+
text=True,
116+
)
117+
118+
assert (
119+
"pong" in process.stdout
120+
), "Expected falcosidekick to respond with pong to ping."
121+
122+
72123
def _assert_falco_logs(instance: harness.Instance):
73124
# Falco should have noticed the unexpected behaviour from the event-generator, and it should
74125
# have logged these events to stdout by default.
@@ -116,12 +167,26 @@ def _assert_falco_logs(instance: harness.Instance):
116167

117168
@pytest.mark.parametrize("image_version", ["0.38.2", "0.39.0"])
118169
def test_integration_falco(function_instance: harness.Instance, image_version):
170+
# falcosidekick has readOnlyRootFilesystem=True, which means Pebble won't be able
171+
# to copy its necessary files. This mutating webhook solves this issue by adding
172+
# an emptydir volume to Pods for Pebble to use.
173+
k8s_util.install_mutating_pebble_webhook(function_instance)
174+
119175
# Deploy Falco helm chart and wait for it to become active.
120176
function_instance.exec(_get_falco_helm_cmd(image_version))
121177

178+
# Deploy falcosidekick helm chart and wait for it to become active.
179+
function_instance.exec(_get_falcosidekick_helm_cmd())
180+
122181
# Wait for the daemonset to become Active.
123182
k8s_util.wait_for_daemonset(function_instance, "falco", "falco", retry_times=10)
124183

184+
# Wait for the deployments to become Active.
185+
for deployment in ["falcosidekick", "falcosidekick-ui"]:
186+
k8s_util.wait_for_deployment(
187+
function_instance, deployment, "falco", retry_times=10
188+
)
189+
125190
# Deploy event-generator for Falco and wait for it to become active.
126191
function_instance.exec(_get_event_generator_helm_cmd())
127192

@@ -136,3 +201,4 @@ def test_integration_falco(function_instance: harness.Instance, image_version):
136201
)
137202

138203
_assert_falco_logs(function_instance)
204+
_assert_falcosidekick_up(function_instance)

0 commit comments

Comments
 (0)