TH小破站

  • 首页
  • 容器
    • 认识Docker
    • DockerFile详解
  • k8s
    • 认识Kubernetes
    • Kubernetes部署--(kubeadm方式)
    • kubeasz部署k8s集群
    • Ansible-binary部署k8s集群-1.31.2
  • Ceph
    • 认识分布式存储
    • CPEH部署
  • CI/CD
    • DevOps认识
    • 部署--Gitlab
  • ELK
    • ELK简介
    • Elasticsearch
    • Kibana部署
    • Logstash
    • ELK--收集 tomcat 日志(实战)
  • HD
    • 认识--大数据
    • Hadoop-单机部署
    • Hadoop-伪分布部署
    • Hadoop-完全分布部署
    • Hadoop-(HA)完全分布部署
    • Ambari自动部署--Hadoop
  • Nginx
    • Nginx功能介绍
    • Nginx安全选项
    • Nginx配置文件简单介绍
    • 网站服务器部署
  • 监控
    • ZABBIX-部署(yum)
    • ZABBIX-编译安装
  • 云计算
    • KVM 概述
    • OpenStack企业级部署(T版)
    • OpenStack之dashboard部署
    • OpenStack-controller的高可用
    • openstack(Caracal版_ubuntu版本)部署
  • 数据库
    • mariadb与mysql
    • mysql主从
    • MySQL--冷备(实战)
    • MySQL--热备(dump表)
    • MySQL--热备(dump库)
    • 数据恢复实战案例
    • Xtrabackup实现MySql8.x全量备份
    • MyCat实现数据库读写分离
    • MHA实现数据库高可用
    • Percona XtraDB(PXC)实现数据库集群高可用
    • 数据库压力测试
    • PostgreSQL 基操
    • PostgreSQL备份恢复
    • PostgreSQL高可用
    • MongDB安装配置基础使用
    • MongoDB实现复制集
    • MongoDB备份还原
  • 自动化
    • ssh远程服务原理及配置
    • Ansible剧本文件应用
    • Ansible管理服务介绍
    • Ansible自动化部署node_exporter(包含升级,回滚)
    • Saltstack-部署安装
  • 脚本
    • 一键查看服务器资源利用率
    • 一键生成SSL证书
    • 保存指定数量的文件/目录
    • 初始化服务器
    • 扫描可用IP
    • 批量分发SSH密钥
    • 监控多主机磁盘脚本
    • 一键安装MySQL8.x脚本
    • Python脚本监控ES集群
    • 资源巡检脚本
    • 查看各用户使用的cpu占比
热衷于分享
架构师成长之路 !!!
  1. 首页
  2. Kubernetes
  3. 正文

eBPF + Flaco(监测 K8S POD安全威胁)

2025年8月28日 838点热度 0人点赞 0条评论

监测 K8S 安全威胁

安装Flaco

添加Helm 仓库

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

安装

### 创建一个PVC
~/flaco# vim nfs-pvc-flaco.yaml 
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: falco-falcosidekick-ui-redis-data-falco-falcosidekick-ui-redis-0
  namespace: falco
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 2Gi
  storageClassName: nfs-csi-th

~/flaco# kubectl create ns falco
~/flaco# kubectl apply -f nfs-pvc-flaco.yaml 

### 安装
~/flaco# helm install falco -n falco --set driver.kind=ebpf --set tty=true falcosecurity/falco --set falcosidekick.enabled=true --set falcosidekick.webui.enabled=true --create-namespace --version 6.2.2
~/flaco# kubectl get po -n falco
NAME                                      READY   STATUS    RESTARTS   AGE
falco-falcosidekick-7687c75d94-89zrn      1/1     Running   0          36m
falco-falcosidekick-7687c75d94-btb5g      1/1     Running   0          36m
falco-falcosidekick-ui-5f585c96bb-ht6ll   1/1     Running   0          36m
falco-falcosidekick-ui-5f585c96bb-tnp89   1/1     Running   0          36m
falco-falcosidekick-ui-redis-0            1/1     Running   0          36m
falco-fvgzz                               2/2     Running   0          36m
falco-t6p75                               2/2     Running   0          36m

