Skip to main content

GCP VM instance stop

GCP VM instance stop powers off from a GCP VM instance using the instance name (or a list of instance names) before for a specific duration.

  • This fault checks the performance of the application (or process) running on the VM instance.
  • When the MANAGED_INSTANCE_GROUP environment variable is set to enable, the fault does not start the instances after chaos. Instead, the fault checks the instance group for new instances.

GCP VM Instance Stop

Use cases

  • GCP VM instance stop fault determines the resilience of an application that runs on a VM instance when a VM instance unexpectedly stops (or fails).
note
apiVersion: v1
kind: Secret
metadata:
name: cloud-secret
type: Opaque
stringData:
type:
project_id:
private_key_id:
private_key:
client_email:
client_id:
auth_uri:
token_uri:
auth_provider_x509_cert_url:
client_x509_cert_url:

Fault tunables

Mandatory fields

Variables Description Notes
GCP_PROJECT_ID Id of the GCP project that belong to the VM instances. All the VM instances must belong to a single GCP project. For more information, go to GCP project ID.
VM_INSTANCE_NAMES Name of the target VM instances. Multiple instance names can be provided as instance1,instance2,... and so on. For more information, go to target GCP instances.
ZONES The zones of the target VM instances. Zone for every instance name is provided as zone1,zone2,... and so on, in the same order as VM_INSTANCE_NAMES. For more information, go to zones.

Optional fields

Variables Description Notes
TOTAL_CHAOS_DURATION Duration that you specify, through which chaos is injected into the target resource (in seconds). Defaults to 30s. For more information, go to duration of the chaos.
CHAOS_INTERVAL Time interval between two successive instance terminations (in seconds). Defaults to 30s. For more information, go to chaos interval.
MANAGED_INSTANCE_GROUP It is set to enable if the target instance is a part of the managed instance group. Defaults to disable. For more information, go to managed instance group.
SEQUENCE Sequence of chaos execution for multiple target instances. Defaults to parallel. It supports serial sequence as well. For more information, go to sequence of chaos execution.
RAMP_TIME Period to wait before and after injecting chaos (in seconds). For example, 30s. For more information, go to ramp time.

Target GCP instances

It stops all the instances with the VM_INSTANCE_NAMES instance names in the ZONES zone in the GCP_PROJECT_ID project.

Note: VM_INSTANCE_NAMES environment variable contains multiple comma-separated VM instances. The comma-separated zone names should be provided in the same order as the instance names.

Use the following example to tune it:

## details of the GCP instance
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: gcp-vm-instance-stop
spec:
components:
env:
# comma-separated list of vm instance names
- name: VM_INSTANCE_NAMES
value: 'instance-01,instance-02'
# comma-separated list of zone names corresponds to the VM_INSTANCE_NAMES
# it should be provided in same order of VM_INSTANCE_NAMES
- name: ZONES
value: 'zone-01,zone-02'
# GCP project ID to which vm instance belongs
- name: GCP_PROJECT_ID
value: 'project-id'

Managed instance group

If the VM instances belong to a managed instance group, set the MANAGED_INSTANCE_GROUP environment variable to enable, otherwise set it disable (the default value).

Use the following example to tune it:

## scale up and down to maintain the available instance counts
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: gcp-vm-instance-stop
spec:
components:
env:
# tells if instances are part of managed instance group
# supports: enable, disable. default: disable
- name: MANAGED_INSTANCE_GROUP
value: 'enable'
# comma-separated list of vm instance names
- name: VM_INSTANCE_NAMES
value: 'instance-01,instance-02'
# comma-separated list of zone names corresponds to the VM_INSTANCE_NAMES
# it should be provided in same order of VM_INSTANCE_NAMES
- name: ZONES
value: 'zone-01,zone-02'
# GCP project ID to which vm instance belongs
- name: GCP_PROJECT_ID
value: 'project-id'
- name: TOTAL_CHAOS_DURATION
VALUE: '60'

Multiple iterations of chaos

It defines the delay between every chaos iteration. Tune the different iterations using the CHAOS_INTERVAL environment variable.

Use the following example to tune it:

# defines delay between each successive iteration of the chaos
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
chaosServiceAccount: gcp-vm-instance-stop-sa
experiments:
- name: gcp-vm-instance-stop
spec:
components:
env:
# delay between each iteration of chaos
- name: CHAOS_INTERVAL
value: '15'
# duration for the chaos execution
- name: TOTAL_CHAOS_DURATION
VALUE: '60'
- name: VM_INSTANCE_NAMES
value: 'instance-01,instance-02'
- name: ZONES
value: 'zone-01,zone-02'
- name: GCP_PROJECT_ID
value: 'project-id'