使用 http 请求启动 Kubernetes 作业

Start Kubernetes job with http request

使用 http 请求(webhook)启动 Kubernetes 作业的最简单方法是什么?我需要在推送到 github 后构建 docker 图像,并且必须在集群内进行。

我认为您正在寻找 KNative. Mainly the Build 的一部分。

KNative 仍处于早期阶段,但几乎是您所需要的。如果构建功能不能满足您的需求,您仍然可以使用其他功能,例如 Serving 从 http 调用触发容器映像和 运行 您需要的工具。

以下是构建文档中的描述:

A Knative Build extends Kubernetes and utilizes existing Kubernetes primitives to provide you with the ability to run on-cluster container builds from source. For example, you can write a build that uses Kubernetes-native resources to obtain your source code from a repository, build a container image, then run that image.

While Knative builds are optimized for building, testing, and deploying source code, you are still responsible for developing the corresponding components that:

  • Retrieve source code from repositories.
  • Run multiple sequential jobs against a shared filesystem, for example:
    • Install dependencies.
    • Run unit and integration tests.
  • Build container images.
  • Push container images to an image registry, or deploy them to a cluster.

The goal of a Knative build is to provide a standard, portable, reusable, and performance optimized method for defining and running on-cluster container image builds. By providing the “boring but difficult” task of running builds on Kubernetes, Knative saves you from having to independently develop and reproduce these common Kubernetes-based development processes.