Configure namespace for Chaos experiments
This chapter walks you through how to configure Chaos experiments to only take effect in the specified namespace, and protect other unspecified namespaces against fault injection.
Chaos Mesh offers two ways to control the scope of the Chaos experiment to take effect:
- To specify the scope for a single Chaos experiment to take effect, refer to Define the scope of a Chaos experiment.
If you have not installed Chaos Mesh yet, you can enable this feature during installation by adding to the command when installing using Helm. The following is a command example in the Docker container:
note
When you use Helm for installation, commands and parameters differ for different containers. Refer to Install Chaos Mesh using Helm for more information.
For helm upgrade
, you can set multiple parameters by adding multiple --set
in the command. Later settings override previous settings. For example, if you add --set controllerManager.enableFilterNamespace=false -set controllerManager.enableFilterNamespace=true
in the command, it still enables this feature.
You can also specify a YAML file using the parameter to describe the configuration. Refer to for more information.
When FilterNamespace is enabled, Chaos Mesh only injects faults to namespaces containing the annotation chaos-mesh.org/input=enabled
. Therefore, before starting Chaos experiments, you need to add this annotation to the namespace in which Chaos experiments can take effect, while other namespaces are protected agains fault injection.
You can add the annotation for a namespace
using the following kubectl
command:
namespace/$NAMESPACE annotated
If you want to delete this annotation, you can use the following command:
If the annotation is successfully deleted, the output is as follows:
You can list all the namespaces that allows Chaos experiments using the following command:
This command outputs all the namespaces with the chaos-mesh.org/input=enabled
annotation. For example:
default