In this tutorial, you will learn how to integrate your Litmus ChaosCenter with Gitops, how to create remote experiments chaos scenarios on Github and have them synced automatically with your local cluster.

What you will learn

In this tutorial, you would first go over what Gitops is, why it is useful and the different types of Gitops. Next, you would create a remote chaos hub repository on Github by forking an already existing repository. Then, you will learn how to connect this remote repository to ChaosCenter using an access token or an ssh key.


Gitops was released in Litmus v2.0 Beta1. In Litmus, Gitops enables you to configure a single source of truth for your Chaos Scenarios and experiments, such that any changes made to either the artifacts stored in the configured git repository or the ChaosCenter will automatically sync with each other. This allows you to create and execute chaos scenarios directly from git.

The two types of Gitops we have are mainly frontend and backend Gitops however, this tutorial will only be focusing on the frontend gitops.

Frontend Gitops enables you to connect your ChaosCenter with any git repository and the ChaosCenter will sync all your chaos scenario manifests with that git repository. You can then make changes directly on Github and it will reflect on the ChaosCenter as well.

In this tutorial, you will be using an entirely new repository for your Gitops. Navigate to GitHub and create a new repository. Here's an example of one I created here.

Open the ChaosCenter and navigate to the settings tab and from the navigation bar select the Gitops option.

Select the git repository option and type in the URL of your repository and the branch in which your experiments resides.

NOTE: If you intend to use ssh, it is necessary that you add your ssh GitHub URL instead of https.

The ChaosCenter provides two ways in which you could link a repository. You can connect to a Github repository using either of the following.

Using an Access Token

The access token option is selected by default. You can get this token from your Github profile.. To get this access token, navigate to github.com/settings/tokens and click on the Generate new token button.

Add a description to the note section of the token, select an expiration date, then select scopes for the token. The scopes let GitHub know what permissions levels the token has, select the scopes you want but specifically give the token read access to your repositories and click on the Generate token button.

Make sure you copy your token once it is added. You won't be able to copy it afterwards and will need to generate a new one.

Go back to the ChaosCenter and paste this token into the access token field, then click the Submit Now button.

Using SSH

Another option Gitops provides is the SSH option. If you selected the SSH key option, you will be presented with an already generated SSH key.

Click the Copy button to copy this key and add it to your account. There are two ways this can be added:

Adding ssh to a specific repository

This is recommended because it gives the keys access to only that repository and nothing else.

Navigate to your repository and click the settings button at the top right nav.

Select the Deploy keys in the vertical menu and click the Add deploy key button.

Paste the copied ssh key, and give it a title. Before you save, there is an Allow write access checkbox by the bottom left, make sure it is selected so that the key will be allowed to write to your repository.

This key will only have access to this repository.

Adding ssh to your profile settings

This is not the recommended way to do it because this will give your ssh key access to your other repositories.

Navigate to github.com/settings/ssh.

You will see a New SSH key button. Click this button, add a title and paste in your SSH key.

Then, click the Add SSH key button.

Verifying Gitops

Navigate back to your repository and reload to observe that Litmus has automatically pushed a commit to your repository.

To further verify that this is working as expected, schedule a new chaos scenario on your ChaosCenter. You will notice that immediately after the chaos scenario is scheduled, Litmus automatically pushes this chaos scenario manifest to your designated Gitops repository.

If this chaos scenario is edited on Github, it will be updated on the ChaosCenter making it a single source of truth for all your chaos scenarios.

In this tutorial, we covered what Gitops is and why it is useful. We showed how you can connect your ChaosCenter to a remote Github repository using two different Gitops method -- Access Tokens, and SSH. To learn more about Litmus and the ChaosCenter, you can refer to Litmus Documentation.

Please visit us on our LitmusSlack Channel (in Kubernetes workspace) and tell us how you like LitmusChaos and this tutorial! We are happy to hear your thoughts & suggestions!

Also, make sure to follow us on Twitter to get the latest news on LitmusChaos, our tutorials, and the newest releases!