https://github.com/codemk8/apihub
Deploy APIs Made Easy
https://github.com/codemk8/apihub
api caas gateway kong kubernetes microservices
Last synced: 5 months ago
JSON representation
Deploy APIs Made Easy
- Host: GitHub
- URL: https://github.com/codemk8/apihub
- Owner: codemk8
- License: mit
- Created: 2018-02-24T09:34:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-08T02:39:12.000Z (over 7 years ago)
- Last Synced: 2024-04-23T11:19:38.520Z (about 2 years ago)
- Topics: api, caas, gateway, kong, kubernetes, microservices
- Language: Go
- Size: 16.9 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# apihub
**Deploy APIs Made Easy**
## Objectives
**apihub** is a thin layer on top of kubernetes cluster to expose and manage Restful-style microservices for external usage. It's major(or small) contribution is to easily add a restful API service to a API gateway ([kong](https://getkong.org) for now). Its usages include:
1. Build a small CAAS (Container-as-a-service) infrastructure
1. Set up a local microservice API testbed for CI
1. Save money for using only one TLS certficates (;-)); for all microservices are under the same URL (Kong proxy).
1. more ...

## Features
**apihub** features:
* A mordern Go CLI interface ([cobra](https://github.com/spf13/cobra/)) to wrap the raw kong API calls
* Made it easy to take advantage of Kong's various plugins (authorization, rate limit) for Restful APIs.
## Setups
We assume you already have:
* A running kubernetes cluster
* [Tiller](https://github.com/kubernetes/helm) is running as a service and local host has helm installed (TODO remove this requirement)
* A bunch of restful docker images that you would like to serve, in an organized way
## Development
```bash
# Make sure you have go tool
cd $GOPATH/src
mkdir -p github.com/codemk8/
cd github.com/codemk8/
git clone https://github.com/codemk8/apihub.git
cd apihub
make
# It'll generate a bin/ap binary
```
## Walkthrough
```bash
cd $GOPATH/src/github.com/codemk8/apihub
make
# Firstly do a quick check to see if prerequisites are satisfied
$ ./bin/ap check
2018/03/13 00:08:33 Found 19 pods in the cluster, checking OK.
NAME REVISION UPDATED STATUS CHART NAMESPACE
apihub-kong 1 Mon Mar 12 00:49:31 2018 DEPLOYED kong-0.1.2 default
NAME URL
stable https://kubernetes-charts.storage.googleapis.com
local http://127.0.0.1:8879/charts
# Then init the system, including persistent volumes (not fully supported yet), kong service
$ ./bin/ap init
...
# Deploy a clusterIP service in the kubernetes as you normally do with kubectl. Following example use echoserver:
$ kubectl create -f docs/manual/echoserver/echoserver.yaml
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
apihub-kong-kong-admin NodePort 172.30.250.49 8444:32444/TCP 23h
apihub-kong-kong-proxy NodePort 172.30.109.2 8443:32443/TCP 23h
apihub-kong-postgresql ClusterIP 172.30.220.61 5432/TCP 23h
http-echoserver ClusterIP 172.30.110.244 80/TCP 11d
# Ready to deploy, run 'ap deploy -h' for detailed usage
$ ./bin/ap deploy http-echoserver --name=my_echo --uris=echo/v1
2018/03/13 00:21:45 Successfully executed Deploy command.
# test the echoserver, note to use the Kong proxy's NodePort,
# Replace localhost with your real kubernetes host
$ curl -k http://localhost:32443/echo/v1
...
# (Optional) Remove an exposed API
$ ./bin/ap remove my_echo
# list APIs
$ ./bin/ap list
+---------+---------------------------+----------+----------+
| NAME | UPSTREAMURL | STRIPURI | URIS |
+---------+---------------------------+----------+----------+
| my_echo | http://http-echoserver:80 | true | /echo/v1 |
+---------+---------------------------+----------+----------+
| TOTAL | 1 |
+---------+---------------------------+----------+----------+
```
## TO DO
* More sophisticated API management including version, tagging.
* Improve usability, add Kong plugin support.
* Expose more features of Kong API.
* Try other API gateways, or just use native [Ingress in Kubernetes](https://kubernetes.io/docs/concepts/services-networking/ingress/)
* Test in medium-scaled clusters.
* Make the tool itself a Restful API service so that fancier web UI can be built as a frontend.