Skip to main content

Enable and disable infrastructure

This topic describes how you can enable and disable a Harness Delegate to use with chaos experiments.

Before you begin, review the following:

Install Infrastructure

You can install chaos infrastructure as a Kubernetes service, as a Linux daemon, or as a Windows agent, based on the targets. Before creating an infrastructure, create an environment because a chaos infrastructure is created within an environment.

tip

If you want to delete your environment, remove the environment references, that is, the infrastructure(s) associated with it first.

Enable Chaos

On Linux infrastructure

note

If you're installing the chaos infrastructure alongside SElinux, you must add a policy module to enable timedatectl. SElinux is enabled by default in distributions such as CentOS, SUSE Linux, RHEL, and Fedora among others.

Details

If you have enabled SELinux for your OS, you must add a policy module prior to the installation of the infrastructure to access timedatectl, which is used in the linux-time-chaos fault.

To add the policy module:

  1. Create the file timedatectlAllow.te in your Linux machine as follows:

module timedatectlAllow 1.0;

require {
type systemd_timedated_t;
type initrc_t;
class dbus send_msg;
}

#============= systemd_timedated_t ==============
allow systemd_timedated_t initrc_t:dbus send_msg;

  1. Install the utilities that will help in compiling and packaging the policy module for your system. Here, we're using the yum package manager to install them:
sudo yum install -y policycoreutils-python checkpolicy
  1. After the installation of these packages, compile the policy module with the following command:
sudo checkmodule -M -m -o timedatectlAllow.mod timedatectlAllow.te

This creates the binary policy module file timedatectlAllow.mod.

  1. Use the policy module file from the previous step to create a policy module package:
sudo semodule_package -o timedatectlAllow.pp -m timedatectlAllow.mod

This creates the policy module package file timedatectlAllow.pp.

  1. Add the package file from the previous step alongside the other SELinux modules in your system:
sudo semodule -i timedatectlAllow.pp

The SELinux policy module is now added, and you can proceed to install the infrastructure.

To enable chaos on Linux:

  1. Go to Chaos > Environments, and then select the environment you want to add chaos infrastructure.

  2. In the environment details page, under Infrastructure type, select Linux, and then select + Enable Chaos.

    Create Infra

  3. On the next screen, enter a Name for the infrastructure, and optionally, a Description and Tags. Select Next. You can also specify different values for the infrastructure.

    Execute Command

  4. On the next screen, copy the command to set up Linux chaos access, select Done, and then execute the copied command on your Linux machine.

Harness Terraform Provider

You can create Harness Delegate (DDCR) using Harness Terraform provider.

Validate Chaos Infrastructure Installation

After adding chaos infrastructure, Harness takes some time to set up all the chaos infrastructure resources. On the UI, if you navigate to Environments -> Windows (or Kubernetes or Linux), you can see the connection status is CONNECTED.

That's it! Now you have a dedicated chaos infrastructure and you're all set to inject chaos into your infrastructure.

Disable Chaos Infrastructure

Disabling a chaos infrastructure removes it from the environment where it resides. It also removes the infrastructure services from the Kubernetes cluster.

Go to the Environments under the Chaos tab, that lists all the environments created under the current project. Select the environment that has the chaos infrastructure to be deleted.

Based on the infrastructure you have used, you can follow the steps to disconnect Kubernetes, Linux, and Windows infrastructure, respectively.

select to disconnect

Kubernetes

  1. Select the icon against the chaos infrastructure name and select Disable.

    Delete Chaos Infra

  2. Execute the commands displayed in the modal from your terminal to remove the chaos infrastructure components. Finally, select Confirm.

With that, the chaos infrastructure will be disabled.