Este contenido no está disponible en el idioma seleccionado.

Chapter 1. Getting started with functions


Function lifecycle management includes creating and deploying a function, after that you can call it. Use the kn func tool to perform these operations on OpenShift Serverless.

1.1. Prerequisites for OpenShift Serverless Functions

To enable the use of OpenShift Serverless Functions on your cluster, you must complete the following steps:

  • You have installed the OpenShift Serverless Operator and Knative Serving on your cluster.

    Note

    Functions are deployed as a Knative service. If you want to use event-driven architecture with your functions, you must also install Knative Eventing.

  • You have installed the oc CLI.
  • You have the Knative (kn) CLI installed. Installing the Knative CLI enables the use of kn func commands which you can use to create and manage functions.
  • You have installed Docker Container Engine or Podman version 3.4.7 or higher.
  • You have access to an available image registry, such as the OpenShift Container Registry.
  • If you are using Quay.io as the image registry, you must ensure that either the repository is not private, or that you have followed the OpenShift Container Platform documentation on Allowing pods to reference images from other secured registries.
  • If you are using the OpenShift Container Registry, a cluster administrator must expose the registry.

1.2. Creating, deploying, and invoking a function

On OpenShift Serverless, you can use the kn func to create, deploy, and call a function.

Procedure

  1. Create a function project by running the following command:

    $ kn func create -l <runtime> -t <template> <path>

    You get an output similar to the following example command:

    $ kn func create -l typescript -t cloudevents examplefunc

    You get an output similar to the following example:

    Created typescript function in /home/user/demo/examplefunc
  2. Navigate to the function project directory by running the following command:

    You get an output similar to the following example command:

    $ cd examplefunc
  3. Build and run the function locally by running the following command:

    You get an output similar to the following example command:

    $ kn func run
  4. Deploy the function to your cluster by running the following command:

    $ kn func deploy

    You get an output similar to the following example:

    Function deployed at: http://func.example.com
  5. Call the function by running the following command:

    $ kn func invoke

    This invokes either a locally or remotely running function. If both are running, the local one is invoked.

Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de la documentación de Red Hat

Legal Notice

Theme

© 2026 Red Hat
Volver arriba