blade create k8s node-process

介绍

kubernetes 节点进程相关场景,同基础资源的进程场景

命令

支持的进程场景命令如下:
    blade create k8s node-process kill 杀节点上指定进程,同 [blade create process kill](blade create process kill.md)
    blade create k8s node-process stop 挂起节点上指定进程,同 [blade create process stop](blade create process stop.md)

参数

除了上述基础场景各自所需的参数外,在 kubernetes 环境下,还支持的参数如下:
1
--evict-count string 限制实验生效的数量
2
--evict-percent string 限制实验生效数量的百分比,不包含 %
3
--labels string 节点资源标签
4
--names string 节点资源名,多个资源名之间使用逗号分隔
5
--kubeconfig string kubeconfig 文件全路径(仅限使用 blade 命令调用时使用)
6
--waiting-time string 实验结果等待时间,默认为 20s,参数值要包含单位,例如 10s,1m
Copied!

案例

杀指定 cn-hangzhou.192.168.0.205 节点上 kubelet 进程
yaml配置方式如下
1
apiVersion: chaosblade.io/v1alpha1
2
kind: ChaosBlade
3
metadata:
4
name: kill-node-process-by-names
5
spec:
6
experiments:
7
- scope: node
8
target: process
9
action: kill
10
desc: "kill node process by names"
11
matchers:
12
- name: names
13
value: ["cn-hangzhou.192.168.0.205"]
14
- name: process
15
value: ["redis-server"]
Copied!
可以看到执行前后,redis-server 的进程号发生改变,说明被杀掉后,又被重新拉起
1
# ps -ef | grep redis-server
2
19497 root 2:05 redis-server *:6379
3
4
# ps -ef | grep redis-server
5
31855 root 0:00 redis-server *:6379
Copied!
通过 kubectl get blade kill-node-process-by-names -o json 可以查看详细的执行结果(下发只截取部分内容)
1
{
2
"apiVersion": "v1",
3
"items": [
4
{
5
"apiVersion": "chaosblade.io/v1alpha1",
6
"kind": "ChaosBlade",
7
"metadata": {
8
"finalizers": [
9
"finalizer.chaosblade.io"
10
],
11
"generation": 1,
12
"name": "kill-node-process-by-names",
13
"resourceVersion": "9421288",
14
"selfLink": "/apis/chaosblade.io/v1alpha1/chaosblades/kill-node-process-by-names",
15
"uid": "24aed084-ff70-11e9-8883-00163e0ad0b3"
16
},
17
"status": {
18
"expStatuses": [
19
{
20
"action": "kill",
21
"resStatuses": [
22
{
23
"id": "ebe34959424fb022",
24
"kind": "node",
25
"name": "cn-hangzhou.192.168.0.205",
26
"nodeName": "cn-hangzhou.192.168.0.205",
27
"state": "Success",
28
"success": true,
29
"uid": "e179b30d-df77-11e9-b3be-00163e136d88"
30
}
31
],
32
"scope": "node",
33
"state": "Success",
34
"success": true,
35
"target": "process"
36
}
37
],
38
"phase": "Running"
39
}
40
}
41
],
42
}
Copied!
执行以下命令停止实验:
1
kubectl delete -f kill_node_process_by_names.yaml
Copied!
或者直接删除 blade 资源:
1
kubectl delete blade kill-node-process-by-names
Copied!
blade 执行方式
1
blade create k8s node-process kill --process redis-server --names cn-hangzhou.192.168.0.205 --kubeconfig config
Copied!
如果执行失败,会返回详细的错误信息;如果执行成功,会返回实验的 UID:
1
{"code":200,"success":true,"result":"fc93e5bbe4827d4b"}
Copied!
可通过以下命令查询实验状态:
1
blade query k8s create fc93e5bbe4827d4b --kubeconfig config
2
3
{"code":200,"success":true,"result":{"uid":"fc93e5bbe4827d4b","success":true,"error":"","statuses":[{"id":"859c56e6850c1c1b","uid":"e179b30d-df77-11e9-b3be-00163e136d88","name":"cn-hangzhou.192.168.0.205","state":"Success","kind":"node","success":true,"nodeName":"cn-hangzhou.192.168.0.205"}]}}
Copied!
销毁实验:
1
blade destroy fc93e5bbe4827d4b
Copied!

常见问题

其他问题参考 [blade create k8s](blade create k8s.md) 常见问题
Last modified 4d ago