Skip to main content

Extended version of Chaos Toolkit Kubernetes support

Project description

Build Status

This is extended version of Chaos Toolkit Kubernetes Support

Created to provide more flexibility with experiments

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.

$ pip install chaostoolkit-k8s-wix

Usage

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

{
    "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-k8s-wix --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:

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

Then in your probe or action:

{
    "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:

{
    "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 code style, add appropriate tests and submit a PR for review.

The Chaos Toolkit projects require all contributors must sign a Developer Certificate of Origin 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.

Develop

If you wish to develop on this project, make sure to install the development dependencies. But first, create a virtual environment and then install those dependencies.

$ pip install -r requirements-dev.txt -r requirements.txt 

Then, point your environment to this directory:

$ python setup.py develop

Now, you can edit the files and they will be automatically be seen by your environment, even when running from the chaos command locally.

Test

To run the tests for the project execute the following:

$ pytest

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-k8s-wix-1.4.4.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chaostoolkit_k8s_wix-1.4.4-py3-none-any.whl (34.6 kB view details)

Uploaded Python 3

File details

Details for the file chaostoolkit-k8s-wix-1.4.4.tar.gz.

File metadata

  • Download URL: chaostoolkit-k8s-wix-1.4.4.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for chaostoolkit-k8s-wix-1.4.4.tar.gz
Algorithm Hash digest
SHA256 e4dad7ac97edda3fcfd6710a9aeeda67eee13dc9a6c7050c8968f6738bf78597
MD5 57d1c96f152852191bea669d95096915
BLAKE2b-256 6fbb3d512a65ac6fc995d301d0f54fe613bc0b724e3711e5249c012620d8b2b4

See more details on using hashes here.

File details

Details for the file chaostoolkit_k8s_wix-1.4.4-py3-none-any.whl.

File metadata

  • Download URL: chaostoolkit_k8s_wix-1.4.4-py3-none-any.whl
  • Upload date:
  • Size: 34.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for chaostoolkit_k8s_wix-1.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bc1f0d2991cc4c585b19a9f17fbbac29cdb948017d6e11d166a46bd63674a7eb
MD5 304627ac2ab9adedbc5adbd038f87d39
BLAKE2b-256 c10b5388b44396426d289a8bdafc54c413c15ad5d0dce6c44951ec030bbfb197

See more details on using hashes here.

Supported by

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