Skip to main content

Chaos Toolkit Kubernetes support

Project description

# Chaos Toolkit Kubernetes Support

[![Build Status](https://travis-ci.org/chaostoolkit/chaostoolkit-kubernetes.svg?branch=master)](https://travis-ci.org/chaostoolkit/chaostoolkit-kubernetes)
[![codecov](https://codecov.io/gh/chaostoolkit/chaostoolkit-kubernetes/branch/master/graph/badge.svg)](https://codecov.io/gh/chaostoolkit/chaostoolkit-kubernetes)
[![Python versions](https://img.shields.io/pypi/pyversions/chaostoolkit-kubernetes.svg)](https://www.python.org/)
[![Downloads](https://pepy.tech/badge/chaostoolkit-kubernetes)](https://pepy.tech/project/chaostoolkit-kubernetes)

This project contains activities, such as probes and actions, you can call from
your experiment through the Chaos Toolkit.

## Install

To be used from your experiment, this package must be installed in the Python
environment where [chaostoolkit][] already lives.

[chaostoolkit]: https://github.com/chaostoolkit/chaostoolkit

```
$ pip install chaostoolkit-kubernetes
```

## Usage

To use the probes and actions from this package, add the following to your
experiment file:

```json
{
"name": "all-our-microservices-should-be-healthy",
"provider": {
"type": "python",
"module": "chaosk8s.probes",
"func": "microservice_available_and_healthy",
"arguments": {
"name": "myapp",
"ns": "myns"
}
}
},
{
"type": "action",
"name": "terminate-db-pod",
"provider": {
"type": "python",
"module": "chaosk8s.pod.actions",
"func": "terminate_pods",
"arguments": {
"label_selector": "app=my-app",
"name_pattern": "my-app-[0-9]$",
"rand": true,
"ns": "default"
}
},
"pauses": {
"after": 5
}
}
```

That's it! Notice how the action gives you the way to kill one pod randomly.

Please explore the code to see existing probes and actions.

### Discovery

You may use the Chaos Toolkit to discover the capabilities of this extension:

```
$ chaos discover chaostoolkit-kubernetes --no-install
```

## Configuration

This extension to the Chaos Toolkit can use the Kubernetes configuration
found at the usual place in your HOME directory under `~/.kube/`, or, when
run from a Pod in a Kubernetes cluster, it will use the local service account.
In that case, make sure to set the `CHAOSTOOLKIT_IN_POD` environment variable
to `"true"`.

You can also pass the credentials via secrets as follows:

```json
{
"secrets": {
"kubernetes": {
"KUBERNETES_HOST": "http://somehost",
"KUBERNETES_API_KEY": {
"type": "env",
"key": "SOME_ENV_VAR"
}
}
}
}
```

Then in your probe or action:

```json
{
"name": "all-our-microservices-should-be-healthy",
"provider": {
"type": "python",
"module": "chaosk8s.probes",
"func": "microservice_available_and_healthy",
"secrets": ["kubernetes"],
"arguments": {
"name": "myapp",
"ns": "myns"
}
}
}
```

You may specify the Kubernetes context you want to use as follows:

```json
{
"secrets": {
"kubernetes": {
"KUBERNETES_CONTEXT": "minikube"
}
}
}
```

Or via the environment:

```
$ export KUBERNETES_CONTEXT=minikube
```

In the same spirit, you can specify where to find your Kubernetes configuration
with:

```
$ export KUBECONFIG=some/path/config
```

## Contribute

If you wish to contribute more functions to this package, you are more than
welcome to do so. Please fork this project, make your changes following the
usual [PEP 8][pep8] code style, add appropriate tests and submit a PR for
review.

[pep8]: https://pycodestyle.readthedocs.io/en/latest/

The Chaos Toolkit projects require all contributors must sign a
[Developer Certificate of Origin][dco] on each commit they would like to merge
into the master branch of the repository. Please, make sure you can abide by
the rules of the DCO before submitting a PR.

[dco]: https://github.com/probot/dco#how-it-works

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chaostoolkit-kubernetes-0.19.1.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

chaostoolkit_kubernetes-0.19.1-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file chaostoolkit-kubernetes-0.19.1.tar.gz.

File metadata

  • Download URL: chaostoolkit-kubernetes-0.19.1.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.6

File hashes

Hashes for chaostoolkit-kubernetes-0.19.1.tar.gz
Algorithm Hash digest
SHA256 072163f2f528b583104fd1c62daa4c6bf0ed31b59d5e22d83839a3f21a04a31c
MD5 049750171f4b47106a67aa9a22080b68
BLAKE2b-256 2b8b67b0689282fbca73a85a3b8f6e77de7fa1bb3240ae591add19b01fd511eb

See more details on using hashes here.

File details

Details for the file chaostoolkit_kubernetes-0.19.1-py3-none-any.whl.

File metadata

  • Download URL: chaostoolkit_kubernetes-0.19.1-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.6

File hashes

Hashes for chaostoolkit_kubernetes-0.19.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c8a4db968af7970d04d9652c110e2632412301f2951bb8efaeb1052a8a93424
MD5 8e130f0b054d84659de602a08a5b3e2b
BLAKE2b-256 487594f8ec55b2a5291f6c7ff73d850b464c0c5dea19d1615ff4b5af0b629f3c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page