Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

Chapter 1. Getting started with functions


Function lifecycle management includes creating and deploying a function, after which it can be invoked. You can do all of these operations on OpenShift Serverless using the kn func tool.

1.1. Prerequisites

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

  • The OpenShift Serverless Operator and Knative Serving are installed 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 the oc CLI installed.
  • 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 invoke a function.

Procedure

  1. Create a function project:

    $ kn func create -l <runtime> -t <template> <path>
    Copy to Clipboard Toggle word wrap

    Example command

    $ kn func create -l typescript -t cloudevents examplefunc
    Copy to Clipboard Toggle word wrap

    Example output

    Created typescript function in /home/user/demo/examplefunc
    Copy to Clipboard Toggle word wrap

  2. Navigate to the function project directory:

    Example command

    $ cd examplefunc
    Copy to Clipboard Toggle word wrap

  3. Build and run the function locally:

    Example command

    $ kn func run
    Copy to Clipboard Toggle word wrap

  4. Deploy the function to your cluster:

    $ kn func deploy
    Copy to Clipboard Toggle word wrap

    Example output

    Function deployed at: http://func.example.com
    Copy to Clipboard Toggle word wrap

  5. Invoke the function:

    $ kn func invoke
    Copy to Clipboard Toggle word wrap

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

1.4. Next steps

Nach oben
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2025 Red Hat