blade create k8s node-network

介绍

kubernetes 节点网络相关场景,同基础资源的网络场景

命令

支持的网络场景命令如下:
    blade create k8s node-network delay 节点网络延迟场景,同 [blade create network delay](blade create network delay.md)
    blade create k8s node-network loss 节点网络丢包场景,同 [blade create network loss](blade create network loss.md)
    blade create k8s node-network dns 节点域名访问异常场景,同 [blade create network dns](blade create network dns.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 节点本地端口 40690 访问丢包率 60%
yaml 配置方式
1
apiVersion: chaosblade.io/v1alpha1
2
kind: ChaosBlade
3
metadata:
4
name: loss-node-network-by-names
5
spec:
6
experiments:
7
- scope: node
8
target: network
9
action: loss
10
desc: "node network loss"
11
matchers:
12
- name: names
13
value: ["cn-hangzhou.192.168.0.205"]
14
- name: percent
15
value: ["60"]
16
- name: interface
17
value: ["eth0"]
18
- name: local-port
19
value: ["40690"]
Copied!
保存为 yaml 文件,比如 loss-node-network-by-names.yaml,使用 kubectl 命令执行:
1
kubectl apply -f loss-node-network-by-names.yaml
Copied!
实验状态查询:
1
kubectl get blade loss-node-network-by-names -o json
Copied!
返回结果如下(省略了一部分):
1
~ » kubectl get blade loss-node-network-by-names -o json
2
{
3
"apiVersion": "chaosblade.io/v1alpha1",
4
"kind": "ChaosBlade",
5
"metadata": {
6
"creationTimestamp": "2019-11-04T09:56:36Z",
7
"finalizers": [
8
"finalizer.chaosblade.io"
9
],
10
"generation": 1,
11
"name": "loss-node-network-by-names",
12
"resourceVersion": "9262302",
13
"selfLink": "/apis/chaosblade.io/v1alpha1/chaosblades/loss-node-network-by-names",
14
"uid": "63a926dd-fee9-11e9-b3be-00163e136d88"
15
},
16
"status": {
17
"expStatuses": [
18
{
19
"action": "loss",
20
"resStatuses": [
21
{
22
"id": "057acaa47ae69363",
23
"kind": "node",
24
"name": "cn-hangzhou.192.168.0.205",
25
"nodeName": "cn-hangzhou.192.168.0.205",
26
"state": "Success",
27
"success": true,
28
"uid": "e179b30d-df77-11e9-b3be-00163e136d88"
29
}
30
],
31
"scope": "node",
32
"state": "Success",
33
"success": true,
34
"target": "network"
35
}
36
],
37
"phase": "Running"
38
}
39
}
Copied!
执行以下命令停止实验:
1
kubectl delete -f loss-node-network-by-names.yaml
Copied!
或者直接删除 blade 资源:
1
kubectl delete blade loss-node-network-by-names
Copied!
blade 执行方式
1
blade create k8s node-network loss --percent 60 --interface eth0 --local-port 40690 --kubeconfig config --names cn-hangzhou.192.168.0.205
Copied!
如果执行失败,会返回详细的错误信息;如果执行成功,会返回实验的 UID:
1
{"code":200,"success":true,"result":"e647064f5f20953c"}
Copied!
可通过以下命令查询实验状态:
1
blade query k8s create e647064f5f20953c --kubeconfig config
2
3
{"code":200,"success":true,"result":{"uid":"e647064f5f20953c","success":true,"error":"","statuses":[{"id":"fa471a6285ec45f5","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 e647064f5f20953c
Copied!

常见问题

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