安装云眼Agent
2024年7月1日大约 3 分钟
安装云眼Agent
如何在 Linux/macOS、Windows、Docker 和 Kubernetes 上安装 云眼 Agent。
从源代码运行Agent (Linux/macOS)
要从源代码开发和编译云眼Agent,请执行以下操作:
- 安装 Golang 变体 1.20+。
 - 在本地克隆云眼Agent存储库。
 - 从存储库目录中,打开一个终端并启动云眼Agent:
 
Shell
make setup然后
Shell
make run这将在前台使用默认配置启动云眼Agent。
从源代码运行Agent (Windows)
可以使用帮助程序脚本来安装必备组件(Golang 和 Git)并在 Windows 环境中编译Agent:
- 在本地克隆云眼Agent存储库。
 - 从存储库目录中,打开 Powershell 终端并运行:
 
PowerShell
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser  
.\scripts\build.ps1  
.\bin\eyeofcloud.exe通过 Docker 在本地运行Agent
如果安装了 Docker,则可以将 云眼 Agent 作为容器启动:
- 拉取 Docker 镜像:
 
Shell
docker pull eyeofcloud/agent默认情况下,这将拉取“最新”标签。还可以通过将变体作为标记提供给 docker 命令来指定特定变体的Agent:
Shell
docker pull eyeofcloud/agent:X.Y.Z- 使用以下命令运行 docker 容器:
 
Shell
docker run -p 8080:8080  
    --env EYEOFCLOUD_LOG_PRETTY=true  
    --env EYEOFCLOUD_SERVER_HOST=0.0.0.0  
    --env EYEOFCLOUD_SERVER_ALLOWEDHOSTS=127.0.0.1 eyeofcloud/agent这将在前台启动Agent,并向主机公开容器 API 端口 8080。
- (可选)可以通过将环境变量传递给上述命令来更改配置,而无需创建 config.yaml 文件。有关更多选项,请参阅配置云眼Agent。
 
码头工人变体控制:
发布新版本时,会将两个映像推送到 Docker 中心。他们的标签区分了他们:
- :最新(与 :X.Y.Z 相同)
 - :高山(同:X.Y.Z-高山)
 
最新和高山的区别在于,最新的是FROM scratch建造的,而阿尔卑斯山是FROM alpine。
在 Kubernetes 集群中运行Agent
如果将 Kubernetes 作为基础架构的一部分运行并安装了 Helm,可以使用我们的 Helm 图表轻松地在集群中托管 云眼 Agent:
- 从 云眼 的存储库中添加
eyeofcloud-agentHelm 图表: 
Shell
helm repo add eyeofcloud-agent https://eyeofcloud.github.io/eyeofcloud-agent-helm输出应为:
Shell
"eyeofcloud-agent" has been added to your repositories- 然后,安装云眼Agent图表,为部署指定一个名称,如下所示:
 
Shell
helm install my-agent eyeofcloud-agent/agent输出应类似:
Shell
NAME: my-agent 
LAST DEPLOYED: Tue Jul 12 18:24:27 2022 
NAMESPACE: default 
STATUS: deployed 
REVISION: 1 
NOTES: 
*** Configuration Summary ***  
Name Override:    
    [no name override; using generated name] 
Full Name Override:    
    [no full name override; using generated full name]  
Image Used:    
    eyeofcloud/agent:latest  
    
Service Account:   
    [account name will be generated]  
    
Replica Count: 1  
Auto-Scaling:   
    [auto-scaling is disabled]  
    
Node Selector:   
    [no node selectors applied]  
    
Node Affinity:
    [no node affinity applied]  
Node Tolerations:
    [no node tolerations applied]  
Pod Annotations Applied:
    [no annotations applied]  
   
Pod Security Context:   
    [no pod security context applied]  
    
Container Security Context:   
    [no container security context applied]  
    
Network Service:    
    Type: ClusterIP   
    Ports:     
        api: 8080 [internal] <== 8080 [external]     
        webhook: 8085 [internal] <== 8085 [external]     
        admin: 8088 [internal] <== 8088 [external]  
        
Network Ingress:     
    Run the following in a *nix terminal to access the running ClusterIP service IP address       
        export CLUSTER_IP=$(kubectl get svc --namespace default my-agent -o jsonpath='{.spec.clusterIP}')       
        echo http://$CLUSTER_IP:8080  
        
Resources:   
    [no resources declarations applied]  
    
Logging:   
    Level set to DEBUG with friendly formatting ON.   
    SDK Key WILL be included in logs.  
    
Environment Variables:   
    [no environment variables applied]  
    
Secrets:- (可选)可以通过使用自定义 YAML 文件修改
--values来更改图表中的默认值,也可以在直接在helm install命令中--set标记时单独更改。有关更多选项,请参阅 GitHub 自述文件中的修改值。