Actions
DNSChaos supports the following actions:- error: Return an error when a DNS request is sent
- random: Return a random IP address when a DNS request is sent
Spec Fields
The DNS chaos action to perform.Options:
error, randomDomain name patterns to affect. Supports:
- Exact domain names (e.g.,
google.com) - Wildcards at the end (e.g.,
github.*) - Single character placeholder
?(e.g.,chaos-mes?.org)
* must be at the end of the string. If patterns is empty, all domain names are affected.Duration of the chaos action (e.g.,
30s, 5m, 1h).Selection mode for target pods.Options:
one, all, fixed, fixed-percent, random-max-percentRequired when mode is
fixed, fixed-percent, or random-max-percent. Specifies the number or percentage of pods to affect.List of container names to affect. If not set, the first container will be injected.
Remote cluster name where the chaos will be deployed.
Examples
Return Random IPs for Specific Domains
google.com(exact match)- Any domain starting with
chaos-mesh.(e.g.,chaos-mesh.org,chaos-mesh.io) github.comorgithub.aom(single character wildcard)
Return Errors for All DNS Requests
app: my-app to fail with an error.
Implementation Details
DNSChaos works by:- Injecting a sidecar container into targeted pods
- Intercepting DNS requests from the container
- Manipulating the DNS response based on the configured action:
error: Returns a DNS errorrandom: Returns a random IP address
api/v1alpha1/dnschaos_type.go:25-34