--- id: container-kill title: Container Kill Experiment Details sidebar_label: Container Kill original_id: container-kill --- ------ ## Experiment Metadata | Type | Description | Tested K8s Platform | | ----------| ------------------------ | ------------------------------------------------------------------| | Generic | Kill one container in the application pod | GKE, Packet(Kubeadm), Minikube| ## Prerequisites - Ensure that the Litmus Chaos Operator is running by executing `kubectl get pods` in operator namespace (typically, `litmus`). If not, install from [here](https://raw.githubusercontent.com/litmuschaos/pages/master/docs/litmus-operator-latest.yaml) - Ensure that the `container-kill` experiment resource is available in the cluster by executing `kubectl get chaosexperiments` in the desired namespace. If not, install from [here](https://hub.litmuschaos.io/charts/generic/experiments/container-kill) - Cluster must run docker container runtime ## Entry Criteria - Application pods are healthy before chaos injection ## Exit Criteria - Application pods are healthy post chaos injection ## Details - Kills one container in the specified application pod by sending SIGKILL termination signal to its docker socket (hence docker runtime is required) - Containers are killed using the `kill` command provided by [pumba](https://github.com/alexei-led/pumba) - Pumba is run as a daemonset on all nodes in dry-run mode to begin with; the `kill` command is issued during experiment execution via `kubectl exec` - Tests deployment sanity (replica availability & uninterrupted service) and recovery workflow of the application - Good for testing recovery of pods having side-car containers ## Integrations - Container kill is achieved using the `pumba` chaos library - The desired pumba image can be configured in the env variable `LIB_IMAGE`. ## Steps to Execute the Chaos Experiment - This Chaos Experiment can be triggered by creating a ChaosEngine resource on the cluster. To understand the values to provide in a ChaosEngine specification, refer [Getting Started](getstarted.md/#prepare-chaosengine) - Follow the steps in the sections below to create the chaosServiceAccount, prepare the ChaosEngine & execute the experiment. ### Prepare chaosServiceAccount - Use this sample RBAC manifest to create a chaosServiceAccount in the desired (app) namespace. This example consists of the minimum necessary role permissions to execute the experiment. #### Sample Rbac Manifest ```yaml apiVersion: v1 kind: ServiceAccount metadata: name: nginx-sa namespace: default labels: name: nginx-sa --- # Source: openebs/templates/clusterrole.yaml apiVersion: rbac.authorization.k8s.io/v1beta1 kind: Role metadata: name: nginx-sa labels: name: nginx-sa rules: - apiGroups: ["","litmuschaos.io","batch","apps"] resources: ["pods","jobs","daemonsets","pods/exec","chaosengines","chaosexperiments","chaosresults"] verbs: ["create","list","get","patch","update","delete"] --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: RoleBinding metadata: name: nginx-sa labels: name: nginx-sa roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: nginx-sa subjects: - kind: ServiceAccount name: nginx-sa namespace: default ``` ### Prepare ChaosEngine - Provide the application info in `spec.appinfo` - Override the experiment tunables if desired #### Supported Experiment Tunables
| Variables | Description | Type | Notes |
|---|---|---|---|
| TARGET_CONTAINER | The container to be killed inside the pod | Mandatory | If the TARGET_CONTAINER is not provided it will delete the first container |
| LIB_IMAGE | The pumba image used to run the kill command | Optional | Defaults to `gaiaadm/pumba:0.4.8`. Note: pumba images >=0.6 do not work with this experiment. |
| LIB | The category of lib use to inject chaos | Optional | Only `pumba` supported currently |