VM Poweroff
Introduction¶
- It causes VMWare VMs to Stop/Power-off before bringing them back to Powered-on state after a specified chaos duration using the VMWare APIs to start/stop the target VM.
- It helps to check the performance of the application/process running on the VMWare VMs.
Scenario: poweroff the vm
Uses¶
View the uses of the experiment
coming soon
Prerequisites¶
Verify the prerequisites
- Ensure that Kubernetes Version > 1.16
- Ensure that the Litmus Chaos Operator is running by executing
kubectl get pods
in operator namespace (typically,litmus
).If not, install from here - Ensure that the
vm-poweroff
experiment resource is available in the cluster by executingkubectl get chaosexperiments
in the desired namespace. If not, install from here - Ensure that you have sufficient Vcenter access to stop and start the VM.
-
(Optional) Ensure to create a Kubernetes secret having the Vcenter credentials in the
CHAOS_NAMESPACE
. A sample secret file looks like:apiVersion: v1 kind: Secret metadata: name: vcenter-secret namespace: litmus type: Opaque stringData: VCENTERSERVER: XXXXXXXXXXX VCENTERUSER: XXXXXXXXXXXXX VCENTERPASS: XXXXXXXXXXXXX
Note: You can pass the VM credentials as secrets or as an chaosengine ENV variable.
Default Validations¶
View the default validations
- VM should be in healthy state.
Minimal RBAC configuration example (optional)¶
NOTE
If you are using this experiment as part of a litmus workflow scheduled constructed & executed from chaos-center, then you may be making use of the litmus-admin RBAC, which is pre installed in the cluster as part of the agent setup.
View the Minimal RBAC permissions
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: vm-poweroff-sa
namespace: default
labels:
name: vm-poweroff-sa
app.kubernetes.io/part-of: litmus
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: vm-poweroff-sa
labels:
name: vm-poweroff-sa
app.kubernetes.io/part-of: litmus
rules:
# Create and monitor the experiment & helper pods
- apiGroups: [""]
resources: ["pods"]
verbs: ["create","delete","get","list","patch","update", "deletecollection"]
# Performs CRUD operations on the events inside chaosengine and chaosresult
- apiGroups: [""]
resources: ["events"]
verbs: ["create","get","list","patch","update"]
# Fetch configmaps & secrets details and mount it to the experiment pod (if specified)
- apiGroups: [""]
resources: ["secrets","configmaps"]
verbs: ["get","list",]
# Track and get the runner, experiment, and helper pods log
- apiGroups: [""]
resources: ["pods/log"]
verbs: ["get","list","watch"]
# for creating and managing to execute comands inside target container
- apiGroups: [""]
resources: ["pods/exec"]
verbs: ["get","list","create"]
# for configuring and monitor the experiment job by the chaos-runner pod
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["create","list","get","delete","deletecollection"]
# for creation, status polling and deletion of litmus chaos resources used within a chaos workflow
- apiGroups: ["litmuschaos.io"]
resources: ["chaosengines","chaosexperiments","chaosresults"]
verbs: ["create","list","get","patch","update","delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: vm-poweroff-sa
labels:
name: vm-poweroff-sa
app.kubernetes.io/part-of: litmus
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: vm-poweroff-sa
subjects:
- kind: ServiceAccount
name: vm-poweroff-sa
namespace: default
Experiment tunables¶
check the experiment tunables
Mandatory Fields
Variables | Description | Notes |
---|---|---|
APP_VM_MOIDS | MOIDs of the vmware instance | Once you open VM in vCenter WebClient, you can find MOID in address field (VirtualMachine:vm-5365). Alternatively you can use the CLI to fetch the MOID. Eg: vm-5365 |
Optional Fields
Variables | Description | Notes |
---|---|---|
TOTAL_CHAOS_DURATION | The total time duration for chaos insertion (sec) | Defaults to 30s |
CHAOS_INTERVAL | The interval (in sec) between successive instance termination | Defaults to 30s |
SEQUENCE | It defines sequence of chaos execution for multiple instance | Default value: parallel. Supported: serial, parallel |
RAMP_TIME | Period to wait before and after injection of chaos in sec |
Experiment Examples¶
Common Experiment Tunables¶
Refer the common attributes to tune the common tunables for all the experiments.
Stop/Poweroff VM By MOID¶
It contains MOID of the vm instance. It can be tuned via APP_VM_MOIDS
ENV.
Use the following example to tune this:
# power-off the VMWare VM
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
chaosServiceAccount: vm-poweroff-sa
experiments:
- name: vm-poweroff
spec:
components:
env:
# MOID of the VM
- name: APP_VM_MOIDS
value: 'vm-53,vm-65'
- name: TOTAL_CHAOS_DURATION
value: '60'