当前位置: 首页 > Skill >

Huawei Cloud Cce Kubernetes Event Analyzer

Huawei Cloud Cce Kubernetes Event Analyzer

0.1.1 2026.11.21 浏览:668
获取Skill文件查看使用说明
作者:陆川许可证:
本文目录展开

Kubernetes Event Analyzer

Overview

Analyze Kubernetes events in Huawei Cloud CCE clusters to find warning events, anomalies, and failure patterns. Queries events via K8s API or LTS log streams, applies client-side filtering, groups patterns, and hands off to diagnosis skills for remediation.

Architecture: MCP Tool → CCE K8s API / LTS Log Streams → Events → Client-side Filter & Group → Pattern Summary → Diagnosis Handoff

Standard workflow:

1. Identify region, cluster_id, and optional namespace from user query
2. Fetch events using huawei_get_cce_events (K8s API) or huawei_query_k8s_events_from_lts (LTS)
3. Apply client-side filters (type, reason, involved_object, time window)
4. Group and aggregate by reason, namespace, or pattern
5. Summarize top reasons, repeated patterns, and affected resources
6. Hand off to diagnosis skill if specific failures identified

Related Skills (handoff targets):

  • Pod failures -> huawei-cloud-cce-pod-failure-diagnoser
  • Workload rollout issues -> huawei-cloud-cce-workload-failure-diagnoser
  • Node issues -> huawei-cloud-cce-node-failure-diagnoser
  • Storage issues -> huawei-cloud-cce-storage-failure-diagnoser
  • Service/Network issues -> huawei-cloud-cce-network-failure-diagnoser
  • Action requested -> huawei-cloud-cce-auto-remediation-runner

Prerequisites

1. Python Dependencies

  • Python 3.8+ with huaweicloudsdkcce, huaweicloudsdkcore, kubernetes packages
  • Run environment check before first use (see Verification section)

2. Credential Configuration

  • Valid Huawei Cloud credentials (AK/SK mode)
  • Security Rules:
    • 🚫 Never expose AK/SK values in code, conversation, or commands
    • 🚫 Never use echo $HUAWEI_AK or echo $HUAWEI_SK to check credentials
    • ✅ Use environment variables: HUAWEI_AK, HUAWEI_SK, HUAWEI_REGION
    • ✅ Prefer IAM users over root account for cloud operations
    • ✅ Enable MFA for sensitive operations

Configuration Method (Environment Variables Only):

export HUAWEI_AK=<your-ak>
export HUAWEI_SK=<your-sk>
export HUAWEI_REGION=cn-north-4

⚠️ Important Security Notes:

  • Never commit credentials to version control
  • Use IAM users with minimal required permissions
  • Enable MFA for sensitive operations
  • Rotate AK/SK regularly

3. IAM Permission Requirements

API Action Permission Purpose
cce:cluster:get Get cluster View CCE cluster details
cce:cluster:createCert Create certificate Obtain kubeconfig for kubectl access
cce:node:list List nodes Query CCE cluster nodes
lte:logStream:list List LTS log streams Discover LTS log streams for event queries
lte:logs:search Search LTS logs Query K8s events from LTS log streams

Permission Failure Handling:

  1. When any command fails due to IAM permission errors, display the required permission list
  2. Guide the user to create a custom policy in the IAM console and grant authorization
  3. Pause execution and wait for user confirmation that permissions have been granted

Security Constraints

Read-Only Skill

This skill is strictly read-only. It only queries Kubernetes events and lists related resources. No modifications are made to the cluster.

  • No write operations: Never modify, delete, or create any Kubernetes resources
  • Redact sensitive data: Do not expose node names, pod names, or workload names that could identify production systems. Use redacted or fictional examples in summaries
  • Hand off remediation: If event analysis reveals a clear remediation path, provide evidence and hand off to the appropriate diagnosis or remediation skill instead of executing recovery actions here
  • Time-bounded queries: Keep event queries time-bounded. Prefer recent windows (1-24 hours) to avoid overwhelming results
  • Redirect action requests: If the user asks to take action based on event findings, redirect to huawei-cloud-cce-auto-remediation-runner with the evidence summarized

Tools

