【Chaos Mesh官方文档】(Kubernetes)Simulate Time Faults

TimeChaos Introduction​

Chaos Mesh provides the TimeChaos experiment type. You can use this experiment type to simulate a time offset scenario. This document describes how to create a TimeChaos experiment and its associated configuration file.
note

TimeChaos only affects the PID 1 process in the PID namespace of the container, and child processes of the PID 1. For example, the process started by kubectl exec does not be affected.

You can create experiments in Chaos Dashboard or using the YAML configuration file.
Create experiments using Chaos Dashboard​

Open Chaos Dashboard, and click NEW EXPERIMENT on the page to create a new experiment:

Create Experiment

In the Choose a Target area, choose CLOCK SCREW and fill out the Clock ID and time offset.

TimeChaos Experiments

Fill out the experiment information, and specify the experiment scope and the scheduled experiment duration:

Experiment Information

Submit the experiment information.

Create experiments using the YAML file​

Write the experiment configuration to the YAML configuration file. In the following example, the time-shift.yaml file is used.

apiVersion: chaos-mesh.org/v1alpha1
kind: TimeChaos
metadata:
  name: time-shift-example
  namespace: chaos-testing
spec:
  mode: one
  selector:
    labelSelectors:
      'app': 'app1'
  timeOffset: '-10m100ns'

This experiment configuration will shift the time of the processes in the specified Pod forward by 10 minutes and 100 nanoseconds.

After the configuration file is prepared, use kubectl to create an experiment:

kubectl apply -f time-shift.yaml

The fields in the YAML configuration file are described in the following table:
Parameter Type Note Default value Required Example
timeOffset string Specifies the length of time offset. None Yes -5m
clockIds []string Specifies the ID of clock that will be offset. See the clock_gettime documentation for details. [“CLOCK_REALTIME”] No [“CLOCK_REALTIME”, “CLOCK_MONOTONIC”]
mode string Specifies the mode of the experiment. The mode options include one (selecting a random Pod), all (selecting all eligible Pods), fixed (selecting a specified number of eligible Pods), fixed-percent (selecting a specified percentage of Pods from the eligible Pods), and random-max-percent (selecting the maximum percentage of Pods from the eligible Pods). None Yes one
value string Provides parameters for the mode configuration, depending on mode.For example, when mode is set to fixed-percent, value specifies the percentage of Pods. None No 1
containerNames []string Specifies the name of the container into which the fault is injected. None No [“nginx”]
selector struct Specifies the target Pod. For details, refer to Define the experiment scope. None Yes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值