➜ Create a Rancher Server with a single node cluster (some experiments require multi node)
➜ Deploy the Demo Microservice and Install Litmus
➜ Run Experiments and Observe (repeat steps for each experiment)
- Kubernetes/kubectl
- VirtualBox
- Vagrant
- plugins for Vagrant
Note: I am using ranchers getting stared with Vagrant configuration along with a demo microservice):
https://github.com/rancher/quickstart/tree/master/vagrant
https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/deployment/quickstart-vagrant/
-
Install plugins to create VirtualBox VMs
vagrant plugin install vagrant-vboxmanage vagrant plugin install vagrant-vbguest
-
Create the environment
vagrant up --provider=virtualbox
-
Navigate to the browser
https://172.22.101.101 #username|password: admin|admin
-
Change the name of the cluster (optional)
-
Scroll to the bottom and check
etcd
,Control Plane
, andWorker
. -
Copy the contents of the clipboard then hit
Save
-
SSH into vagrant
vagrant ssh server-01
-
Paste contents of clipboard into server terminal
-
Open a new terminal on the server and watch the container
docker ps docker container logs <name> --follow
-
Navigate back to browser and wait for cluster to have an active status
-
Once created click on the cluster to access the dashboard
-
Under
Kubeconfig File
copy the file contents and put it in a file under this dirtouch kube.yaml vim kube.yaml #insert(i),paste,save and quite (:wq)
-
Check you have access to rancher on your local machine, deploy demo microservice, verify pods are running
kubectl --kubeconfig kube.yaml get pods --namespace=cattle-system #deploy kubectl --kubeconfig kube.yaml create -f sock-shop.yaml #verify - wait for running status kubectl --kubeconfig kube.yaml get pods -n sock-shop
-
Deploy Litmus ChaosOperator
kubectl --kubeconfig kube.yaml apply -f https://litmuschaos.github.io/litmus/litmus-operator-v1.9.0.yaml
-
Install Litmus Experiments
curl -sL https://github.com/litmuschaos/chaos-charts/archive/1.9.0.tar.gz -o litmus.tar.gz tar -zxvf litmus.tar.gz rm litmus.tar.gz find chaos-charts-1.9.0 -name experiments.yaml | grep generic | xargs kubectl --kubeconfig kube.yaml apply -n sock-shop -f
-
Create Service Account
kubectl --kubeconfig kube.yaml create -f rbac.yaml
-
Access url of sock shop microservice
Get front-end deployment port info:
kubectl --kubeconfig kube.yaml get deploy front-end -n sock-shop -o jsonpath='{.spec.template.spec.containers[?(@.name == "front-end")].ports[0].containerPort}'
Set port forwarding
kubectl --kubeconfig kube.yaml port-forward deploy/front-end -n sock-shop 3000:8079 #browser address: 127.0.0.1:3000
-
Delete any existing Chaos engines in the namespace
kubectl --kubeconfig kube.yaml delete chaosengine rancher-chaos -n sock-shop
-
Run the experiment
kubectl --kubeconfig kube.yaml create -f litmus/pod-memory-hog.yaml -n sock-shop
-
Observe Results (Takes a few seconds for command to turnover, results initially in
await
state)kubectl --kubeconfig kube.yaml get pods -n sock-shop --watch kubectl --kubeconfig kube.yaml describe chaosengine rancher-chaos -n sock-shop kubectl --kubeconfig kube.yaml describe chaosresult rancher-chaos-pod-memory-hog -n sock-shop #to save results to file: kubectl --kubeconfig kube.yaml describe chaosengine rancher-chaos -n sock-shop > litmus-results/chaosengine-pod-memory-hog.txt kubectl --kubeconfig kube.yaml describe chaosresult rancher-chaos-pod-memory-hog -n sock-shop > litmus-results/chaosresult-pod-memory-hog.txt
-
Uninstall
kubectl --kubeconfig kube.yaml delete -f https://litmuschaos.github.io/litmus/litmus-operator-v1.9.0.yaml kubectl delete chaosengine --all -n sock-shop kubectl --kubeconfig kube.yaml delete chaosengine --all -n litmus kubectl --kubeconfig kube.yaml delete namespaces sock-shop