Tool Purpose Required Parameters Optional Parameters
huawei_get_cce_events Query CCE Kubernetes events via K8s API Server region, cluster_id namespace, limit
huawei_query_k8s_events_from_lts Query K8s events from LTS log streams (Event→LTS LogConfig required) region, cluster_id, start_time, end_time keywords

Scenario Routing

User Intent Reference Document
Full event query workflow (5-step) references/workflow.md
Event pattern recognition table references/workflow.md
Time-window analysis guidance references/workflow.md
Risk constraints & guardrails references/risk-rules.md
Output schema (query & analysis) references/output-schema.md

Core Commands

Step 1: Query Events via K8s API (huawei_get_cce_events)

Fetches raw Kubernetes events from the cluster API Server. All filtering beyond namespace and limit is done client-side after fetching.

# Query all events in a cluster
python3 scripts/huawei-cloud.py huawei_get_cce_events 
  region=cn-north-4 
  cluster_id=<cluster-id>

# Query events in a specific namespace
python3 scripts/huawei-cloud.py huawei_get_cce_events 
  region=cn-north-4 
  cluster_id=<cluster-id> 
  namespace=default

# Limit event count
python3 scripts/huawei-cloud.py huawei_get_cce_events 
  region=cn-north-4 
  cluster_id=<cluster-id> 
  limit=100

Supported API filters: namespace, limit (default 500)

Unsupported filters (apply client-side): event_type, reason, involved_object_kind, involved_object_name, hours, start_time, end_time

Step 2: Query Events via LTS (huawei_query_k8s_events_from_lts)

Queries K8s events collected to LTS via Event→LTS LogConfig. Requires a LogConfig with event collection enabled and pointing to LTS output.

# Query events from LTS in a time window
python3 scripts/huawei-cloud.py huawei_query_k8s_events_from_lts 
  region=cn-north-4 
  cluster_id=<cluster-id> 
  start_time="2026-05-30 06:00:00" 
  end_time="2026-05-30 08:00:00"

# Query with keyword filter
python3 scripts/huawei-cloud.py huawei_query_k8s_events_from_lts 
  region=cn-north-4 
  cluster_id=<cluster-id> 
  start_time="2026-05-30 00:00:00" 
  end_time="2026-05-30 23:59:59" 
  keywords=FailedScheduling

LTS time format: YYYY-MM-DD HH:MM:SS

Fallback: If no Event→LTS LogConfig is found with events enabled, returns an error. Use huawei_get_cce_events instead.

Step 3: Apply Client-Side Filters

After fetching events, apply filters based on user needs:

  • type == "Warning" — warning events only
  • reason — specific patterns (FailedScheduling, ImagePullBackOff, FailedMount, etc.)
  • involved_object.kind + involved_object.name — specific resources
  • namespace — namespace-specific analysis
  • first_timestamp / last_timestamp — time-window analysis

Step 4: Group and Aggregate

  • Group by reason to find top event patterns
  • Group by namespace to find high-noise namespaces
  • Flag events with count > 1 as repeated patterns
  • Calculate warning_count vs normal_count for quick health signal

Step 5: Summarize and Hand Off

Summarize findings with counts, timestamps, and affected objects. If events point to specific failures, hand off to the appropriate diagnosis skill with evidence.

Parameter Reference

Common Parameters

Parameter Required/Optional Description Default
region Required Huawei Cloud region HUAWEI_REGION
cluster_id Required CCE cluster ID N/A
namespace Optional Kubernetes namespace filter N/A (all namespaces)
ak Optional Override AK HUAWEI_AK
sk Optional Override SK HUAWEI_SK
project_id Optional Project ID Auto from IAM

huawei_get_cce_events Parameters

Parameter Required Description Default
region Yes Huawei Cloud region HUAWEI_REGION
cluster_id Yes CCE cluster ID N/A
namespace No Kubernetes namespace filter N/A (all namespaces)
limit No Maximum number of events to return 500

huawei_query_k8s_events_from_lts Parameters

Parameter Required Description Default
region Yes Huawei Cloud region HUAWEI_REGION
cluster_id Yes CCE cluster ID N/A
start_time Yes Query start time (YYYY-MM-DD HH:MM:SS) N/A
end_time Yes Query end time (YYYY-MM-DD HH:MM:SS) N/A
keywords No Keyword filter for LTS search N/A

