Search⌘ K

Terminating Application Instances

Explore how to create chaos in Kubernetes by terminating application pods to understand system behavior and resilience. This lesson guides you through writing and running a termination experiment, inspecting outputs, and the importance of exit codes for automation.

Inspecting the definition of terminate-pod.yaml

We’re finally there. We can finally create some chaos. We are about to destroy stuff.

Let’s take a look at the first definition that we are going to use. It is located in the chaos directory, in the file terminate-pod.yaml.

Shell
cat chaos/terminate-pod.yaml

The output is as follows.

version: 1.0.0
title: What happens if we terminate a Pod?
description: If a Pod is terminated, a new one should be created in its places.
tags:
- k8s
- pod
method:
- type: action
  name: terminate-pod
  provider:
    type: python
    module: chaosk8s.pod.actions
    func: terminate_pods
    arguments:
      label_selector: app=go-demo-8
      rand: true
      ns: go-demo-8

What do we have there? We have version, title, description, and tags. They’re all informative. They do not influence how an experiment is executed. They just provide additional information to whoever would like to know what that experiment is about.

title

The title, for example, says what happens if we terminate a Pod?. That’s a valid question.

description

The description is a statement that if a pod is terminated, a new one should be created in its ...