"a robot butler serving kubernets on a platter!"
Open Source solution to automate use of kubectl!
this project is under active development!
as everyone knows by now! in order to communicate with a kubernetes cluster you need to use a tool called "Kubectl".theres a bunch of commands that you can use to interact with your cluster!
Kube-o-Matic! provides a layer on top of k8s.io/client-go to automate "kubectl"! we expose an HTTP REST API to bring kubectl to your browser!
we use our browsers to interact with alot of different systems daily so why not kubernetes! ?
as i was doing a system analysis on kubernetes to understand how it works and i was knee deep in Kubernetes repo :) i had Epiphany!!
kubectl is basically a wrapper for k8s.io/client-go. so client-go is the actuall client for kubernetes so then i used that knowledge to write my own wrapper that takes away little bit of weight from the back of developers / devops / sre teams!
- as the first feature that came to mind was parsing webhooks from github to watch a set of manifests and if changed deploy them!
- you can have multiple clusters setup and add automation to deploy accross all of them!
- theres a github robot you can use to check your manifests / automate other tasks right from the api no coding neded!
- so you can use the swagger UI / Any REST Client to easily interact with your kubernetes cluster.
- you can import and inject your kube config in a bunch of ways that we'll discuss in depth. keep on reading!
- you can easily set up jobs and watches and see the results in JSON!(Come on now i am not a Frontend Developer!)
To install Kube-o-Matic please follow the instructions bellow:
using make you can build and run the project binaries.
# build go and output to /bin
make build
# run the binary
make run
# Use kubectl to deploy the manifests located at /Manifests
kubectl apply -k /manifests
# Use Make to deploy
make deploy
# Inject Kube config
cd hack && chmod +x ./upload-kubeconfig.sh && ./upload-kubeconfig.sh -c kind-kubeomatic -a http://localhost:8555
- Download from Github packages and run in docker.
# If you have the repository cloned:
make PullAndRun
# IF you dont have the repository localy run :
docker pull docker pull ghcr.io/miladhzzzz/kube-o-matic:main
docker run -p 8555:8555 -d --name kube-o-matic ghcr.io/miladhzzzz/kube-o-matic:main
# Injecting KubeConfig
cd hack && chmod +x ./upload-kubeconfig.sh && ./upload-kubeconfig.sh -c kind-kubeomatic -a http://localhost:8555
# DONT FORGET TO UPLOAD YOUR KUBECONFIG!
- This script will build a docker image then run it and inject your kubeconfig with /hack/upload-kubeconfig.sh.
# Clone The repository
git clone https://github.com/miladhzzzz/Kube-o-Matic.git
# Change Directory into it
cd Kube-o-Matic
# Use Makefile to build and run a docker image
make BuildAndRun
## INJECTING CONFIG
# after we are finished with building and running the image we need to upload kubeconfig
cd hack && chmod +x ./upload-kubeconfig.sh && ./upload-kubeconfig.sh -c <example> -a <http://localhost:8555>
# Example ./upload-kubeconfig.sh -c kind -a http://localhost8555
-
Theres a upload-kubeconfig.sh file in /hack directory which exports your kubernetes configuration based on the context you provided otherwise it will use default and uploads the config file to Kube-o-Matic.
-
if your are on windows try this:
curl -X POST -H "Content-Type: multipart/form-data" -F "file=@/path/to/kubeconfig" http://localhost:8555/upload
- To setup our GitOps CD pipeline you need to head to your github repository : Settings > Webhook > Add Webhook and provide the following parameters:
-
in order for github to be able to reach our CD we need a "Public IP Adrress". if you are running this localy use (Ngrok)[https://github.com/ngrok] and make sure you have it installed. provide the Ngrok URL in the webhook settings.
-
webhook secret is basically preventing anyone else from activating your CD Pipeline! so you have to provide a good one and then use http://localhost:8555/webhook/secret/<"YOUR SECRET HERE"> to set the secret in your CD.
-
make sure all of your manifests are in the root directory.
-
Push Changes To your Repo and they will get deployed eachtime you update the code!
-
- you can use Postman , CURL, Browser REST Clients , or any other REST Client to communicate and monitor your kubernetes cluster.
Endpoint | Method | Description | Example |
---|---|---|---|
/ | GET | Healthchecks | curl http://localhost:8555/ |
/upload | POST | You Can Upload Your kubernetes configuration file | curl -X POST -H "Content-Type: multipart/form-data" -F "file=@/path/to/kubeconfig" http://localhost:8555/upload |
/kube/clusters | GET | Returns a list of your kubernetes clusters based on kubeConfig files uploaded | curl http://localhost:8555/kube/clusters |
/kube/:cluster/:ns/pods | GET | Returns a list of all Pods in a specifig Cluster and Namespace | curl http://localhost:8555/kube/kind-kubeomatic/default/pods |
/kube/:cluster/deployments | GET | Returns a list of all deployments in a specific Kubernetes cluster | curl http://localhost:8555/kube/my-cluster/deployments |
/kube/:cluster/replicasets | GET | Returns a list of all replicasets in a specific Kubernetes cluster | curl http://localhost:8555/kube/my-cluster/replicasets |
/kube/:cluster/nodes | GET | Returns a list of all nodes in a specific Kubernetes cluster | curl http://localhost:8555/kube/my-cluster/nodes |
/kube/:cluster/services | GET | Returns a list of all services in a specific Kubernetes cluster | curl http://localhost:8555/kube/my-cluster/services |
/kube/:cluster/events | GET | Returns a list of all events in a specific Kubernetes cluster | curl http://localhost:8555/kube/my-cluster/events |
/webhook/secret/:secret | GET | Sets your Webhook secret for GitOps Automation !REQUIRED! | curl http://localhost:8555/webhook/secret/YOUR SECRET HERE |
/webhook | POST | Receives a webhook from your github repo and processes it(GitOps) | curl -X POST -H "Content-Type: application/json" -d '{"cluster": "my-cluster", "pod": "my-pod", "namespace": "my-namespace"}' http://localhost:8555/hooks |