
Monitoring your EKS clusters audit logs
This blog post is an update of a post of November 2022
At the beginning of the year 2022, Falco introduced a game changing feature, the Falco Plugins. They allow Falco to monitor and trigger alerts for any kind of event. Since the launch of the new plugin framework the Falco community has collaborated to create plugins for Github, AWS CloudTrail and Okta. A plugin has also replaced the way Falco consumes the Audit Logs generated by a K8s API server through a dedicated plugin. With these plugins, Falco covers more in depth the aspects of your infrastructure and allows you to use a single syntax for rules.
For months (okay, maybe years...), our adopters have asked us for a way to monitor K8s Audit Logs. The previous implementation used an internal web server to receive the logs from the Kubernetes API, although it was functional, it was a very manual process to install and manage clusters. This method didn't support clusters managed by cloud providers, such as EKS, AKS, or GKE as they had to capture the Audit Logs for their own usage and then add them to their log aggregators.
This situation is now solved thanks to the plugin framework and we're proud to announce the first release of the plugin for EKS Audit Logs: k8saudit-eks
!!!
How it works
AWS captures the Audit Logs and exposes them in the CloudWatch Logs service. We have made available libs to create a clean session with the AWS API and pull logs from the relevant Cloudwatch Logs Stream. You can reuse these libs for any plugin you'd like to create for any Amazon service.
Usage
The configuration for the usage of the plugin is:
With:
init_config
:- profile: The Profile to use to create the session, env var AWS_PROFILE if present
- region: The Region of your EKS cluster, env var AWS_REGION is used if present
- use_async: If true then async extraction optimization is enabled (Default: true)
- polling_interval: Polling Interval in seconds (default: 5s)
- shift: Time shift in past in seconds (default: 1s)
- buffer_size: Buffer Size (default: 200)
open_params
: A string which contains the name of your EKS Cluster (required).
If you run Falco inside an EKS cluster with a setup of an OIDC provider, the profile and region parameters can be omitted in favor of a service account
+ IAM Role (see the official docs).
IAM
Whatever the method you use for the authentication to the AWS API, you need to set up this minimal policy to your user/role:
With:
REGION
: The Region of your EKS clusterACCOUNT_ID
: The ID of the account running the EKS clusterCLUSTER_NAME
: The name of your cluster EKS cluster (same value than in your plugin configuration)
Default Rules
A good thing about Kubernetes is that it brings standards into our industry. Despite a few differences, the cluster works in the same way and produces the same format of logs. This helps us enormously. By creating the k8saudit plugin we declared the fields to extract, as well as some default rules, which we can reuse for any plugin that consumes the same Audit Logs. It is a time saver for both, developers and adopters.
You can find the proposed default rules here.
Installation
For the installation, we'll use falcoctl
. We can use it as a CLI tool for a locale installation or as a sidecar for Kubernetes. See this blog post for more information.
Local installation
In this example, we'll see how to install the k8saudit-eks
in a local host.
First, add the index of artifacts for falcoctl
:
Install the latest version of the plugins:
As the output notices, the plugins will be now available in /usr/share/plugins
:
After installing the k8saudit-eks
plugin, we also need to install the rules that it uses. (Those rules are the same as the k8saudit
plugin rules.):
And we get the rules in /etc/falco
:
By default, the installation of a ruleset comes with the associated plugins. In this blog, we have installed them on our own, this is why --resolve-deps
is set to false.
We now have the plugins and rules in our system. The last step is to configure Falco to use them.
Modify your /etc/yaml
to make it looks like the following (with the relevant values for REGION
, ACCOUNT_ID
, and CLUSTER_NAME
):
You can now start Falco ( sudo /usr/bin/falco --disable-source syscall
) and monitor the audit logs of your EKS cluster:
In this example, we also disable the collection of the syscalls with the option --disable-source syscall
. The k8saudit-eks
plugin works with a pull
model, you should have only one Falco instance collecting the audit logs to avoid any duplication of alerts. We dedicate that instance to that role.
And get alerts:
Kubernetes installation
Next, we will see how to install the k8saudit-eks
plugin with the falcoctl
tool in a Kubernetes setup. We'll use the official Helm chart with the following values.yaml
file:
Let's look into this configuration section by section:
With EKS, we can use an OIDC provider and annotations on the service accounts to allow access to the AWS API ( see the official docs). This section allows you to set which ROLE_ARN
to use.
As the local installation, this section sets the used plugins.
To collect and monitor all the syscalls, Falco must be deployed as a DaemontSet in your cluster, to have one instance per Kernel. In this example, we're deploying Falco with the k8saudit-eks
plugin, which relies on a pull
model. To avoid several Falco pods to collect the same audit logs and duplicate the alerts, we MUST install Falco with the k8saudit-eks
plugin only once. The Helm chart allows to use a one replica deployment and to disable the syscalls and K8s metdadata collections, this is the purpose of this section.
The last section sets up falcoctl
. It will install the requested plugins and rules and track new versions of the rules.
Now you can run your helm install command:
And see the result:
Disclaimer
Our tests noticed some latencies between the presence of the logs in the CloudWatch Logs Stream and their evaluation by Falco. This is more visible with highly requested API servers. The solution is to adapt the size of your nodes where Falco runs, considering a minimal size of 2xlarge
as a safe option.
Conclusion
With this first Plugin for a managed K8s solution, we hope to open the door for new contributions from the community for other flavors like GKE and AKS. If you need to create a plugin for another AWS service, take also a look at the libs we created to help the developers.
You can find us in the Falco community. Please feel free to reach out to us for any questions, suggestions, or even for a friendly chat!
If you would like to find out more about Falco:
- Get started in Falco.org
- Check out the Falco project in GitHub.
- Get involved in the Falco community.
- Meet the maintainers on the Falco Slack.
- Follow @falco_org on Twitter.