Kubernetes eBPF 安装
概述
ebpf-agent 可以部署在 Kubernetes 集群中,用于采集集群内系统和应用的 metrics、logs 数据。
系统要求
前置条件
- 已安装 light-agent(可以在集群内或集群外)
- Kubernetes 集群可以访问镜像仓库
- 具有集群的管理员权限
镜像准备
根据 light-agent 的安装位置选择相应的镜像准备方式:
light-agent 在集群内
如果 light-agent 安装在 Kubernetes 集群中,安装时已经将相关镜像导入到集群可访问的仓库中,无需额外操作。
light-agent 在集群外
请参考 Kubernetes 安装 light-agent 中的镜像推送步骤,将 ebpf-agent 镜像推送到集群可访问的仓库。
安装步骤
1. 获取部署模板
# 将 <Lighthouse IP> 替换为 Lighthouse 平台的实际 IP 地址
curl -O http://<Lighthouse IP>/downloads/k8s/ebpf-agent-template.yaml
2. 生成部署配置
COLLECTOR_SERVER_IP=<Lighthouse IP> \
REGISTRY_REPO=<your_registry_url> \
REGISTRY_CRED=<registry_cred_str> \
envsubst '${REGISTRY_REPO} ${COLLECTOR_SERVER_IP} ${REGISTRY_CRED}' \
<ebpf-agent-template.yaml >ebpf-agent.yaml
参数说明
<Lighthouse IP>
:Lighthouse 平台的访问地址<your_registry_url>
:镜像仓库地址(需包含项目名称,如192.168.2.99/light-agent
)<registry_cred_str>
:镜像仓库的访问凭证(参考 Kubernetes 安装 light-agent)
3. 执行安装
kubectl apply -f ebpf-agent.yaml
部署验证
使用以下命令监控部署状态:
# 查看部署状态
kubectl get all -n lighthouse
# 实时监控
watch -n 1 kubectl get all -n lighthouse
检查要点
- 确保所有 Pod 状态为 Running
- 检查 Pod 日志是否有错误信息
- 验证与 light-agent 的连接状态
常用操作
查看日志
# 查看指定 Pod 的日志
kubectl logs -n lighthouse <pod-name>
# 实时查看日志
kubectl logs -f -n lighthouse <pod-name>
卸载服务
kubectl delete -f ebpf-agent.yaml
注意事项
卸载操作会删除所有相关资源,请确保数据已经正确上报后再执行卸载操作
故障排除
如果部署过程中遇到问题,请检查:
-
镜像拉取问题
- 确认镜像仓库地址是否正确
- 验证镜像访问凭证是否有效
- 检查网络连接是否正常
-
Pod 启动失败
- 查看 Pod 详细状态:
kubectl describe pod -n lighthouse <pod-name>
- 检查容器日志
- 确认资源配额是否充足
- 查看 Pod 详细状态:
-
数据采集异常
- 确认 Lighthouse 平台地址配置是否正确
- 检查与 light-agent 的连接状态
- 验证网络策略配置