You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Chaos Toolkit编写AKS集群节点创建混沌实验时遇报错,求正确实验配置指导

Fixing the "metadata.name: Required value" Error in Chaos Toolkit AKS Node Creation Experiment

First, let's break down the issue clearly: your error message confirms the Kubernetes API is rejecting the node creation request because you didn't provide a name or generateName for the new node. The create_node function from chaosk8s.node.actions requires this parameter to properly construct the Node resource that K8s expects.

Root Cause

When using the create_node action, you must explicitly provide either:

  • A fixed name for the node, or
  • A generateName pattern (e.g., aks-test-node-) that Kubernetes uses to auto-generate a unique node name with a random suffix.

Without either of these, the K8s API returns a 422 Validation Error—exactly what you're seeing.

Fixed Chaos Experiment YAML

Here's the corrected version of your experiment configuration, with the missing node identifier parameter added:

version: 1.0.0
title: What happens if we create a node
description: All the instances are distributed among healthy nodes and the applications are healthy
tags:
  - k8s
  - deployment
  - node
steady-state-hypothesis:
  title: Nodes are indestructible
  probes:
    - name: all-apps-are-healthy
      type: probe
      tolerance: true
      provider:
        type: python
        func: all_microservices_healthy
        module: chaosk8s.probes
        arguments:
          ns: qs-aks-dev
actions:
  - type: action
    name: create-node
    provider:
      type: python
      func: create_node
      module: chaosk8s.node.actions
      arguments:
        # Option 1: Use a fixed, unique node name (pick one option)
        name: "aks-test-node-001"
        # Option 2: Auto-generate a unique name (uncomment if using instead)
        # generateName: "aks-test-node-"
        # Optional: Add AKS-specific node attributes if needed
        # labels:
        #   node-role.kubernetes.io/worker: ""
    pauses:
      after: 10

Key Modifications Explained

  1. Added arguments to the create-node action:
    • We included either a fixed name or a generateName (choose whichever fits your testing needs). This satisfies the K8s API's mandatory field requirement and resolves the validation error.
  2. Optional AKS-specific tweaks:
    • If your AKS cluster requires specific labels or taints for worker nodes, you can add those under arguments (example commented out above) to match your cluster's existing node configuration.

Quick Note for AKS

Keep in mind that in a managed AKS cluster, manually creating nodes via the K8s API might not align with AKS's native node pool management. For more realistic chaos testing of node scaling, you might want to explore AKS-specific actions (like scaling node pools) instead of direct node creation. But for fixing the immediate error you're facing, the above configuration will work as intended.

内容的提问来源于stack exchange,提问作者Ginni

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.01 00:32:46