To Run this simple demo, make sure you have access to a running kubernetes cluster with kubeconfig accessible at
$HOME/.kube/config
-
Setup your
$GOPATHwith the correct toolchain access! -
go getall needed dependencies
-> go get k8s.io/client-go/kubernetes
-> go get github.com/gin-gonic/gin
-> go get github.com/ghodss/yaml
-> go get github.com/stretchr/testify/assert
-
Run
go build github.com/k8sApi/apito compile the API -
Run
go install github.com/k8sApi/apito install in your$GOPATH/bin -
If steps 2. & 3. goes when then you should be able to just run
k8sApion the command line to start the kubernetes client webserver
The k8sApi web client serves the following endpoints
GET /api/nodes
GET /api/nodes/count
GET /api/pods
GET /api/pods/count
Example Request:
- Get All pods in the cluster ->
REQUEST: curl http://localhost:9090/api/pods/kube-system
- Get All pod count in the cluster ->
REQUEST: curl http://localhost:9090/api/pods/kube-system/count
RESPONSE
"{ 'pods' : 23 }"
- Get All nodes in the cluster ->
REQUEST: curl http://localhost:9090/api/nodes
- Get All node count in the cluster ->
REQUEST: curl http://localhost:9090/api/nodes/count
RESPONSE
"{ 'nodes' : 5 }"

