VMware CPU hog
VMware CPU hog applies stress on the CPU resources on Linux OS based VMware VM.
- It checks the performance of the application running on the VMware VMs.
Usage
View the uses of the fault
This fault helps determine how resilient an application is when stress is applied on the CPU resources of a VMware virtual machine. The fault causes CPU stress on the target resource(s). It simulates the situation of lack of CPU for processes running on the application, which degrades their performance. It also helps verify metrics-based horizontal pod autoscaling as well as vertical autoscale, i.e. demand based CPU addition. It helps scalability of nodes based on growth beyond budgeted pods. It verifies the autopilot functionality of (cloud) managed clusters. It benefits include verifying multi-tenant load issues (when the load increases on one container, it does not cause downtime in other containers).
Prerequisites
- Kubernetes > 1.16
- Execution plane is connected to vCenter and the hosts on port 443.
- VMware tool is installed on the target VM with remote execution enabled.
- Adequate vCenter permissions to access the hosts and the VMs.
- Create a Kubernetes secret that has the Vcenter credentials in the
CHAOS_NAMESPACE
. Below is a sample secret file:
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 a ChaosEngine
environment variable.
Default validations
The VM should be in a healthy state.
Fault tunables
Fault tunables
Mandatory fields
Variables | Description | Notes |
---|---|---|
VM_NAME | Name of the target VM. | For example, ubuntu-vm-1 code>. |
Optional fields
Variables | Description | Notes |
---|---|---|
CPU_CORES | Number of CPU cores subject to CPU stress. | Default to 1. |
CPU_LOAD | Load exerted on each CPU core (in percentage). | Defaults to 100%. |
TOTAL_CHAOS_DURATION | Duration that you specify, through which chaos is injected into the target resource (in seconds). | Defaults to 30s. |
CHAOS_INTERVAL | Time interval between two successive instance terminations. | Defaults to 30s. |
RAMP_TIME | Period to wait before and after injecting chaos (in seconds). | For example, 30s. |
SEQUENCE | Sequence of chaos execution for multiple instances. | Defaults to parallel. Supports serial sequence as well. |
Fault examples
Common fault tunables
Refer to the common attributes to tune the common tunables for all the faults.
CPU_CORES
It stresses the CPU_CORE
of the target VM for the duration defined by the TOTAL_CHAOS_DURATION
environment variable.
Use the following example to tune it:
# CPU hog in the VMware VM
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: VMware-cpu-hog
spec:
components:
env:
# Name of the VM
- name: VM_NAME
value: 'test-vm-01'
# CPU cores for stress
- name: CPU_CORES
value: '1'
CPU load
It specifies the load exerted on each VM CPU core (in percentage). You can tune it using the CPU_LOAD
environment variable.
Use the following example to tune it:
# CPU hog in the VMware VM
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: VMware-cpu-hog
spec:
components:
env:
# Name of the VM
- name: VM_NAME
value: 'test-vm-01'
# CPU load in percentage for the stress
- name: CPU_LOAD
value: '100'