说明

  • 所谓半离线值得是公司拉不下镜像来 !-_-!
  • 都是学习的官网资料​​https://chaos-mesh.org/docs​

镜像获取

  • 其实镜像获取很容易. 找一个能上外网的VPC就可以了.
mkdir /choasmesh && cd /chaosmesh
docker pull ghcr.io/chaos-mesh/chaos-mesh:${CHAOS_MESH_VERSION}
docker pull ghcr.io/chaos-mesh/chaos-daemon:${CHAOS_MESH_VERSION}
docker pull ghcr.io/chaos-mesh/chaos-dashboard:${CHAOS_MESH_VERSION}
docker save ghcr.io/chaos-mesh/chaos-mesh:${CHAOS_MESH_VERSION} > image-chaos-mesh.tar
docker save ghcr.io/chaos-mesh/chaos-daemon:${CHAOS_MESH_VERSION} > image-chaos-daemon.tar
docker save ghcr.io/chaos-mesh/chaos-dashboard:${CHAOS_MESH_VERSION} > image-chaos-dashboard.tar
curl -fsSL -o chaos-mesh.zip https://github.com/chaos-mesh/chaos-mesh/archive/refs/heads/master.zip
cd /
tar -czvf chaosmesh.tar.gz chaosmesh/

K8S单节点处理

  • 导入镜像
docker load < image-chaos-mesh.tar
docker load < image-chaos-daemon.tar
docker load < image-chaos-dashboard.tar

  • 下载helm 然后添加相关的仓库信息
helm repo add chaos-mesh https://charts.chaos-mesh.org
kubectl create ns chaos-testing
helm install chaos-mesh chaos-mesh/chaos-mesh -n=chaos-testing --version 2.1.4
# 注意这个版本号 是跟上面获取镜像的版本号一致的.

  • 查看svc
kubectl get svc -n chaos-testing
dashboard 是 nodePort格式的 可以直接获取端口进行访问.

  • 创建相关权限
使用NodePort登录后会提示创建用户. 
第一步:
需要创建一个 rbac.yaml
dashboard 会自动弹出来
一般内容为:
kind: ServiceAccount
apiVersion: v1
metadata:
namespace: default
name: account-cluster-manager-fzjew

---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: role-cluster-manager-fzjew
rules:
- apiGroups: [""]
resources: ["pods", "namespaces"]
verbs: ["get", "watch", "list"]
- apiGroups:
- chaos-mesh.org
resources: [ "*" ]
verbs: ["get", "list", "watch", "create", "delete", "patch", "update"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: bind-cluster-manager-fzjew
subjects:
- kind: ServiceAccount
name: account-cluster-manager-fzjew
namespace: default
roleRef:
kind: ClusterRole
name: role-cluster-manager-fzjew
apiGroup: rbac.authorization.k8s.io

  • 创建以及获取token
kubectl apply -f rbac.yaml
kubectl describe secrets account-cluster-manager-fzjew
# 第一个创建相关权限
# 第二个获取token