GithubHelp home page GithubHelp logo

albertosh / chaostoolkit-kubernetes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chaostoolkit/chaostoolkit-kubernetes

0.0 1.0 0.0 112 KB

Kubernetes driver extension of the Chaos Toolkit probes and actions API

Home Page: https://docs.chaostoolkit.org/drivers/kubernetes/

License: Apache License 2.0

Python 98.39% Shell 1.61%

chaostoolkit-kubernetes's Introduction

Chaos Toolkit Kubernetes Support

Build Status codecov Python versions Downloads

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-kubernetes

Usage

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

{
    "name": "all-our-microservices-should-be-healthy",
    "type": "probe",
    "tolerance": "true",
    "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:

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

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

chaostoolkit-kubernetes's People

Contributors

devatoria avatar dviniere avatar lawouach avatar nithyanatarajan avatar palmerabollo avatar russmiles avatar sappo avatar sudoq avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.