Skills2026年4月15日·1 分钟阅读

OpenFaaS — Serverless Functions Made Simple

OpenFaaS is a framework for packaging code, binaries or containers as portable serverless functions that run on Kubernetes or containerd with autoscaling, metrics, and a rich CLI.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
OpenFaaS Serverless
先审查命令
npx -y tokrepo@latest install 258f31fe-38fa-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

TL;DR
OpenFaaS runs serverless functions on Kubernetes or containerd with autoscaling and metrics.
§01

What it is

OpenFaaS is a framework for packaging code, binaries, or containers as portable serverless functions. It runs on Kubernetes or containerd, providing autoscaling, metrics collection, and a rich CLI for managing deployments.

OpenFaaS appeals to developers and platform engineers who want serverless capabilities without vendor lock-in to AWS Lambda or Google Cloud Functions. If you run your own Kubernetes cluster, OpenFaaS gives you the same deploy-and-forget experience.

§02

How it saves time or tokens

OpenFaaS eliminates boilerplate container orchestration. You write a function in any language, run faas-cli build && faas-cli deploy, and the platform handles image building, scaling to zero, and request routing. No Dockerfiles to maintain, no ingress rules to configure, no HPA manifests to write.

For AI workloads, you can wrap an inference endpoint as an OpenFaaS function and get automatic scale-to-zero when idle, cutting cloud costs on GPU instances that sit unused.

§03

How to use

  1. Install the OpenFaaS CLI: curl -sL https://cli.openfaas.com | sudo sh
  2. Deploy the OpenFaaS stack to your cluster: arkade install openfaas
  3. Create a new function from a template: faas-cli new --lang python3 my-function
  4. Build and deploy: faas-cli up -f my-function.yml
§04

Example

# my-function.yml
provider:
  name: openfaas
  gateway: http://127.0.0.1:8080

functions:
  my-function:
    lang: python3
    handler: ./my-function
    image: my-registry/my-function:latest
    environment:
      write_timeout: 30s
      read_timeout: 30s
    labels:
      com.openfaas.scale.min: '1'
      com.openfaas.scale.max: '10'

The function handler is a simple Python file:

def handle(req):
    return 'Hello from OpenFaaS: ' + req
§05

Related on TokRepo

§06

Common pitfalls

  • Forgetting to set write_timeout for long-running functions causes 502 errors under load
  • Scale-to-zero is not enabled by default; you need to configure the faas-idler or use OpenFaaS Pro
  • Using the community edition in production without monitoring leaves you blind to cold-start latency spikes

常见问题

What languages does OpenFaaS support?+

OpenFaaS supports any language or binary that can run in a container. Official templates exist for Python, Node.js, Go, Java, C#, Ruby, and PHP. You can also use a custom Dockerfile template to run anything that responds to HTTP on port 8080.

How does OpenFaaS differ from AWS Lambda?+

AWS Lambda is a managed service tied to the AWS ecosystem. OpenFaaS is self-hosted and runs on any Kubernetes cluster or containerd host. You own the infrastructure, avoid vendor lock-in, and can deploy on-premise or across clouds. The tradeoff is that you manage the cluster yourself.

Does OpenFaaS scale to zero?+

Yes, but it requires the faas-idler component (community edition) or the built-in scale-to-zero feature in OpenFaaS Pro. When enabled, functions with no traffic are scaled down to zero replicas and cold-started on the next request.

Can OpenFaaS run without Kubernetes?+

Yes. OpenFaaS supports faasd, a lightweight alternative that uses containerd directly without Kubernetes. This is suitable for single-node deployments, edge devices, or development environments where a full cluster is overkill.

How does autoscaling work in OpenFaaS?+

OpenFaaS uses a built-in autoscaler that monitors requests per second. You set min and max replica counts via labels in your function YAML. The autoscaler adjusts replicas based on demand. For more advanced scaling, you can integrate with Kubernetes HPA.

引用来源 (3)
  • OpenFaaS GitHub— OpenFaaS packages code as portable serverless functions on Kubernetes or contain…
  • faasd GitHub— faasd provides a lightweight containerd-based alternative to Kubernetes
  • Kubernetes Docs— Kubernetes Container Runtime Interface specification

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产