falco

by Helm

Helm chartv9.2.2App 0.45.2

Falco

About this chart

Falco

Falco is a Cloud Native Runtime Security tool designed to detect anomalous activity in your applications. You can use Falco to monitor runtime security of your Kubernetes applications and internal components.

Introduction

The deployment of Falco in a Kubernetes cluster is managed through a Helm chart. This chart manages the lifecycle of Falco in a cluster by handling all the k8s objects needed by Falco to be seamlessly integrated in your environment. Based on the configuration in values.yaml file, the chart will render and install the required k8s objects. Keep in mind that Falco could be deployed in your cluster using a daemonset or a deployment. See next sections for more info.

Attention

Before installing Falco in a Kubernetes cluster, a user should check that the kernel version used in the nodes is supported by the community. Also, before reporting any issue with Falco (missing kernel image, CrashLoopBackOff and similar), make sure to read about the driver section and adjust your setup as required.

Adding falcosecurity repository

Before installing the chart, add the falcosecurity charts repository:

helm repo add falcosecurity https://falcosecurity.github.io/charts
helm repo update

Installing the Chart

To install the chart with the release name falco in namespace falco run:

helm install falco falcosecurity/falco \
    --create-namespace \
    --namespace falco

After a few minutes Falco instances should be running on all your nodes. The status of Falco pods can be inspected through kubectl:

kubectl get pods -n falco -o wide

If everything went smoothly, you should observe an output similar to the following, indicating that all Falco instances are up and running in you cluster:

NAME          READY   STATUS    RESTARTS   AGE     IP          NODE            NOMINATED NODE   READINESS GATES
falco-57w7q   1/1     Running   0          3m12s   10.244.0.1   control-plane   <none>           <none>
falco-h4596   1/1     Running   0          3m12s   10.244.1.2   worker-node-1   <none>           <none>
falco-kb55h   1/1     Running   0          3m12s   10.244.2.3   worker-node-2   <none>           <none>

The cluster in our example has three nodes, one control-plane node and two worker nodes. The default configuration in values.yaml of our helm chart deploys Falco using a daemonset. That's the reason why we have one Falco pod in each node.

Tip: List Falco release using helm list -n falco, a release is a name used to track a specific deployment.

Falco, Event Sources and Kubernetes

Starting from Falco 0.31.0 the new plugin system is stable and production ready. The plugin system can be seen as the next step in the evolution of Falco. Historically, Falco monitored system events from the kernel trying to detect malicious behaviors on Linux systems. It also had the capability to process k8s Audit Logs to detect suspicious activities in Kubernetes clusters. Since Falco 0.32.0 all the related code to the k8s Audit Logs in Falco was removed and ported in a plugin. At the time being Falco supports different event sources coming from plugins or drivers (system events).

Note that a Falco instance can handle multiple event sources in parallel. you can deploy Falco leveraging drivers for syscall events and at the same time loading plugins. A step by step guide on how to deploy Falco with multiple sources can be found here.

About Drivers

Falco needs a driver to analyze the system workload and pass security events to userspace. The supported drivers are:

The driver must be loaded on the node where Falco is running. Falco now prefers the Modern eBPF probe by default. When using falcoctl with driver.kind=auto, it will automatically choose the best driver for your system. Specifically, it first attempts to use the Modern eBPF probe (which is shipped directly within the Falco binary) and will fall back to the kernel module if the necessary BPF features are not available.

Pre-built drivers

The kernel-crawler automatically discovers kernel versions and flavors. At the time being, it runs weekly. We have a site where users can check for the discovered kernel flavors and versions, example for Amazon Linux 2.

The discovery of a kernel version by the kernel-crawler does not imply that pre-built kernel modules are available. That is because once kernel-crawler has discovered new kernels versions, the drivers need to be built by jobs running on our Driver Build Grid infra. Please keep in mind that the building process is based on best effort. Users can check the existence of prebuilt modules at the following link.

Building the driver on the fly (fallback)

If a prebuilt driver is not available for your distribution/kernel, users can build the driver by them self or install the kernel headers on the nodes, and the init container (falco-driver-loader) will try and build the driver on the fly.

Falco needs kernel headers installed on the host as a prerequisite to build the driver on the fly correctly. You can find instructions for installing the kernel headers for your system under the Install section of the official documentation.

Selecting a different driver loader image

Note that since Falco 0.36.0 and Helm chart version 3.7.0 the driver loader image has been updated to be compatible with newer kernels (5.x and above) meaning that if you have an older kernel version and you are trying to build the kernel module you may experience issues. In that case you can use an alternative falco-driver-loader image flavor (e.g. falcosecurity/falco-driver-loader:latest-buster) to use an older version of the toolchain. To do so you can set the appropriate value, i.e. --set driver.loader.initContainer.image.tag=latest-buster. For more information please refer to the documentation regarding the currently supported images.

About Plugins

