Questo contenuto non è disponibile nella lingua selezionata.

Chapter 3. Running functions locally


You can run a function locally by using the kn func tool. This can be useful, for example, for testing the function before deploying it to the cluster.

3.1. Running a function locally

You can use the kn func run command to run a function locally in the current directory or in the directory specified by the --path flag. If the function that you are running has never previously been built, or if the project files have been modified since the last time it was built, the kn func run command builds the function before running it by default.

Example command to run a function in the current directory

$ kn func run
Copy to Clipboard Toggle word wrap

Example command to run a function in a directory specified as a path

$ kn func run --path=<directory_path>
Copy to Clipboard Toggle word wrap

You can also force a rebuild of an existing image before running the function, even if there have been no changes to the project files, by using the --build flag:

Example run command using the build flag

$ kn func run --build
Copy to Clipboard Toggle word wrap

If you set the build flag as false, this disables building of the image, and runs the function using the previously built image:

Example run command using the build flag

$ kn func run --build=false
Copy to Clipboard Toggle word wrap

You can use the help command to learn more about kn func run command options:

Build help command

$ kn func help run
Copy to Clipboard Toggle word wrap

Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat