cyscaledev/kubernetes-agentCyscale Kubernetes Agent 是一款与 Cyscale Platform 集成的 Kubernetes 代理组件,旨在通过收集 Kubernetes 集群的资源配置、运行时数据及安全相关信息,为 Cyscale Platform 提供数据输入,从而实现对集群安全状态的持续监控、风险识别与合规性评估。
kubectl 命令行工具,且具备集群管理员权限(用于部署代理)。创建代理配置文件(如 cyscale-agent-deployment.yaml),示例如下(根据实际环境调整参数):
yamlapiVersion: apps/v1 kind: Deployment metadata: name: cyscale-agent namespace: cyscale-agent labels: app: cyscale-agent spec: replicas: 1 selector: matchLabels: app: cyscale-agent template: metadata: labels: app: cyscale-agent spec: containers: - name: cyscale-agent image: cyscale/k8s-agent:latest # 替换为实际镜像标签 imagePullPolicy: Always env: - name: CYSCALE_API_KEY value: "your-cyscale-api-key" # 替换为 Cyscale API 密钥 - name: CLUSTER_NAME value: "your-cluster-name" # 自定义集群名称(用于平台识别) - name: LOG_LEVEL value: "info" # 日志级别:debug/info/warn/error resources: limits: cpu: "500m" memory: "512Mi" requests: cpu: "200m" memory: "256Mi"
创建命名空间(如 cyscale-agent):
bashkubectl create namespace cyscale-agent
应用部署配置:
bashkubectl apply -f cyscale-agent-deployment.yaml -n cyscale-agent
检查 Pod 运行状态:
bashkubectl get pods -n cyscale-agent
预期输出:cyscale-agent-xxxxxxxxx-xxxxx 状态为 Running。
查看代理日志(确认数据上报正常):
bashkubectl logs -f <pod-name> -n cyscale-agent
以下为生产环境推荐的 Deployment 配置(包含资源限制、健康检查及自动重启策略):
yamlapiVersion: apps/v1 kind: Deployment metadata: name: cyscale-agent namespace: cyscale-agent labels: app: cyscale-agent spec: replicas: 1 selector: matchLabels: app: cyscale-agent strategy: rollingUpdate: max***: 0 maxUnavailable: 1 type: RollingUpdate template: metadata: labels: app: cyscale-agent spec: containers: - name: cyscale-agent image: cyscale/k8s-agent:v1.2.0 # 指定具体版本,避免自动升级风险 imagePullPolicy: IfNotPresent env: - name: CYSCALE_API_KEY valueFrom: secretKeyRef: name: cyscale-secrets key: api-key # 推荐通过 Secret 管理敏感信息 - name: CLUSTER_NAME value: "production-cluster-01" - name: LOG_LEVEL value: "info" - name: SCAN_INTERVAL value: "300" # 扫描间隔(秒),默认 300 resources: limits: cpu: "1000m" memory: "1Gi" requests: cpu: "500m" memory: "512Mi" livenessProbe: httpGet: path: /health port: 8080 initialDelaySeconds: 30 periodSeconds: 10 readinessProbe: httpGet: path: /ready port: 8080 initialDelaySeconds: 5 periodSeconds: 5 securityContext: readOnlyRootFilesystem: true # 增强容器安全性 runAsNonRoot: true runAsUser: 1000 restartPolicy: Always
若需在非 K8s 环境中运行代理(仅用于测试),可通过 docker run 命令启动容器:
bashdocker run -d \ --name cyscale-agent \ -e CYSCALE_API_KEY="your-api-key" \ -e CLUSTER_NAME="test-cluster" \ -e KUBECONFIG=/kubeconfig \ -v /path/to/local/kubeconfig:/kubeconfig \ # 挂载本地 kubeconfig 以访问集群 cyscale/k8s-agent:latest
| 参数名 | 描述 | 必填 | 默认值 | 示例值 |
|---|---|---|---|---|
CYSCALE_API_KEY | Cyscale Platform API 密钥 | 是 | - | cs-abc123def456... |
CLUSTER_NAME | 集群名称(用于平台识别) | 是 | - | production-cluster |
LOG_LEVEL | 日志级别 | 否 | info | debug/warn/error |
SCAN_INTERVAL | 资源扫描与数据上报间隔(秒) | 否 | 300 | 60(高频扫描) |
CYSCALE_API_ENDPOINT | Cyscale API 服务地址(私有化部署用) | 否 | 公网地址 | [***] |
PROXY_URL | 代理服务器地址(如需要网络代理) | 否 | - | [***] |
根据集群规模调整资源请求与限制:
200m-500m,内存 256Mi-512Mi500m-1000m,内存 512Mi-1Gi1000m-2000m,内存 1Gi-2Gi更新部署文件中的镜像标签(如 v1.2.0 升级至 v1.3.0):
yamlimage: cyscale/k8s-agent:v1.3.0
应用更新:
bashkubectl apply -f cyscale-agent-deployment.yaml -n cyscale-agent
bashkubectl delete deployment cyscale-agent -n cyscale-agent kubectl delete namespace cyscale-agent



manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务