运行一个测试容器

~/flaco# cat flaco-deployment.yaml 
kind: Deployment
apiVersion: apps/v1
metadata:
  name: spring-boot-helloworld
  labels:
    app: spring-boot-helloworld
spec:
  replicas: 1
  selector:
    matchLabels:
      app: spring-boot-helloworld
  template:
    metadata:
      name: spring-boot-helloworld
      labels:
        app: spring-boot-helloworld
    spec:
      containers:
      - name: spring-boot-helloworld
        image: registry.cn-zhangjiakou.aliyuncs.com/tanghao-public/spring-boot-helloworld:v0.9.5
        ports:
        - name: http
          containerPort: 80
          protocol: TCP
---
kind: Service
apiVersion: v1
metadata:
  name: spring-boot-helloworld
  labels:
    app: spring-boot-helloworld
spec:
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80
  selector:
    app: spring-boot-helloworld

# kubectl apply -f flaco-deployment.yaml 

执行安全事件命令

~/flaco# kubectl exec -it spring-boot-helloworld-674f5fb6f-6rszh -- sh -c "uptime"
 15:42:37 up 1 day,  6:54,  0 users,  load average: 0.37, 0.35, 0.38

查看 flaco 输出的安全日志

~/flaco# kubectl logs -f -n falco falco-t6p75 
{"hostname":"k8s-node01","output":"15:30:45.285198582: Notice A shell was spawned in a container with an attached terminal | evt_type=execve user=root user_uid=0 user_loginuid=-1 process=sh proc_exepath=/bin/busybox parent=containerd-shim command=sh terminal=34816 exe_flags=EXE_WRITABLE|EXE_LOWER_LAYER container_id=023d6a7ef787 container_name=k8s_spring-boot-helloworld_spring-boot-helloworld-674f5fb6f-6rszh_default_cc16a26d-163b-4cfd-814e-c800fff89c1e_0 container_image_repository=registry.cn-zhangjiakou.aliyuncs.com/tanghao-public/spring-boot-helloworld container_image_tag=v0.9.5 k8s_pod_name=spring-boot-helloworld-674f5fb6f-6rszh k8s_ns_name=default","output_fields":{"container.id":"023d6a7ef787","container.image.repository":"registry.cn-zhangjiakou.aliyuncs.com/tanghao-public/spring-boot-helloworld","container.image.tag":"v0.9.5","container.name":"k8s_spring-boot-helloworld_spring-boot-helloworld-674f5fb6f-6rszh_default_cc16a26d-163b-4cfd-814e-c800fff89c1e_0","evt.arg.flags":"EXE_WRITABLE|EXE_LOWER_LAYER","evt.time":1755012645285198582,"evt.type":"execve","k8s.ns.name":"default","k8s.pod.name":"spring-boot-helloworld-674f5fb6f-6rszh","proc.cmdline":"sh -c uptime","proc.exepath":"/bin/busybox","proc.name":"sh","proc.pname":"containerd-shim","proc.tty":34816,"user.loginuid":-1,"user.name":"root","user.uid":0},"priority":"Notice","rule":"Terminal shell in container","source":"syscall","tags":["T1059","container","maturity_stable","mitre_execution","shell"],"time":"2025-08-12T15:30:45.285198582Z"}

转发 ui 界面

~/flaco# kubectl port-forward -n falco  svc/falco-falcosidekick-ui --address 0.0.0.0 8888:2802

标签: 暂无
最后更新:2025年8月28日

tanghao946

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复
文章目录
  • 监测 K8S 安全威胁
    • 安装Flaco
    • 运行一个测试容器
    • 查看 flaco 输出的安全日志
    • 转发 ui 界面

COPYRIGHT © 2025 TH小破站. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

渝ICP备2023013789号

渝公网安备50011702500926号