Plugins are used to extend Falco to support new data sources. The current plugin framework supports plugins with the following capabilities:

  • Event sourcing capability;
  • Field extraction capability;

Plugin capabilities are composable, we can have a single plugin with both capabilities. Or on the other hand, we can load two different plugins each with its capability, one plugin as a source of events and another as an extractor. A good example of this is the Kubernetes Audit Events and the Falcosecurity Json plugins. By deploying them both we have support for the K8s Audit Logs in Falco

Note that the driver is not required when using plugins.

About Falco Artifacts

Historically rules files and plugins used to be shipped inside the Falco docker image and/or inside the chart. Starting from version v0.3.0 of the chart, the falcoctl tool can be used to install/update rules files and plugins. When referring to such objects we will use the term artifact. For more info please check out the following proposal.

The default configuration of the chart for new installations is to use the falcoctl tool to handle artifacts. The chart will deploy two new containers along the Falco one:

  • falcoctl-artifact-install an init container that makes sure to install the configured artifacts before the Falco container starts;
  • falcoctl-artifact-follow a sidecar container that periodically checks for new artifacts (currently only falco-rules) and downloads them;

For more info on how to enable/disable and configure the falcoctl tool checkout the config values here and the upgrading notes

Deploying Falco in Kubernetes

After the clarification of the different event sources and how they are consumed by Falco using the drivers and the plugins, now let us discuss how Falco is deployed in Kubernetes.

The chart deploys Falco using a daemonset or a deployment depending on the event sources.

Daemonset

When using the drivers, Falco is typically deployed as a DaemonSet. By using a DaemonSet, Kubernetes ensures that a Falco instance is running on each node even as new nodes are added to your cluster. This makes it a perfect fit for monitoring across the entire cluster.

By default, with driver.kind=auto, the correct driver will will be automatically selected for each node. This is accomplished through the driver loader (implemented by falcoctl), which generates a new Falco configuration file and picks the right engine driver (Modern eBPF or kmod) based on the underlying environment. If you prefer to manually force a specific driver, see the other available options below.

Kernel module

To run Falco with the kernel module you just need to set driver.kind=kmod as shown in the following snippet:

helm install falco falcosecurity/falco \
    --create-namespace \
    --namespace falco
    --set driver.kind=kmod

Modern eBPF probe

To run Falco with the modern eBPF probe you just need to set driver.kind=modern_bpf as shown in the following snippet:

helm install falco falcosecurity/falco \
    --create-namespace \
    --namespace falco \
    --set driver.kind=modern_ebpf

Deployment

In the scenario when Falco is used with plugins as data sources, then the best option is to deploy it as a k8s deployment. Plugins could be of two types, the ones that follow the push model or the pull model. A plugin that adopts the first model expects to receive the data from a remote source in a given endpoint. They just expose and endpoint and wait for data to be posted, for example Kubernetes Audit Events expects the data to be sent by the k8s api server when configured in such way. On the other hand other plugins that abide by the pull model retrieves the data from a given remote service. The following points explain why a k8s deployment is suitable when deploying Falco with plugins:

  • need to be reachable when ingesting logs directly from remote services;
  • need only one active replica, otherwise events will be sent/received to/from different Falco instances;

Uninstalling the Chart

To uninstall a Falco release from your Kubernetes cluster always you helm. It will take care to remove all components deployed by the chart and clean up your environment. The following command will remove a release called falco in namespace falco;

helm uninstall falco --namespace falco

Showing logs generated by Falco container

There are many reasons why we would have to inspect the messages emitted by the Falco container. When deployed in Kubernetes the Falco logs can be inspected through:

kubectl logs -n falco falco-pod-name

where falco-pods-name is the name of the Falco pod running in your cluster. The command described above will just display the logs emitted by falco until the moment you run the command. The -f flag comes handy when we are doing live testing or debugging and we want to have the Falco logs as soon as they are emitted. The following command:

kubectl logs -f -n falco falco-pod-name

The -f (--follow) flag follows the logs and live stream them to your terminal and it is really useful when you are debugging a new rule and want to make sure that the rule is triggered when some actions are performed in the system.

If we need to access logs of a previous Falco run we do that by adding the -p (--previous) flag:

kubectl logs -p -n falco falco-pod-name

A scenario when we need the -p (--previous) flag is when we have a restart of a Falco pod and want to check what went wrong.

Enabling real time logs

By default in Falco the output is buffered. When live streaming logs we will notice delays between the logs output (rules triggering) and the event happening. In order to enable the logs to be emitted without delays you need to set .Values.tty=true in values.yaml file.

K8s-metacollector

Starting from Falco 0.37 the old k8s-client has been removed. A new component named k8s-metacollector replaces it. The k8s-metacollector is a self-contained module that can be deployed within a Kubernetes cluster to perform the task of gathering metadata from various Kubernetes resour

Deploy falco with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has falco on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartfalco is pinned at v9.2.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply