Hello Chaos Engineers,
In this article, we will get to know about one of the salient features of Litmus Portal i.e My Hub. We will go through the steps from connecting a hub to creating a custom workflow. My Hub allows SREs to orchestrate their Litmus Experiments directly from their respective Github repositories.
What is Litmus and how we can run chaos experiments using Litmus Portal?
Litmus is an open-source chaos engineering framework that provides tools to set up chaos in Kubernetes to help developers and SREs discover weaknesses and flaws in the application system. It is very easy to use and comes with detailed documentation. It also provides a large collection of chaos experiments, which you can find here. If you want to get started with Litmus Portal and how to create a custom workflow, this article is surely going to help you. You can also join our slack community for an open discussion.
Litmus Portal allows you to create, run and analyze the chaos workflows using a UI console. SREs can invite their team members to work on different projects and analyze the workflows present in the projects. Currently the Litmus Portal is in beta-0 version and lots of improvements are being added on a daily basis.
Steps involving the creation of custom workflows using MyHub are :
Using the Default MyHub:
When a user creates a project on Litmus Portal, a default MyHub is provided to the user. It is similar to the Litmus ChaosHub.
Connecting a MyHub:
Users can connect their chaos hubs from their Github repositories using the github link and the branch name. Once this step is done, the user can view their connected hub in the My Hub section.
View charts and experiments:
Users can select one of the hubs and view the charts present in the particular hub. The user can view a variety of chaos experiments and these are sorted according to their types like generic, kube-aws etc.
The user can then select one of the charts and view the details about the experiments.
The user can install the experiment using the experiment link, the user can also setup a service account using the RBAC link and we also provide the link for chaos engine which is highly configurable.Customize your workflows using MyHubs:
The users can click the “Create your own workflow” card in the pre-defined templates section to start creating the custom workflows.
Here the user can select a hub and choose the experiment from the different My Hubs present in the project. The user can also specify the namespace where he wants to run the chaos experiment.
After selecting the experiment from the hub, the user can now customize the experiment, the users can now tune the workflow according to their requirement.
The users can edit the appinfo which includes the appns, applabel, appkind.
To know more about appns, applable etc, please check the Litmus Docs
The users can tune the variables of the chaos engine and add more key value pairs as necessary.
Once the user has customized the experiment , more experiments can be added to the workflows. The user can also alter the sequence of the experiments in the workflow according to the requirements. Once the user clicks the Finish adding the experiments button, a YAML is generated consisting of the experiment details that the user has selected while configuring the workflow.
Here in this custom workflow, I have selected two experiemnts generic/pod-delete
and generic/pod-cpu-hog
. The generated YAML comprising these two experiment is
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: custom-chaos-workflow-1609259040
namespace: litmus
spec:
arguments:
parameters:
- name: adminModeNamespace
value: litmus
entrypoint: custom-chaos
securityContext:
runAsNonRoot: true
runAsUser: 1000
serviceAccountName: argo-chaos
templates:
- name: custom-chaos
steps:
- - name: install-chaos-experiments
template: install-chaos-experiments
- - name: pod-delete
template: pod-delete
- - name: pod-cpu-hog
template: pod-cpu-hog
- - name: revert-chaos
template: revert-chaos
- name: install-chaos-experiments
container:
args:
- kubectl apply -f
https://github.com/litmuschaos/chaos-charts/raw/master/charts/generic/pod-delete/experiment.yaml
-n {{workflow.parameters.adminModeNamespace}} | kubectl apply -f
https://github.com/litmuschaos/chaos-charts/raw/master/charts/generic/pod-cpu-hog/experiment.yaml
-n {{workflow.parameters.adminModeNamespace}} | sleep 30
command:
- sh
- -c
image: lachlanevenson/k8s-kubectl
- name: pod-delete
inputs:
artifacts:
- name: pod-delete
path: /tmp/chaosengine-pod-delete.yaml
raw:
data: |
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: pod-delete
namespace: "{{workflow.parameters.adminModeNamespace}}"
spec:
appinfo:
appns: default
applabel: app=nginx
appkind: deployment
annotationCheck: "false"
engineState: active
chaosServiceAccount: litmus-admin
monitoring: false
jobCleanUpPolicy: delete
experiments:
- name: pod-delete
spec:
components:
env:
- name: TOTAL_CHAOS_DURATION
value: "30"
- name: CHAOS_INTERVAL
value: "10"
- name: FORCE
value: "false"
container:
args:
- -file=/tmp/chaosengine-pod-delete.yaml
- -saveName=/tmp/engine-name
image: litmuschaos/litmus-checker:latest
- name: pod-cpu-hog
inputs:
artifacts:
- name: pod-cpu-hog
path: /tmp/chaosengine-pod-cpu-hog.yaml
raw:
data: |
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: pod-cpu-hog
namespace: "{{workflow.parameters.adminModeNamespace}}"
spec:
annotationCheck: "false"
engineState: active
appinfo:
appns: default
applabel: app=nginx
appkind: deployment
chaosServiceAccount: litmus-admin
monitoring: false
jobCleanUpPolicy: delete
experiments:
- name: pod-cpu-hog
spec:
components:
env:
- name: CPU_CORES
value: "1"
- name: TOTAL_CHAOS_DURATION
value: "60"
container:
args:
- -file=/tmp/chaosengine-pod-cpu-hog.yaml
- -saveName=/tmp/engine-name
image: litmuschaos/litmus-checker:latest
- name: revert-chaos
container:
args:
- kubectl delete chaosengines --all -n
{{workflow.parameters.adminModeNamespace}}
command:
- sh
- -c
image: lachlanevenson/k8s-kubectl
Now the user can run the workflow and see the results in the analytics section. Once the workflow execution is completed , the user can view the workflow in a graphical format that consists of all useful informations like the nodes, step groups etc.
Conclusion
Now you are not limited to some predefined workflows, even if you are beginner. You are getting your own chaos template that it highly customisable. Using the Public Hub and your own My Hub, you get all the chaos experiments at one place. You can play around with all the configuration from the UI and check the changes that are happening in the workflow.
Feel free to check out our ongoing project - Litmus Portal and do let us know if you have any suggestions or feedback regarding the same. You can always submit a PR if you find any required changes.
Make sure to reach out to us if you have any feedback or queries. Hope you found the blog informative!
If chaos engineering is something that excites you or if you want know more about cloud native chaos engineering, don’t forget to checkout our Litmus website, ChaosHub and the Litmus repo. Do leave a star if you find it insightful. 😊
I would love to invite you to our community to stay connected with us and get your Chaos Engineering doubts cleared.
To join our slack please follow the following steps!
Step 1: Join the Kubernetes slack using the following link: https://slack.k8s.io/
Step 2: Join the #litmus
channel on the Kubernetes slack or use this link after joining the Kubernetes slack: https://slack.litmuschaos.io/
Cheers!
Top comments (0)