Extended version of Chaos Toolkit Kubernetes support
Project description
# This is extended version of Chaos Toolkit Kubernetes Support
# Created to provide more flexibility with experiments
[![Build Status](https://travis-ci.org/chaostoolkit/chaostoolkit-kubernetes.svg?branch=master)](https://travis-ci.org/chaostoolkit/chaostoolkit-kubernetes)
[![Python versions](https://img.shields.io/pypi/pyversions/chaostoolkit-kubernetes.svg)](https://www.python.org/)
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-wix,
"func": "microservice_available_and_healthy",
"arguments": {
"name": "myapp",
"ns": "myns"
}
}
},
{
"type": "action",
"name": "terminate-db-pod",
"provider": {
"type": "python",
"module": chaosk8s-wix,
"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_wix,
"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
# Created to provide more flexibility with experiments
[![Build Status](https://travis-ci.org/chaostoolkit/chaostoolkit-kubernetes.svg?branch=master)](https://travis-ci.org/chaostoolkit/chaostoolkit-kubernetes)
[![Python versions](https://img.shields.io/pypi/pyversions/chaostoolkit-kubernetes.svg)](https://www.python.org/)
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-wix,
"func": "microservice_available_and_healthy",
"arguments": {
"name": "myapp",
"ns": "myns"
}
}
},
{
"type": "action",
"name": "terminate-db-pod",
"provider": {
"type": "python",
"module": chaosk8s-wix,
"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_wix,
"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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chaostoolkit-k8s-wix-1.0.1.tar.gz
(17.8 kB
view hashes)
Built Distribution
Close
Hashes for chaostoolkit-k8s-wix-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 475c5d55d9cf38ad0a0173c63426258d7a70b37b25f5eb9b0ab3c2306f632043 |
|
MD5 | 2af8cd034e93082fbe4bb67fe8e47ae5 |
|
BLAKE2b-256 | f55c5421d5d69647118f7a2ec78eb52d5ee5abad161104c9ca026521d4973c58 |
Close
Hashes for chaostoolkit_k8s_wix-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73a9af7f2e8ac1581ff62443c47de4c2ecb7c9b1f8dc56186048a31aeddec3b4 |
|
MD5 | 230a88d30491f69708ee04f7eb6c8285 |
|
BLAKE2b-256 | 7cb7808d67155cdce4dc63f05496f351642891c78e57ed0a19c93beea8aaaf83 |