Skip to main content

GCP VM instance stop by label

GCP VM instance stop by label powers off from the GCP VM instances (filtered by a label before) for a specific duration.

GCP VM Instance Stop By Label

Use cases

  • GCP VM instance stop by label 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 should belong to a single GCP project. For more information, go to GCP project ID.
INSTANCE_LABEL Name of the target VM instances. This value is provided as key:value pair or as a key if the corresponding value is empty. For example, vm:target-vm. For more information, go to target GCP instances.
ZONES The zone of the target VM instances. Only one zone is provided, that is, all the target instances should reside in the same zone. 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. The fault doesn't start the VM instances after the duration when this variable is set. Instead, the fault checks the instance group for new instances. Defaults to disable. For more information, go to managed instance group.
INSTANCE_AFFECTED_PERC Percentage of the total VMs filtered using the target label (specify numeric values only). Defaults to 0 (corresponds to 1 instance). For more information, go to instance affected percentage.
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.

Instance affected percentage

It specifies the number of VMs filtered using the target label. It defaults to 0 that corresponds to a single instance. Tune it by using the INSTANCE_AFFECTED_PERC environment variable.

Target GCP instances

It stops all the instances that are filtered using the INSTANCE_LABEL label in the ZONES zone in the GCP_PROJECT_ID project.

Note: INSTANCE_LABEL environment variable accepts only one label and ZONES accepts only one zone name. Therefore, all the instances must reside in the same zone.

Use the following example to tune it:

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: gcp-vm-instance-stop-by-label
spec:
components:
env:
- name: INSTANCE_LABEL
value: 'vm:target-vm'
- name: ZONES
value: 'us-east1-b'
- name: GCP_PROJECT_ID
value: 'my-project-4513'
- name: TOTAL_CHAOS_DURATION
VALUE: '60'

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:

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: gcp-vm-instance-stop-by-label
spec:
components:
env:
- name: MANAGED_INSTANCE_GROUP
value: 'enable'
- name: INSTANCE_LABEL
value: 'vm:target-vm'
- name: ZONES
value: 'us-east1-b'
- name: GCP_PROJECT_ID
value: 'my-project-4513'
- name: TOTAL_CHAOS_DURATION
VALUE: '60'
- name: INSTANCE_AFFECTED_PERC
VALUE: "0"