This repository implements the rest endpoints to fetch all apps deployed as a deployment object on the current k8s cluster.
Exposed endpoints only return three fields:name
of the app,applicationGroup
it belongs to and how many correspondingpods
are in healthy state.
GET
: Get all services contains number of pods running in the cluster in namespace default per service and per application group.
Example:
$ curl -X GET -H "Content-type: application/json" -H "Accept: application/json" http://localhost:8080/services
[
{
"name": "<service>",
"applicationGroup": "alpha",
"runningPodsCount": 2
},
{
"name": "<service>",
"applicationGroup": "beta",
"runningPodsCount": 1
}
...
]
GET
: Get all services by application group contains number of running pods in the cluster in namespacedefault
that are part of the sameapplicationGroup
Example:
$ curl -X GET -H "Content-type: application/json" -H "Accept: application/json" http://localhost:8080/services/alpha
GET `/services/alpha`
[
{
"name": "<service>",
"applicationGroup": "alpha",
"runningPodsCount": 2
}
]
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Docker Engine (preferably 20.0.1+) is required to run
make docker-build
/make docker-push
. - If you are running locally using
make run-local
then make sure that kubeconfig file exist at location~/.kube/config
and context is set to the Kubernetes cluster that you want to work on.
$ git clone https://github.com/shani1998/k8s-utility-controller.git
To run all tests
$ make test
To build and push docker image
# change image registry variable in Makefile to where you have the permission.
$ make docker-build
$ make docker-push
To run and test locally
$ make run-local #kubeconfig file should present at ~/.kube/config
$ curl localhost:8080/services
$ curl localhost:8080/services/alpha
To deploy in kubernetes cluster and test
$ cd k8s-utility-controller/
$ k apply -f deploy/
$ curl <Node-IP>:<NODE-PORT>/services
$ curl <Node-IP>:<NODE-PORT>/services/alpha
# grep NodePort using
# kubectl get service k8s-utility-controller -oyaml | grep -i nodeport
# get the nodeIP where pod deployed