Event Pattern Quick Reference

Pattern Likely Cause Handoff Target
ImagePullBackOff repeated Wrong image or pull secret missing huawei-cloud-cce-pod-failure-diagnoser
FailedScheduling + insufficient Resource pressure or node not ready huawei-cloud-cce-workload-failure-diagnoser
FailedMount Volume attach or PVC issue huawei-cloud-cce-storage-failure-diagnoser
Evicted pods Budget disruption or node pressure huawei-cloud-cce-pod-failure-diagnoser
NodeNotReady Node agent or network issue huawei-cloud-cce-node-failure-diagnoser
Unhealthy + Readiness probe Application issue or startup failure huawei-cloud-cce-pod-failure-diagnoser
FailedCreatePodSandBox CNI or network issue huawei-cloud-cce-network-failure-diagnoser
OOMKilled Memory limit exceeded huawei-cloud-cce-pod-failure-diagnoser

Output Format

From huawei_get_cce_events (K8s API)

Field Description
region Huawei Cloud region
cluster_id CCE cluster ID
namespace Kubernetes namespace filter (if applied)
total_fetched Number of events returned by the API
events Raw event list (apply filters client-side)
warning_count Number of Warning events (calculated)
top_reasons Top event reasons with counts (calculated)
repeated_patterns Events with count > 1 grouped by reason
namespace_breakdown Event counts by namespace
next_steps Suggested follow-up query or diagnosis skill

From huawei_query_k8s_events_from_lts (LTS)

Field Description
region Huawei Cloud region
cluster_id CCE cluster ID
log_group_id LTS log group ID
log_stream_id LTS log stream ID
keywords Keywords used for filtering
event_count Number of events returned
events Parsed event list with normalized structure
time_range Start/end time of the query
log_config LogConfig info (name, events enabled, etc.)

Verification

  1. Run environment check script
  2. Query CCE events with huawei_get_cce_events
  3. Verify event filtering and pattern grouping
  4. Confirm handoff to diagnosis skills works correctly

Best Practices

  1. Start with K8s API — use huawei_get_cce_events for quick queries; fall back to LTS only when time-range precision is needed
  2. Filter Warning first — Warning events are the primary signal; filter type == "Warning" before deep analysis
  3. Group by reason — event reason grouping reveals systemic issues faster than per-event analysis
  4. Time-bound queries — prefer recent windows (1-24 hours) to avoid overwhelming results
  5. Hand off, don't remediate — this skill is read-only; always hand off to diagnosis skills with evidence
  6. Redact sensitive names — use generic labels in summaries; do not expose production pod/node/workload names

Common Pitfalls

Pitfall Symptom Quick Fix
Missing cluster_id Action fails immediately Provide cluster_id from huawei_get_cce_clusters
No Event→LTS LogConfig configured LTS query returns error Use huawei_get_cce_events (K8s API) instead
Unbounded time query Overwhelming results, slow response Always provide start_time/end_time or limit scope to 1-24 hours
LTS time format mismatch LTS query fails or returns no results Use exact format YYYY-MM-DD HH:MM:SS for start_time and end_time
Large namespace scan with no filter Too many events, hard to analyze Narrow with namespace or client-side filters (type, reason)
Permission denied on kubeconfig Cannot access cluster Verify cce:cluster:createCert IAM permission
LTS permission denied Cannot query LTS log streams Verify lte:logStream:list and lte:logs:search IAM permissions
Ignoring count > 1 events Missing systemic patterns Always group by reason and flag repeated events first

Notes

  • This skill does not modify, delete, or create any Kubernetes or LTS resources — all actions are read-only
  • Event summaries must redact production pod/node/workload names; use generic labels in public outputs
  • AK/SK must never be hardcoded — use environment variables only
  • The Python dispatcher script (scripts/huawei-cloud.py) is the only execution method — do not use hcloud CLI or direct API calls for event queries
  • For LTS queries, the cluster must have an Event→LTS LogConfig configured; otherwise fall back to K8s API
  • Hand off remediation requests to huawei-cloud-cce-auto-remediation-runner with evidence summarized — this skill never executes recovery actions
  • All event data is point-in-time — K8s API events have a retention limit; use LTS for historical analysis beyond the API retention window

