Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mock the Kubernetes cluster/server?

Kubernetes OpenAPI specification is hosted here.

https://github.com/kubernetes/kubernetes/tree/master/api/openapi-spec

Additionally, various client APIs for the Kubernetes is provided here:

https://kubernetes.io/docs/reference/using-api/client-libraries/

Using the OpenAPI specification, I am able to generate the server code, which provides the REST services. However, the applications using these K8s client APIs (written in either language - Go, Java, etc.) do not use these REST API directly.

My objective is to mock the K8s server to use in the test automation and build a controlled environment to create various test scenarios.

Is there any ready-to-use Kubernetes mock available? If not, how we can interface the client APIs with the above OpenAPI generated REST server? This way, the applications shall continue to use the client APIs but internally, they will be communicating with the mocked K8s server and not the real one.

Please help with the options.

.

like image 997
AnilJ Avatar asked Nov 06 '22 09:11

AnilJ


1 Answers

Not really a direct answer to your question, but most solutions i have seen implemented are not trying to mock the k8s API but are really using it through either k3s (from rancher labs) or KinD project (official way)

You then connect to it like a normal kubernetes cluster

like image 162
webofmars Avatar answered Nov 15 '22 08:11

webofmars