云的混沌。
项目描述
Chaotic - 云的混沌
Chaotic评估计划,了解它如何为您云环境带来混沌。
根据使用的云API,它可能杀死分配(Hashicorp Nomad)、重启或停止/启动云环境中的虚拟机。
如果没有提供参数,Chaotic将以“一次性”运行,作为cron作业执行。使用--periodic
传递运行作为守护进程,具有可配置的间隔--interval 5
分钟(默认值为1)。注意:配置在每个间隔时都会重新读取,无需在更改配置后重新启动服务。
云
目前实现的云
- DigitalOcean
- Vultr
- Hetzner Cloud
- Proxmox KVM
- CloudStack
- Hashicorp Nomad
- Exoscale
- cloudscale.ch
安装
pip3 install -U chaotic-ngine
配置
创建一个名为config.yaml
的文件或使用环境变量CHAOTIC_CONFIG
指向配置文件(也请参阅示例目录)
export CHAOTIC_CONFIG=config_nomad.yaml
排除时间
定义机器人在不应执行实际操作的时间(它将运行在dry-run)
---
kind: ...
excludes:
weekdays:
- Sun
- Sat
times_of_day:
- 22:00-08:00
- 11:00-14:00
days_of_year:
- Jan01
- Apr01
- May01
- Aug01
- Dec24
Exoscale
Chaotic将停止由可选过滤标签选择的服务器,并以可配置的时间(默认60秒)延迟停止/启动。
export EXOSCALE_API_KEY="..."
export EXOSCALE_API_SECRET="..."
---
kind: exoscale
dry_run: false
configs:
# Optional, filter tag
tag:
key: chaos
value: enabled
# Optional, 60 seconds is the default
wait_before_restart: 60
CloudStack
Chaotic将停止由可选过滤标签选择的服务器,并以可配置的时间(默认60秒)延迟停止/启动。
export CLOUDSTACK_API_KEY="..."
export CLOUDSTACK_API_SECRET="..."
export CLOUDSTACK_API_ENDPOINT="..."
---
kind: cloudstack
dry_run: false
configs:
# Optional, filter tag
tag:
key: chaos
value: enabled
# Optional, 60 seconds is the default
wait_before_restart: 60
Vultr
Chaotic将停止由可选过滤标签选择的服务器,并以可配置的时间(默认60秒)延迟停止/启动。
export VULTR_API_KEY="..."
---
kind: vultr
dry_run: true
configs:
# Optional instance tag filter
tag: "chaos=opt-in"
# Optional, 60 seconds is the default
wait_before_restart: 60
cloudscale.ch
Chaotic将停止由可选过滤标签选择的服务器,并以可配置的时间(默认60秒)延迟停止/启动。
配置
export CLOUDSCALE_API_TOKEN="..."
---
kind: cloudscale_ch
dry_run: true
configs:
# Optional server tag filter
filter_tag: "chaos=opt-in"
# Optional, 60 seconds is the default
wait_before_restart: 60
Hetzner Cloud
Chaotic将停止由可选过滤标签选择的服务器,并以可配置的时间(默认60秒)延迟停止/启动。
配置
export HCLOUD_API_TOKEN=...
---
kind: hcloud
dry_run: false
configs:
# Optional server label filter
label: "chaos=enabled"
# Optional, 60 seconds is the default
wait_before_restart: 60
DigitalOcean云
Chaotic将停止由可选过滤标签选择的droplet,并以可配置的时间(默认60秒)延迟停止/启动。
配置
export DIGITALOCEAN_ACCESS_TOKEN=...
---
kind: digitalocean
dry_run: false
configs:
# Optional droplet tag filter
tag: "chaos:enabled"
# Optional, 60 seconds is the default
wait_before_restart: 60
诺德工作
混沌将向允许列表中选择的可用命名空间中的一个分配发送分配信号。
配置
export NOMAD_ADDR=http://nomad.example.com:4646
---
kind: nomad
dry_run: true
configs:
experiments:
- job
# Signals to choose from
signals:
- SIGKILL
# Optional: namespace allowlist
namespace_allowlist:
- example-prod
- foobar-prod
# Optional: namespace denylist
namespace_denylist:
- default
# Optional: job type skip list
job_type_skiplist:
- system
- batch
- sysbatch
# Optional: job name skip list
job_skiplist:
- my-job-name
# Optional: Add a meta tag in your nomad job "chaotic" = False to opt-out
job_meta_opt_key: chaotic
诺德节点
混沌将排出一个节点,并设置其在一段时间内不可用。
配置
export NOMAD_ADDR=http://nomad.example.com:4646
---
kind: nomad
dry_run: true
configs:
experiments:
- node
# Optional: Node drain deadline in seconds, default 10
node_drain_deadline_seconds: 15
# Optional: Skip nodes in these classes
node_class_skiplist:
- storage
# Optional: Skip nodes with these names
node_skiplist:
- node1
- node5
# Optional: Wait for this amount of seconds before set node to be eligible again, default 60
node_wait_for: 100
# Optional: Also drain system jobs, default false
node_drain_system_jobs: true
# Optional: Drain multiple nodes in one run in percent, fallback 1 node
node_drain_amount_in_percent: 30
Proxmox KVM
混沌将停止虚拟机,并使用可配置的时间延迟(默认60秒)停止/启动它。
export PROXMOX_API_HOST="pve1.example.com"
export PROXMOX_API_USER="root@pam"
export PROXMOX_API_PASSWORD="..."
---
kind: proxmox_kvm
dry_run: false
configs:
# Optional: Do not shutdown VMs having a lower uptime in minutes
min_uptime: 60
# Optional: Do not shutdown VMs in this name list
denylist:
- my-single-vm
# Optional: 60 seconds is the default
wait_before_restart: 60
运行
命令行界面
chaos-ngine
Docker
一次性
docker run -ti --rm -v $PWD/examples/config_nomad.yaml:/app/config.yaml -e TZ=Europe/Zurich -e NOMAD_ADDR=$NOMAD_ADDR --name chaotic ghcr.io/ngine-io/chaotic:latest
作为服务
docker run -ti --rm -v $PWD/examples/config_nomad.yaml:/app/config.yaml -e TZ=Europe/Zurich -e NOMAD_ADDR=$NOMAD_ADDR --name chaotic ghcr.io/ngine-io/chaotic:latest --periodic
日志
您应该看到的(例如,对于kind cloudscale.ch)
2021-06-09 09:01:25,433 - cloudscale.log:INFO:Started, version: 0.6.2
2021-06-09 09:01:25,433 - cloudscale.log:INFO:Using profile default
2021-06-09 09:01:25,433 - cloudscale.log:INFO:API Token used: xyz...
2021-06-09 09:01:25,433 - chatic:INFO:Querying with filter_tag: None
2021-06-09 09:01:25,433 - cloudscale.log:INFO:HTTP GET to https://api.cloudscale.ch/v1/servers
2021-06-09 09:01:25,651 - cloudscale.log:INFO:HTTP status code 200
2021-06-09 09:01:25,652 - chatic:INFO:Choose server app3
2021-06-09 09:01:25,653 - chatic:INFO:Stopping server app3
2021-06-09 09:01:25,653 - cloudscale.log:INFO:HTTP POST to https://api.cloudscale.ch/v1/servers/d5628484-a6eb-4ea9-b3ef-ba8da2bb9fe0/stop
2021-06-09 09:01:26,336 - cloudscale.log:INFO:HTTP status code 204
2021-06-09 09:01:26,336 - chatic:INFO:Sleeping for server 60
2021-06-09 09:02:26,393 - cloudscale.log:INFO:HTTP POST to https://api.cloudscale.ch/v1/servers/d5628484-a6eb-4ea9-b3ef-ba8da2bb9fe0/start
2021-06-09 09:02:26,955 - cloudscale.log:INFO:HTTP status code 204
2021-06-09 09:02:26,956 - chatic:INFO:done
项目详情
下载文件
下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
构建分布
chaotic-ngine-0.13.0.tar.gz 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 6e0d936fd7d55587dabc70b708beee5554b71063351c1a91aabe1df7fc9c4b21 |
|
MD5 | 5e81a9a9762abf59c8e1336465496083 |
|
BLAKE2b-256 | ec228d54b99114a588f4508d643f5e75611130c765ffcfeb5e01ccd70b5b390f |
chaotic_ngine-0.13.0-py3-none-any.whl 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 425a20747ab1b45e8893c98a9ee696e1cf0620bf590a7158870f5e3e51c2a904 |
|
MD5 | 854a0b161c73664d2729afd628a7f995 |
|
BLAKE2b-256 | 6a347f9ed575a8457462ea743683ee7a343f9369051b9572f153317bee0364e2 |