faaso/docs/funkos.md

83 lines
2.3 KiB
Markdown
Raw Permalink Normal View History

2024-06-30 23:23:53 +00:00
# Funkos What, Why, How
A funko is the equivalent of a AWS lambda. It's the unit
of deployment for FaaSO.
A funko is a folder containing a metadata `funko.yml` file
and source code in any language supported by a *runtime*
Think of a runtime as a template that gets merged with yout
funko and produces a full containerized application.
FaaSO can use your funko and its runtime to create a Docker image.
That docker image can be built in a server by the FaaSO proxy or it can be
built locally just like any docker image.
2024-06-30 23:31:11 +00:00
Then we can start it locally or, using the proxy, in the server.
2024-06-30 23:23:53 +00:00
```mermaid
flowchart TD
subgraph funko_hello
A(fa:fa-code Metadata)
B(fa:fa-code Code in language X)
end
R(runtime for X)
2024-06-30 23:29:23 +00:00
C(fa:fa-box Containerized Application Code)
2024-06-30 23:27:44 +00:00
D1(fa:fa-image Local Docker Image)
2024-06-30 23:29:23 +00:00
subgraph server
2024-06-30 23:27:44 +00:00
D2(fa:fa-image Remote Docker Image)
2024-06-30 23:23:53 +00:00
E(fa:fa-server FaaSO Proxy)
F(Container Instance Running In Server)
2024-06-30 23:29:23 +00:00
end
2024-06-30 23:23:53 +00:00
G(Container Instance Running Locally)
2024-06-30 23:27:44 +00:00
funko_hello --> C -- faaso build -l --> D1
2024-06-30 23:29:23 +00:00
C --> E -- faaso build --> D2
2024-06-30 23:23:53 +00:00
R --> C
2024-06-30 23:27:44 +00:00
D2 -- faaso up --> F
D1 -- faaso up -local --> G
2024-06-30 23:23:53 +00:00
```
How is that application reached? FaaSO will usually run the image
in a *opinionated* way. All funkos listen in port 3000 in their own
container instances, and they are all segregated into a network called
faaso-net.
2024-06-30 23:47:00 +00:00
The proxy is the only container exposed to the host network, everything
else needs to be accessed through it.
2024-07-09 01:02:47 +00:00
The faaso-proxy container will automatically proxy all requests so if
you access the URL `http://faaso-proxy:8888/funko/hello/foo` that will be
2024-06-30 23:23:53 +00:00
proxied to `/foo` in the `hello` funko.
2024-07-09 01:02:47 +00:00
This is all done via naming conventions. You can create your own
`faaso-whatever` container, add it to the `faaso-net` and faaso will
2024-06-30 23:23:53 +00:00
happily consider it a funko.
In the same way all funkos are simply docker containers running in that
network, with names following that convention. There is zero magic
involved.
```mermaid
flowchart TD
subgraph faaso-net
faaso-proxy
faaso-funko1
faaso-funko2
faaso-hello
end
client -- GET /funko/hello/foo --> faaso-proxy
2024-06-30 23:45:36 +00:00
client -- GET /funko/funko1/bar --> faaso-proxy
2024-06-30 23:23:53 +00:00
faaso-proxy -- GET /foo --> faaso-hello
2024-06-30 23:45:36 +00:00
faaso-proxy -- GET /bar --> faaso-funko1
2024-06-30 23:23:53 +00:00
```
The dynamic proxying is achieved by reading the current state of
Docker and just adapt to it using the naming conventions mentioned
2024-06-30 23:47:00 +00:00
above.