Skip to content

porthunt/mock8s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mock8s - Mock Kubernetes

Build Status

mock8s is an easy way to test your kubernetes resources.

Summary

def delete_service(namespace):
    config.load_kube_config()
    api_instance = client.CoreV1Api()
    api_instance.delete_namespaced_service("foobar", "default")

Using the previous code, kubernetes-client will try to delete the resource Service with the name "foobar". If you want to have a unit test for this, you don't want your test to actually modify your cluster. To avoid this situation, you can use mock8s.

Simply add a decorator @mock8s and mock8s will mock the cluster for you. So you can simply use

@mock8s
def delete_service(namespace):
    config.load_kube_config()
    api_instance = client.CoreV1Api()
    api_instance.delete_namespaced_service("foobar", "default")

With this decorator, all the supported interactions with the cluster are mocked.

Support

Check the wiki page to verify if the class/method you want to test is supported.

Install

Since mock8s is still not available on pip, you can install it using:

$ pip install git+https://https://github.com/porthunt/mock8s.git@0.1.0

About

mock8s is an easy way to test your kubernetes resources.

Resources

License

Stars

Watchers

Forks

Packages

No packages published