Analyze CCE (Cloud Container Engine) cluster cost optimization opportunities. This skill performs read-only analysis and generates configuration suggestions — it does not directly modify HPA, autoscaler, node pools, or workload requests. All configuration changes require explicit user confirmation.
Analysis scope:
Architecture: Python SDK v3 → CCE API + AOM PromQL → Inventory + Metrics → Cost Analysis → Report
This skill enforces a strict read-only-by-default policy. All write operations require
confirm=true.
ToolOperation TypeRisk LevelDescriptionhuawei_configure_cce_hpaCreate/Update HPA🟠 HighCreates or replaces a HorizontalPodAutoscalerNode pool resize/scale-downScale🟠 HighReduces node pool capacity
Write operations without confirm=true return a preview only. The huawei_configure_cce_hpa tool returns a manifest preview and risk warning when called without confirm=true. Only after explicit user approval can it be called with confirm=true to apply the configuration.
Step 1: Preview Operation — Call without confirm=true
bash
python3 scripts/huawei-cloud.py huawei_configure_cce_hpa \
region=cn-north-4 \
cluster_id=xxx \
workload_name=my-deploy \
namespace=default \
min_replicas=1 \
max_replicas=3 \
target_cpu_utilization=60
Returns: HPA manifest preview, risk warning, confirmation hint
Step 2: Confirm Execution — Call with confirm=true after user approval
bash
python3 scripts/huawei-cloud.py huawei_configure_cce_hpa \
region=cn-north-4 \
cluster_id=xxx \
workload_name=my-deploy \
namespace=default \
min_replicas=1 \
max_replicas=3 \
target_cpu_utilization=60 \
confirm=true
huawei_configure_cce_hpa without confirm=true returns preview onlyHW_ACCESS_KEY / HW_SECRET_KEY / HW_REGION_NAMEpip install huaweicloudsdkcce huaweicloudsdkcore huaweicloudsdkcespip install kubernetespip install matplotlib numpybash
export HW_ACCESS_KEY="your-access-key-id"
export HW_SECRET_KEY="your-secret-access-key"
export HW_REGION_NAME="cn-north-4"
Ensure the IAM user has the minimum required permissions:
PermissionDescriptioncce:cluster:listList clusterscce:cluster:getGet cluster detailscce:node:listList nodescce:node:getGet node detailscce:nodepool:listList node poolscce:nodepool:getGet node pool detailsaom:*:getRead AOM metrics and PromQL data
ToolFunctionParametershuawei_analyze_cce_cost_optimizationOne-shot cost optimization analysis — inventory, 24h/7d node utilization, pod usage/request, HPA/autoscaler status, and report outputregion, cluster_id, exclude_namespaces, business_namespaces, short_hours, long_hours, top_n, output_dir
Prefer
huawei_analyze_cce_cost_optimizationfor comprehensive analysis. Only use individual tools below for supplementing details, reviewing specific metrics, or manually generating HPA YAML.
ToolFunctionParametershuawei_list_cce_clustersList all CCE clusters in regionregion``huawei_list_cce_nodesList cluster nodesregion, cluster_id``huawei_get_kubernetes_nodesGet Kubernetes node details (including allocatable resources)region, cluster_id``huawei_list_cce_nodepoolsList node pools with autoscaling inforegion, cluster_id``huawei_get_cce_podsGet pod list with labels, status, requestsregion, cluster_id``huawei_get_cce_deploymentsGet deployment listregion, cluster_id``huawei_list_cce_hpasList HPA configurations (excludes kube-system by default)region, cluster_id
ToolFunctionParametershuawei_get_cce_node_metrics_topNNode CPU/memory/disk utilization Top Nregion, cluster_id, top_n, hours``huawei_get_cce_node_metricsSingle node utilization time seriesregion, cluster_id, node_ip, hours``huawei_get_cce_pod_metrics_topNPod CPU/memory utilization Top N (supports custom PromQL)region, cluster_id, top_n, hours, cpu_query, memory_query``huawei_get_cce_pod_metricsSingle pod utilization time seriesregion, cluster_id, pod_name, namespace, hours``huawei_get_aom_metricsGeneric AOM PromQL queryregion, aom_instance_id, query, hours
ToolFunctionRisk LevelRequires Confirmationhuawei_generate_cce_hpa_manifestGenerate autoscaling/v2 HPA YAML (no cluster modification)🟢 LowNohuawei_configure_cce_hpaCreate or replace HPA in cluster🟠 HighYes ( confirm=true)
HPA configuration workflow:
huawei_generate_cce_hpa_manifest or huawei_configure_cce_hpa without confirm=true to generate a previewhuawei_configure_cce_hpa with confirm=trueHPA recommendations must be based on request sizing. If requests are clearly oversized, first recommend calibrating requests, then configure HPA.
ToolFunctionParametershuawei_generate_monitor_dashboardGenerate monitoring dashboard chart imagesregion, cluster_id, metrics_type, hours
All tools accept these common parameters for authentication and region:
ParameterTypeRequiredDefaultDescriptionregionstringYes—Huawei Cloud region code (e.g., cn-north-4)cluster_idstringYes*—CCE cluster ID; not required for huawei_list_cce_clusters``akstringNoenv HW_ACCESS_KEYAccess Key ID; environment variable preferredskstringNoenv HW_SECRET_KEYSecret Access Key; environment variable preferredproject_idstringNoautoIAM project ID; auto-resolved from region if omitted
\* cluster_id is not required for huawei_list_cce_clusters (lists all clusters in region).
huawei_analyze_cce_cost_optimization)#ParameterTypeRequiredDefaultDescriptionregionstringYes—Huawei Cloud region codecluster_idstringYes—CCE cluster IDshort_hoursintNo24Short-window metrics duration in hourslong_hoursintNo168 (7d)Long-window metrics duration in hourstop_nintNo50Top N pods/nodes for oversized-request and utilization rankingexclude_namespacesstringNokube-systemComma-separated namespaces to exclude from analysisbusiness_namespacesstringNo—Comma-separated namespaces to treat as business workloads; if omitted, all non-excluded namespaces are analyzedoutput_dirstringNo—Directory to write summary JSON and report markdowninclude_rawboolNofalseInclude raw metrics data in output
huawei_generate_cce_hpa_manifest / huawei_configure_cce_hpa)#ParameterTypeRequiredDefaultDescriptionworkload_namestringYes—Target Deployment/StatefulSet namenamespacestringYes—Namespace of the target workloadmin_replicasintYes—Minimum replica count for HPAmax_replicasintYes—Maximum replica count for HPAworkload_typestringNodeploymentWorkload kind: deployment or statefulset``hpa_namestringNoautoHPA object name; defaults to <workload_name>-hpa``target_cpu_utilizationintNo60Target average CPU utilization percentagetarget_memory_utilizationintNo—Target average memory utilization percentage; omit to skip memory metricbehaviorobjectNo—HPA behavior policy (scaling rates, stabilization windows)confirmboolNofalsehuawei_configure_cce_hpa only: must be true to apply changes
huawei_get_cce_node_metrics_topN / huawei_get_cce_pod_metrics_topN)#ParameterTypeRequiredDefaultDescriptiontop_nintNo10Number of top nodes/pods to returnhoursintNo1Metrics query time range in hourscpu_querystringNoautoCustom PromQL for CPU; defaults to built-in querymemory_querystringNoautoCustom PromQL for memory; defaults to built-in querynode_ipstringYes*—Required for huawei_get_cce_node_metrics (single node)pod_namestringYes*—Required for huawei_get_cce_pod_metrics (single pod)namespacestringYes*—Required for huawei_get_cce_pod_metrics (single pod)
\* Only required for single-entity metrics tools.
huawei_generate_monitor_dashboard)#ParameterTypeRequiredDefaultDescriptionhoursintNo1Monitoring data time range in hourstop_nintNo10Top N pods for dashboard rankingnamespacestringNo—Filter by namespacelabel_selectorstringNo—Filter by label (e.g., app=nginx)output_filestringNoautoOutput HTML file pathtitlestringNoautoDashboard title
See references/workflow.md for detailed analysis steps, thresholds, and decision logic.
kube-system)high (p95 < 33% of request), optimize (p95 < 50%), or observe (short-window only)See references/risk-rules.md for complete safety boundaries.
Key constraints:
See references/output-schema.md for the complete JSON report structure.
All tools return JSON with:
status / success: operation resultdata: analysis results, metrics, or configuration previewmessage: human-readable descriptionwarning: risk warning for write operations (preview mode only)files: paths to generated summary JSON and report markdownRegion CodeRegion Namecn-north-4North China-Beijing 4cn-north-1North China-Beijing 1cn-east-3East China-Shanghai 1cn-south-1South China-Guangzhouap-southeast-1Asia-Pacific-Hong Kongap-southeast-2Asia Pacific-Bangkokap-southeast-3Asia Pacific-Singapore
huawei_analyze_cce_cost_optimization for a complete picture before drilling into individual tools; avoid piecemeal queries that miss cross-resource dependencies.HW_ACCESS_KEY / HW_SECRET_KEY over passing AK/SK as parameters to avoid credential leakage in command history and logs.huawei_configure_cce_hpa without confirm=true first; inspect the manifest YAML and risk warning with the user before applying.top_n appropriately — use top_n=50 for large clusters (100+ pods) to capture all significant outliers; reduce to top_n=10 for focused analysis of specific namespaces.output_dir to write the summary JSON and report markdown to a known location; this enables later review and comparison across multiple analysis runs.PitfallSymptomQuick FixMissing AK/SK credentialsAll tools return "success": false with credential errorSet HW_ACCESS_KEY and HW_SECRET_KEY environment variables before runningWrong cluster IDEmpty or error results from cluster-specific toolsRun huawei_list_cce_clusters first to confirm the correct cluster_id for your regionAnalyzing kube-system workloadsFalse oversized-request alerts on system DaemonSetsSet exclude_namespaces=kube-system (default) or add other system namespacesSingle-window scale-down decisionNode marked low-utilization in 24h only but stable in 7dAlways require both short_hours=24 and long_hours=168 before recommending scale-downHPA on oversized requestsHPA triggers scaling at low actual usage because requests are inflatedFirst reduce CPU/memory requests to realistic values, then configure HPA with target_cpu_utilization=60Missing AOM metricsEmpty utilization data, data_gaps flagged in reportVerify IAM has aom:*:get permission and AOM is enabled on the clusterApplying HPA without previewhuawei_configure_cce_hpa called with confirm=true without reviewAlways call without confirm=true first, review manifest, then re-run with confirm=truekubernetes SDK not installedHPA tools fail with "Kubernetes SDK not installed"Install with pip install kubernetes before using HPA listing or configuration toolsLarge cluster with small top_nOversized-request pods missing from reportIncrease top_n to 50 or higher for clusters with 100+ business podsNo output directory specifiedReport files written to temporary location, may be lostSet output_dir to a persistent path like ./cost-reports
All tools return JSON with status, success, data, message, warning, and iles fields. See references/output-schema.md for the complete report structure.
See Verification Method for step-by-step verification.
SkillWhen to Usehuawei-cloud-cce-cluster-managementCreate/delete/hibernate clusters, manage node pools, manage addons, cordon/uncordon/drain nodes, create/delete individual nodes
DocumentPathDescriptionWorkflowreferences/workflow.mdDetailed analysis workflow, thresholds, and decision logicRisk Rulesreferences/risk-rules.mdSafety boundaries, prohibited actions, and confirmation requirementsOutput Schemareferences/output-schema.mdCost optimization report JSON structure
kube-system namespace