Remote Cluster Management

Remote Cluster Introduction

Chaos Mesh provides the cluster scoped RemoteCluster resource to help you manage and inject faults into remote Kubernetes clusters. This document describes how to create a RemoteCluster object and use it to inject faults.

Remote Cluster Management - 图1note

RemoteCluster is in an early stage. The configuration and function of it (for example, configuration migration, version management and authentication) will continue to improve. If you faced any problem, please open an issue in chaos-mesh/chaos-mesh to report.

Register a remote cluster

To register a remote cluster into the Chaos Mesh installed on the current cluster, you’ll need to create a RemoteCluster resource. After creating such a resource, necessary components will be installed automatically in the remote cluster. The following is an example of a RemoteCluster resource:

  1. apiVersion: chaos-mesh.org/v1alpha1
  2. kind: RemoteCluster
  3. metadata:
  4. name: cluster-xxxxxxx
  5. spec:
  6. namespace: 'chaos-mesh'
  7. version: '2.6.1'
  8. kubeConfig:
  9. secretRef:
  10. name: chaos-mesh-02.kubeconfig
  11. namespace: default
  12. key: kubeconfig

It will install the chaos-mesh helm chart with the KUBECONFIG provided in the .spec.kubeConfig field in the specified namespace.

Field description

ParameterTypeDescriptionDefault valueRequiredExample
namespacestringRepresent the namespace to install Chaos Mesh components in the remote clusterNoneYeschaos-mesh
versionstringThe version of Chaos Mesh to install in the remote clusterNoneYes2.6.1
kubeConfig.secretRef.namestringThe name of the secret, which is used to store the kubeconfig of remote cluster. This kubeconfig will be used to install chaos-mesh components and inject errorsNoneYeschaos-mesh-02.kubeconfig
kubeConfig.secretRef.namespacestringThe name of the kubeconfig secret.NoneYesdefault
kubeConfig.secretRef.keystringThe key of the kubeconfig in the secret.NoneYeskubeconfig

Inject errors in the remote cluster

To inject the errors to a remote cluster using the registered RemoteCluster, you could use the remoteCluster field in the .spec of every chaos types. For example:

  1. apiVersion: chaos-mesh.org/v1alpha1
  2. kind: StressChaos
  3. metadata:
  4. name: burn-cpu
  5. spec:
  6. remoteCluster: cluster-xxxxxxx
  7. mode: one
  8. selector:
  9. labelSelectors:
  10. 'app.kubernetes.io/component': 'tikv'
  11. stressors:
  12. cpu:
  13. workers: 1
  14. load: 100
  15. options: ['--cpu 2', '--timeout 600', '--hdd 1']
  16. duration: '30s'

The Chaos Mesh will inject the errors to the remote cluster using the kubeconfig registered with the RemoteCluster named cluster-xxxxxxx. The corresponding StressChaos will be automatically created in the remote cluster, and the status is synchronized back to the current cluster, so that you can manage the chaos injection for multiple different clusters in a single kubernetes.