需要检测容器内的异常进程、文件访问、网络连接和提权行为。Falco 基于 eBPF 或内核模块采集系统调用,按规则告警,适合 Kubernetes 运行时安全。
helm repo add falcosecurity https://falcosecurity.github.io/charts
helm install falco falcosecurity/falco \
--namespace falco --create-namespace \
--set driver.kind=ebpf \
--set tty=true
kubectl -n falco get pods
kubectl -n falco logs -l app.kubernetes.io/name=falco -f
helm upgrade falco falcosecurity/falco \
--namespace falco \
--set falcosidekick.enabled=true \
--set falcosidekick.config.slack.webhookurl='https://hooks.slack.com/...'
kubectl -n falco create configmap falco-rules \
--from-file=custom_rules.yaml=./custom_rules.yaml
规则示例:
- rule: Shell in container
desc: Detect shell spawned in container
condition: spawned_process and container and shell_procs
output: Shell spawned (user=%user.name container=%container.name command=%proc.cmdline)
priority: WARNING
- rule: Shell in container
exceptions:
- name: known_admin
fields: [container.name, proc.cmdline]
values:
- [debug-tools, "/bin/sh -c echo ok"]
sh 能触发告警。proc.cmdline 和容器白名单,正常运维操作被当成攻击。falco — 运行时检测falcosidekick — 告警转发kubectl — 查看 Pod 和规则helm — 安装和升级bpftool — 检查 eBPF 程序