fx
fx copied to clipboard
on Kubernetes
Table of Contents
- Story
- Goals
- Design
- Tasks
Story
The reason I build fx is I hate to do things repeatedly.
As an engineer, we're required to build API again and again, with multiple kinds of programing language, on different environments. we get the requirement, we start to learn the basic syntax of the language, get to familiar with the handiest framework of the specific language world, then we are going to write lines of codes, finally, we build out the API, and make it run well on own laptop, thank god, finally I can get a coffee and leave office, but sadly, you still have a lot stuffs to do, you have to think about the server, the deployment, the scale ...
I always think there must be an easy way to build an API, which does not require a developer to worry about anything but only the code, the function to handle the request since I entered the industry, then AWS lambda came out and make serverless a real thing, and now "Function as a Service" is almost a basic service of each public cloud provider. It's very easy to build an API with AWS lambda and serve it with AWS API Gateway (Google Cloud and Azure also have the same things), that's what we developer really want.
I don't know why I still not stop thinking about to build a tool to do "Function as a Service" on my own server (virtual machine and Kubernetes cluster of public cloud provider) even thought AWS, Azure, Google Cloud already have full support with reasonable pricing, maybe it's a kind of quality of an engineer, we are born to build something.
Two years ago, it's a chance I found that there was a Golang hackathon GoHack held at Shanghai, it's a weekend, then I registered with zero experience of Golang. fx was built at that hackathon and actively maintained since then.
fx is growing.
Goals
Kubernetes is an almost fact standard of cloud native infrastructure, all public cloud providers offer Kubernetes cluster service, adopting Kubernetes as an operation middleware of fx would complement fx with abilities,
- self-healing
- service discovery
- load balancing
- easy horizontal scaling
fx will be able to detect if the environment is Docker (or the other container runtime) and Kubernetes ready, fx up --name <service_name> --replica_num <num> ... will create a service to serve the API on top of service and pod of Kubernetes.
Design
fx consists of the following components,
- Packer, it packs a function into a Docker project which can run as a service and handle the incoming request with the given function.
- Service Manager, it will create an image, schedule containers running, and expose it as a service.
- Container Runtime Driver, it provides the container running infrastructure on top of container engine (Docker supported only for now, maybe rkt later).
Tasks
- [x] fx support image build
- [x] fx support export the Docker project
- [ ] Integration with Kubernetes
- [ ] Kubernetes pick ups
- [ ] Service Type
- [ ] Port, Target Port, and Node Port
- [x] Setup local development and test on kind . https://github.com/metrue/fx/pull/269
- [x] Setup CI on GitHub actions.
- [x] Setup CD on Github actions.
- [x] Run container in pods
- [x] Expose service to proxy outside request to container
- [ ] Kubernetes pick ups
- [x] Support AKS
- [ ] Support EKS
- [ ] Support GKE