部署
Kubernetes UniAgent安装包
检查环境是否满足要求
首先检查Kubernetes的node节点(操作系统、可用CPU、可用内存、可用存储等)是否满足运行eBPF探针的最低要求。
Node节点内核版本:高于5.0版本
Node节点可用CPU: 1核以上
Node节点可用内存: 1GB以上
Node节点可用存储: 1GB以上
然后检查部署的kubernetes UniAgent版本。eBPF探针要求kubernetes UniAgent版本>=2.4.1.0 且平台需要开通Infra主机授权。默认情况下,eBPF探针功能是禁用的,需要手动开启。
开启eBPF探针
将tingyunagent.yaml中的tingyun-common-config
的ebpf_enabled: false
改为ebpf_enabled: true
。
apiVersion: v1
kind: ConfigMap
metadata:
name: tingyun-common-config
namespace: tingyun
data:
VERSION: |
2.4.1.0
tingyun-common.yaml: |
#是否启用EBPF网络数据收集功能,true或false
#如果开启EBPF功能,需要同时修改Daemonset tingyun-linux-agent的requests cpu为0.5, memory为1Gi,并重启Daemonset tingyun-linux-agent
ebpf_enabled: false #修改为true
修改tingyunagent.yaml中 Daemonset tingyun-linux-agent的requests cpu为0.5,memory为1GiB。
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: tingyun-linux-agent
namespace: tingyun
spec:
selector:
matchLabels:
vendor: tingyun
component: linux-agent
template:
spec:
containers:
- name: linux
image: tingyunagent/infra-agent:2.4.0.0
securityContext:
privileged: true
runAsUser: 0
resources:
limits:
cpu: "2"
memory: "2Gi"
requests:
cpu: "0.5" #修改cpu为0.5
memory: "1Gi" #修改memory为1Gi
然后使用yaml文件更新。
kubectl apply -f tingyunagent.yaml
当tingyunagent.yaml安装文件丢失时,可以使用edit configmap
命令修改配置。
kubectl edit configmap tingyun-common-config -n tingyun
确认eBPF探针是否启动。在每个node节点上执行:
kubectl -n tingyun exec -ti tingyun-linux-agent-xxxxx -- ps -ef | grep ebpf_agent | grep -v grep
如果进程存在,则表示EBPF探针已运行。如果进程不存在,则表示EBPF探针未运行。
查看eBPF探针日志
eBPF探针日志保存在Daemonset tingyun-linux-agent的pod中/opt/agent/ebpf
目录下。
查看工作日志:
kubectl -n tingyun exec -ti tingyun-linux-agent-vrtwk -- cat /opt/agent/ebpf/logs/ebpf-agent.log
查看熔断日志:
kubectl -n tingyun exec -ti tingyun-linux-agent-vrtwk -- cat /opt/agent/ebpf/restart.log
在低版本内核 4.15+ 上运行
如果操作系统版本比较低,例如 银河麒麟4.19 ,大概率会发现ebpf探针进程崩溃重复启动
/opt/agent/ebpf # tail -f restart.log
Thu Mar 6 18:19:83 2025: ebpf agent start, because of crash restart or blow recover
Thu Mar 6 18:20:83 2025: ebpf agent start, because of crash restart or blow recover
Thu Mar 6 18:21:83 2025: ebpf agent start, because of crash restart or blow recover
可以尝试使用兼容低版本ebpf内核的探针:vi 探针yaml,定位到 infra-agent 部分,添加下面配置,并注意格式对齐
command: ["sh","-c","cp -f /opt/agent/ebpf/bin/tingyun_probe_safe.o /opt/agent/ebpf/bin/tingyun_probe.o && sh /opt/agent/linux/start.sh"]
最终yaml类似如下:
containers:
- name: linux
image: goinline.cn/tingyunagent/infra-agent:2.5.0.1
imagePullPolicy: IfNotPresent
command: ["sh","-c","cp -f /opt/agent/ebpf/bin/tingyun_probe_safe.o /opt/agent/ebpf/bin/tingyun_probe.o && sh /opt/agent/linux/start.sh"] # 添加这行配置
securityContext:
privileged: true
runAsUser: 0
更新yaml后,观察ebpf探针进程是否正常启动,如果仍旧崩溃重复启动,说明在此系统上无法支持eBPF网络功能。