From a5adc6346331f507ebb02e6ea01bf8866ac8a5d7 Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Fri, 27 Nov 2026 21:32:22 -0500 Subject: [PATCH 1/9] Consolidate Functions navigation and add redirects for retired pages --- config/redirects.yml | 4 ++++ docs/versioned/.nav.yml | 14 +++++--------- docs/versioned/client/README.md | 2 +- docs/versioned/functions/creating-functions.md | 10 ---------- docs/versioned/functions/install-func.md | 18 ------------------ docs/versioned/functions/invoking-functions.md | 17 ----------------- docs/versioned/functions/kafka-functions.md | 15 --------------- .../getting-started/about-knative-functions.md | 2 +- 8 files changed, 11 insertions(+), 71 deletions(-) delete mode 100644 docs/versioned/functions/creating-functions.md delete mode 100644 docs/versioned/functions/install-func.md delete mode 100644 docs/versioned/functions/invoking-functions.md delete mode 100644 docs/versioned/functions/kafka-functions.md diff --git a/config/redirects.yml b/config/redirects.yml index 1a15338fbf6..095e3629643 100644 --- a/config/redirects.yml +++ b/config/redirects.yml @@ -240,3 +240,7 @@ plugins: versioned/getting-started/clean-up.md: versioned/getting-started/next-steps.md#clean-up versioned/bookstore/disclaimer/README.md: versioned/bookstore/disclaimer/disclaimer.md versioned/bookstore/extra-challenge/README.md: versioned/bookstore/extra-challenge/extra-challenges.md + versioned/functions/install-func.md: versioned/functions/running-functions.md + versioned/functions/creating-functions.md: versioned/functions/running-functions.md + versioned/functions/invoking-functions.md: versioned/functions/running-functions.md + versioned/functions/kafka-functions.md: versioned/functions/subscribing-functions.md diff --git a/docs/versioned/.nav.yml b/docs/versioned/.nav.yml index c04631218ba..3c98e91b6d0 100644 --- a/docs/versioned/.nav.yml +++ b/docs/versioned/.nav.yml @@ -28,15 +28,11 @@ nav: ############################################################################### - Functions: - Overview: functions/README.md - - Install: functions/install-func.md - - Create: functions/creating-functions.md - - Build: functions/building-functions.md - - Run locally: functions/running-functions.md - - Deploy: functions/deploying-functions.md - - Invoke: functions/invoking-functions.md - - Subscribe to events: functions/subscribing-functions.md - - Kafka: functions/kafka-functions.md - - Language packs: functions/language-packs.md + - Develop locally: functions/running-functions.md + - Build an image: functions/building-functions.md + - Deploy a function: functions/deploying-functions.md + - Connect events: functions/subscribing-functions.md + - Templates and runtimes: functions/language-packs.md ############################################################################### # Serving ############################################################################### diff --git a/docs/versioned/client/README.md b/docs/versioned/client/README.md index c05df275eea..28700ce25f9 100755 --- a/docs/versioned/client/README.md +++ b/docs/versioned/client/README.md @@ -37,7 +37,7 @@ The `func` CLI enables you to create, build, and deploy Knative Functions withou ### Additional resources -- See [Installing Knative Functions](../functions/install-func.md). +- See [Develop locally — Prepare](../functions/running-functions.md#prepare). - See the [`func` documentation]({{ funcdocs() }}){target=_blank} in Github. ## Connecting CLI tools to your cluster diff --git a/docs/versioned/functions/creating-functions.md b/docs/versioned/functions/creating-functions.md deleted file mode 100644 index c34be4b9261..00000000000 --- a/docs/versioned/functions/creating-functions.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -audience: developer -components: - - functions -function: how-to ---- - -# Creating functions - ---8<-- "create-a-function.md" diff --git a/docs/versioned/functions/install-func.md b/docs/versioned/functions/install-func.md deleted file mode 100644 index ad5aca03307..00000000000 --- a/docs/versioned/functions/install-func.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -audience: developer -components: - - functions -function: how-to ---- - -# Installing Knative Functions - ---8<-- "install-functions-intro.md" - -## Installing the `func` CLI - ---8<-- "install-func-CLI.md" - -## Installing the `kn func` CLI plugin - ---8<-- "install-kn-func-plugin.md" diff --git a/docs/versioned/functions/invoking-functions.md b/docs/versioned/functions/invoking-functions.md deleted file mode 100644 index da8d92b9300..00000000000 --- a/docs/versioned/functions/invoking-functions.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -audience: developer -components: - - functions -function: how-to ---- - -# Invoking functions - -You can use the `func invoke` command to send a test request to invoke a -function either locally or on your Knative cluster. - -This command can be used to test that a function is working and able to receive HTTP requests and CloudEvents correctly. - -If your function is running locally, `func invoke` sends a test request to the local instance. - -You can use the `func invoke` command to send test data to your function with the `--data` flag, as well as other options to simulate different types of requests. See the [func invoke](https://github.com/knative/func/blob/main/docs/reference/func_invoke.md){target=_blank} documentation for more information. diff --git a/docs/versioned/functions/kafka-functions.md b/docs/versioned/functions/kafka-functions.md deleted file mode 100644 index 66cbcbef7be..00000000000 --- a/docs/versioned/functions/kafka-functions.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -audience: developer -components: - - functions -function: explanation ---- - -# Kafka functions - -A function can consume messages from an Apache Kafka topic. When a function declares a `run.kafka` configuration, `func` deploys a language-agnostic runtime sidecar alongside it. The sidecar consumes the topic and delivers each record to the function as a CloudEvent over HTTP, so the function stays a plain CloudEvents handler in any language, with no Kafka client code of its own. - -The full guide lives in the `func` repository, covering concepts, a getting-started walkthrough, delivery and retries, deployment and scaling, idempotency, local development, and troubleshooting: - -- [Kafka functions guide](https://github.com/knative/func/blob/main/docs/kafka-functions/README.md){target=_blank} -- [run.kafka configuration reference](https://github.com/knative/func/blob/main/docs/reference/func_yaml.md#runkafka){target=_blank} diff --git a/docs/versioned/getting-started/about-knative-functions.md b/docs/versioned/getting-started/about-knative-functions.md index 724c2802764..7a5b3debe7d 100644 --- a/docs/versioned/getting-started/about-knative-functions.md +++ b/docs/versioned/getting-started/about-knative-functions.md @@ -37,7 +37,7 @@ required for the local workflow. `func`. Verify `func version` prints a version number. For `kn func` plugin installation, -see [Installing Knative Functions](../functions/install-func.md). +see [Develop locally — Prepare](../functions/running-functions.md#prepare). From aa0af061f49637db5862c451b95b49b53b396fa8 Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Fri, 27 Nov 2026 21:32:22 -0500 Subject: [PATCH 2/9] Rewrite Functions guides as six task-focused pages --- docs/versioned/functions/README.md | 33 ++-- .../versioned/functions/building-functions.md | 135 ++++----------- .../functions/deploying-functions.md | 143 +++++++++++++--- docs/versioned/functions/language-packs.md | 81 ++++++++- docs/versioned/functions/running-functions.md | 157 +++++++++++++++++- .../functions/subscribing-functions.md | 107 ++++++++++-- 6 files changed, 486 insertions(+), 170 deletions(-) diff --git a/docs/versioned/functions/README.md b/docs/versioned/functions/README.md index 70f9fc91d63..7bdb8d08fa5 100644 --- a/docs/versioned/functions/README.md +++ b/docs/versioned/functions/README.md @@ -3,26 +3,31 @@ audience: developer components: - functions function: explanation +hide_prev: true +hide_next: true --- -# Knative Functions overview +# Knative Functions --8<-- "about-functions.md" -## Function templates +## Start here ---8<-- "functions-templates-intro.md" +New to Knative Functions? Follow [Try Functions](../getting-started/about-knative-functions.md) +to create, edit, and test a Go function locally — no Kubernetes cluster or +registry account required. -## Language packs +## Choose a task -Functions can be written in any language supported by the available [language packs](https://github.com/knative/func/blob/main/docs/language-packs/language-pack-contract.md){target=_blank}. - +- **[Develop locally](running-functions.md):** install `func`, create a project, + run it locally, and send HTTP or CloudEvents test requests. +- **[Build an image](building-functions.md):** build a container image locally + without running or deploying it. +- **[Deploy a function](deploying-functions.md):** deploy from your machine or + build and deploy remotely on a cluster with Tekton. +- **[Connect events](subscribing-functions.md):** subscribe a function to a + Knative Broker with Triggers, or consume Apache Kafka topics via sidecar. +- **[Templates and runtimes](language-packs.md):** choose a language and + HTTP/CloudEvents template, or use custom language-pack repositories. -## Getting started with functions - -Follow [Get started with Functions](../getting-started/about-knative-functions.md) -to create, change, and test a Go function locally. This is the same Functions -track linked from Get Started. Cluster deployment is optional and links to the -shared learning-cluster setup. - -For an existing project, use the how-to guides in this section. +For the full CLI reference, see the [`func` documentation]({{ funcdocs() }}){target=_blank}. diff --git a/docs/versioned/functions/building-functions.md b/docs/versioned/functions/building-functions.md index 7bca01c18f9..f6caf1138a7 100644 --- a/docs/versioned/functions/building-functions.md +++ b/docs/versioned/functions/building-functions.md @@ -3,27 +3,29 @@ audience: developer components: - functions function: how-to +hide_prev: true +hide_next: true --- -# Building functions +# Build an image -Build a container image from an existing function project. The local procedure -builds only: it does not run, publish, or deploy the function. The optional -on-cluster workflow below builds **and deploys**, so choose it only when you want -that result. +Build an OCI container image from an existing function project without running, +pushing, or deploying it. If you want to build **and deploy** in one step +(locally or on a cluster with Tekton), see [Deploy a function](deploying-functions.md). -## Local builds +## Requirements -### Prerequisites +- An initialized function project containing `func.yaml` and source code. + [Create a project](running-functions.md#create-a-project) if needed. +- A running [Docker](https://docs.docker.com/get-started/get-docker/) engine + for containerized builders (`pack` or `s2i`). +- Run commands from inside the function project directory. -- You have an initialized function project containing `func.yaml` and its source. - [Create a project](creating-functions.md) if needed. -- Docker is running for the container-based buildpacks builder used here. -- Run these commands from that project directory, not its parent directory. + -### Procedure +## Build -Set an explicit local image name so the build does not need a registry prompt: +Pass an explicit local image name so the build does not prompt for a registry: === "func" @@ -39,100 +41,29 @@ Set an explicit local image name so the build does not need a registry prompt: --image localhost/my-function:latest ``` -`my-function` is an example image name; substitute yours consistently if desired. -`localhost` here is a local tag, not a registry server you must create. Wait for -building to complete, then check the image in Docker: +`localhost/my-function:latest` is a local tag — nothing is pushed to a registry +or deployed to a cluster. To prepare an image for a registry, pass +`--registry ` (for example `ghcr.io/alice` or `docker.io/alice`) or +set `FUNC_REGISTRY`. + +## Verify the image + +Confirm the image exists in Docker: ```bash docker image ls localhost/my-function:latest ``` -A row with the tag `latest` and an image ID identifies the built image. This does -not mean it was pushed or started. For publishing, see the -[deployment guide](deploying-functions.md#procedure), which explains registry -prefixes and full image destinations. [Try Functions](../getting-started/about-knative-functions.md#run-and-test) -shows how to run and test an image as a separate step. For other builders, image -naming options, and flags, see the [func build reference](https://github.com/knative/func/blob/main/docs/reference/func_build.md). - -## On-cluster Builds - -This alternative uses a remote pipeline and deploys the resulting function. -It avoids a local container build, but requires a configured cluster and registry -credentials. The source can come from Git **or** direct upload; Git is not required -for the direct-upload branch. - -### Prerequisites - -- Your kubeconfig selects a cluster with Knative Serving installed. -- Tekton Pipelines and the function build pipeline are configured according to the - [on-cluster build setup guide](https://github.com/knative/func/blob/main/docs/building-functions/on_cluster_build.md). -- The pipeline can push to your chosen registry, and the cluster can pull the image. - Complete the registry/credential setup in that guide rather than assuming local - Docker login alone configures every remote pipeline. -- You have an initialized local function project and are in its directory. - -### Procedure - -Choose the source branch below. Replace `REGISTRY-USER` with your Docker Hub -account namespace in the image name. For Git, separately replace `GIT-OWNER` and -`GIT-REPO` with the repository owner and name; the Git owner need not match your -registry account. The explicit image destination avoids carrying over a local-only -tag from an earlier build. +A row with tag `latest` and an image ID confirms the build succeeded. This does +not push or start the container. -#### Git-backed source + -The function project must be committed in a Git repository the pipeline can read. -For a private repository, your platform administrator must provision pipeline -access before you use this branch; the linked function-build setup guide does -not provide a private-Git authentication recipe. The [Tekton authentication guide](https://tekton.dev/docs/pipelines/auth/) -is background for that platform setup. If you cannot arrange repository access, -use direct upload instead. - -These commands assume the project is at the repository root. For a subdirectory, -set `build.source.dir` in your project's `func.yaml` to its relative path, following -the configuration example in the [on-cluster build guide](https://github.com/knative/func/blob/main/docs/building-functions/on_cluster_build.md). -For example, `dir: functions/my-function` selects that directory within the Git repository. - -=== "func" - - ```bash - func deploy --remote \ - --image docker.io/REGISTRY-USER/my-function:latest \ - --git-url https://github.com/GIT-OWNER/GIT-REPO - ``` - -=== "kn func" - - ```bash - kn func deploy --remote \ - --image docker.io/REGISTRY-USER/my-function:latest \ - --git-url https://github.com/GIT-OWNER/GIT-REPO - ``` - -#### Direct-upload source - -Use this branch to upload the current local project. No Git repository is required. -Passing an empty Git URL explicitly clears a previously configured Git source. -If you previously set `build.source.dir` for a Git subdirectory, remove that `dir` -entry from `build.source` too so the upload uses the current local project root: - -=== "func" - - ```bash - func deploy --remote \ - --image docker.io/REGISTRY-USER/my-function:latest \ - --git-url="" - ``` - -=== "kn func" - - ```bash - kn func deploy --remote \ - --image docker.io/REGISTRY-USER/my-function:latest \ - --git-url="" - ``` +## Other builders -Wait for the pipeline and deployment to finish. Verify the **deployed** function -using `func invoke --target remote` (or `kn func invoke --target remote`) and -check your function's expected response. A finished image build alone does not -prove deployment or invocation succeeded. +`func build` supports `--builder pack` (Cloud Native Buildpacks), `--builder s2i` +(Source-to-Image), and `--builder host` (host-native builds for supported +languages). For remote on-cluster builds with Tekton, see +[Deploy a function — Build and deploy remotely](deploying-functions.md#build-and-deploy-remotely). +For all flags and builder options, see the +[`func build` reference](https://github.com/knative/func/blob/main/docs/reference/func_build.md){target=_blank}. diff --git a/docs/versioned/functions/deploying-functions.md b/docs/versioned/functions/deploying-functions.md index 62b578d60db..587caa08dde 100644 --- a/docs/versioned/functions/deploying-functions.md +++ b/docs/versioned/functions/deploying-functions.md @@ -3,36 +3,135 @@ audience: developer components: - functions function: how-to +hide_prev: true +hide_next: true --- -# Deploying functions +# Deploy a function ---8<-- "deploy-func-intro.md" +Build, push, and deploy a function project to Kubernetes as a Knative Service +(or as a raw Kubernetes Deployment). For a guided first deployment, see +[Try Functions — Deploy to Knative](../getting-started/about-knative-functions.md#deploy-to-knative-optional). -## Prerequisites +## Requirements -- You have a Kubernetes cluster with Knative Serving installed, and your kubeconfig - selects the intended cluster and namespace. For a disposable environment, - [set up a learning cluster](../getting-started/quickstart-install.md) and check - its context before returning here. Local Functions development alone does not - create a cluster. +- An initialized function project containing `func.yaml` + ([create a project](running-functions.md#create-a-project) if needed). +- A Kubernetes cluster with Knative Serving installed, with your `kubectl` + context selecting the target cluster and namespace. +- Push access to a container registry that your cluster can pull from (use a + public repository or configure image pull secrets for private registries). +- For local builds: a running [Docker](https://docs.docker.com/get-started/get-docker/) + engine. For remote builds: Tekton Pipelines configured on the cluster. -- You have a Docker daemon running on your local machine for the container builder. - Quickstart uses an existing container engine; it does not install one. +## Deploy from your machine -- You have access to a container registry and are able to push images to this registry. Note that some image registries set newly pushed images to private by default. If you are deploying a function for the first time, you may need to ensure that your images are set to public. +Run `func deploy` from inside the project directory. Pass `--registry ` +where `` is the registry and your account namespace (for example +`ghcr.io/alice` or `docker.io/alice`), or pass `--image ` to +override a previous local-only `localhost/...` image tag: -## Procedure +=== "func" -For a first deployment, follow the [worked deployment tutorial](../getting-started/about-knative-functions.md#deploy-to-knative-optional), -which covers cluster setup, registry login, and the full image name. This is also -the next step if you are coming from the local Functions track. + ```bash + func deploy --registry + ``` -In the commands below, `` means the registry **and your account namespace**. -For example, `docker.io/alice` means Alice's Docker Hub namespace, and -`ghcr.io/alice` means her GitHub Container Registry namespace. Substitute your own -account; do not type the angle brackets. The CLI uses that prefix with the -function's project name to construct the image name. The worked tutorial instead -uses `--image` to set the complete destination explicitly. +=== "kn func" ---8<-- "proc-deploying-function.md" + ```bash + kn func deploy --registry + ``` + +`func` builds the image, pushes it to `/:latest`, and +creates or updates a Knative Service with the project name. + +- **Namespace:** By default, `func deploy` uses the previously deployed + namespace recorded in the project, or your current `kubectl` namespace on + first deploy. Pass `-n ` to target a specific namespace. +- **Private registries:** Set `FUNC_USERNAME` and `FUNC_PASSWORD` environment + variables for registry push credentials (avoid passing `--password` on the + command line), and ensure the target cluster namespace has pull credentials. +- **Raw Kubernetes deployer:** Add `--deployer raw` to deploy as a standard + Kubernetes Deployment and Service instead of a Knative Service. + +## Build and deploy remotely + +Use `--remote` to run the build and deployment on the cluster with Tekton +Pipelines instead of a local Docker engine. Configure Tekton and pipeline RBAC +first using the +[on-cluster build guide](https://github.com/knative/func/blob/main/docs/building-functions/on_cluster_build.md){target=_blank}. + +Choose one source method and pass an explicit `--image` destination (replace +`REGISTRY-USER` with your registry account namespace): + +=== "Git-backed source" + + Commit your project to a Git repository the cluster pipeline can read. For + private repositories, have your platform administrator provision pipeline + Git access first (see the + [Tekton authentication guide](https://tekton.dev/docs/pipelines/auth/){target=_blank}). + If the project is in a subdirectory, set `build.source.dir` in `func.yaml` + as shown in the on-cluster build guide. + + ```bash + func deploy --remote \ + --image docker.io/REGISTRY-USER/my-function:latest \ + --git-url https://github.com/GIT-OWNER/GIT-REPO + ``` + + (Some CLI versions accept `--source` / `--source-dir` instead of `--git-url`; + check `func deploy --help` for your installed CLI.) + +=== "Direct upload (no Git)" + + Upload the current local project directory directly. Passing `--git-url=""` + clears any previously configured Git URL (also remove `build.source.dir` + from `func.yaml` if previously set): + + ```bash + func deploy --remote \ + --image docker.io/REGISTRY-USER/my-function:latest \ + --git-url="" + ``` + +(`kn func deploy` accepts the same flags.) + +## Verify + +Invoke the deployed function with an explicit `--target remote` so you do not +accidentally hit a locally running instance: + +=== "func" + + ```bash + func invoke --target remote + ``` + +=== "kn func" + + ```bash + kn func invoke --target remote + ``` + +Confirm the response body matches your function's expected output. You can also +check status on the cluster: + +- **Knative deployer (default):** `kn service describe -n ` +- **Raw deployer (`--deployer raw`):** `kubectl get deployment/ service/ -n ` + +## Update and remove + +- **Update:** + - Local builds and direct-upload remote builds: edit your code and re-run + `func deploy` (or `func deploy --remote --git-url=""`). + - Git-backed remote builds: commit and push your changes to the configured + Git branch first, then re-run `func deploy --remote`. + - With the default Knative deployer, each deploy rolls out a new Revision; + with `--deployer raw`, it updates the Kubernetes Deployment. +- **Remove:** Run `func delete` from inside the project directory (works for + both Knative and raw deployers). You can also delete directly with + `kn service delete -n ` (Knative deployer) or + `kubectl delete deployment/ service/ -n ` (raw + deployer). Deleting the workload does not delete the pushed image from your + container registry. diff --git a/docs/versioned/functions/language-packs.md b/docs/versioned/functions/language-packs.md index 0322039ed87..431011aee5f 100644 --- a/docs/versioned/functions/language-packs.md +++ b/docs/versioned/functions/language-packs.md @@ -3,19 +3,84 @@ audience: developer components: - functions function: how-to +hide_prev: true +hide_next: true --- -# Language packs +# Templates and runtimes -Language packs can be used to extend Knative Functions to support additional runtimes, function signatures, operating systems, and installed tooling for functions. Language Packs are distributed through Git repositories or as a directory on a disc. +Knative Functions includes built-in language runtimes and templates, and lets +you pull custom templates from Git repositories via language packs. -For more information see the [language pack](https://github.com/knative/func/blob/main/docs/language-packs/language-pack-contract.md){target=_blank} documentation. +## Choose a runtime -## Using external Git repositories +Pass `-l ` to `func create`. Built-in runtimes: -When creating a new function, a Git repository can be specified as the source -for the template files. +| Runtime | `-l` value | +| --- | --- | +| Go | `go` | +| Node.js | `node` | +| TypeScript | `typescript` | +| Python | `python` | +| Quarkus (Java) | `quarkus` | +| Spring Boot (Java) | `springboot` | +| Rust | `rust` | -## Installing language packs locally +## Choose HTTP or CloudEvents -Language packs can be installed locally by using the [`func repository`](https://github.com/knative/func/blob/main/docs/reference/func_repository.md){target=_blank} command. +Pass `-t