Reference Documents

Document Description
workflow.md Full event query workflow, pattern recognition, time-window analysis, aggregation guidance, LTS vs K8s API selection guide
risk-rules.md Read-only constraints, data redaction rules, handoff policies, guardrails
output-schema.md Event query summary, analysis summary, and per-event detail schema

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,033
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,018
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,016
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,012
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,012
Skill 文件
  • SKILL.md
    • Kubernetes Event Analyzer
    • Overview
    • Prerequisites
      • 1. Python Dependencies
      • 2. Credential Configuration
      • 3. IAM Permission Requirements
    • Security Constraints
      • Read-Only Skill
    • Tools
    • Scenario Routing
    • Core Commands
      • Step 1: Query Events via K8s API (huawei_get_cce_events)
      • Step 2: Query Events via LTS (huawei_query_k8s_events_from_lts)
      • Step 3: Apply Client-Side Filters
      • Step 4: Group and Aggregate
      • Step 5: Summarize and Hand Off
    • Parameter Reference
      • Common Parameters
      • huawei_get_cce_events Parameters
      • huawei_query_k8s_events_from_lts Parameters
    • Event Pattern Quick Reference
    • Output Format
      • From huawei_get_cce_events (K8s API)
      • From huawei_query_k8s_events_from_lts (LTS)
    • Verification
    • Best Practices
    • Common Pitfalls
    • Notes
    • Reference Documents
  • 项目或源文件

相关 Skill

更多
Analyze Kubernetes cluster issues through MCP with K8sGPT Analyze Kubernetes cluster issues through MCP with K8sGPT 将 K8sGPT 运行为 MCP 服务器,以便代理可以扫描 Kubernetes 集群、解释不健康的资源,并以自然语言返回优先级修复线索。
Kubernetes Network Policy Generator Kubernetes Network Policy Generator 使用加权评分卡在12项标准上评估和比较隐私解决方案供应商。适用于选择隐私管理软件、比较数据保护方案等场景。
Garden Kubernetes 开发与测试自动化平台 Garden Kubernetes 开发与测试自动化平台 Garden 是一个 DevOps 自动化工具,用于更快地开发和测试 Kubernetes 应用。它按需启动类似生产环境的环境,提供智能构建缓存和并行执行,并在开发、测试和 CI 阶段使用统一的 YAML 配置。
阿拉丁·CI/CD与部署编排工坊|多平台流水线·Docker/K8s·质量门禁·本地校验 阿拉丁·CI/CD与部署编排工坊|多平台流水线·Docker/K8s·质量门禁·本地校验 阿拉丁·CI/CD与部署编排工坊把"交付上线"工程化:①自动探测仓库——识别语言/框架/构建/测试/端口,免手填;②多平台 CI 一键齐发——GitHub Actions + GitLab CI + Jenkinsfile 三大主流;③容器化——多阶段 Dockerfile(非 root/多语言基础镜像) + docker-compose;④编排部署——Kubernetes Deployment/Service/Ingress + Helm 骨架(带探针/资源限制/健康检查);⑤质量门禁联动——把 aladin-code-pilot(审查)/aladin-api-pilot(契约测试)/aladin-sql-forge(迁移) 嵌成流水线 stage;⑥本地校验 dry-run——纯标准库做 YAML 结构/密钥占位符/:latest 告警/端口/探针校验;⑦发布流水线——语义版本 bump + CHANGELOG + 标签 + 发布说明;⑧多格式导出——.yml/.yaml/.groovy/Dockerfile + HTML 看板 + MD 部署文档。相比 skillhub 飙升的
k8s AIops k8s AIops Use this skill whenever the user needs to operate a Kubernetes cluster — list/inspect pods, deployments, statefulsets, daemonsets, replicasets, jobs, cronjobs, services, ingresses, endpoints, configmaps, secrets (names/keys only), PVCs/PVs/storageclasses, nodes, namespaces, and events; read pod logs; describe pods/nodes; pod/node top (metrics); read-only diagnostics / RCA (pod-health, workload-readiness); scale deployments/statefulsets; rollout status/history/undo/pause/resume and set image; del