diff --git a/config/redirects.yml b/config/redirects.yml index a9c66224e45..095e3629643 100644 --- a/config/redirects.yml +++ b/config/redirects.yml @@ -169,7 +169,7 @@ plugins: versioned/install/collecting-metrics/index.md: versioned/serving/observability/metrics/collecting-metrics.md versioned/install/eventing/eventing-installation-files.md: versioned/install/yaml-install/eventing/eventing-installation-files.md versioned/install/eventing/install-eventing-with-yaml.md: versioned/install/yaml-install/eventing/install-eventing-with-yaml.md - versioned/install/getting-started-knative-app/index.md: versioned/getting-started/README.md + versioned/install/getting-started-knative-app/index.md: versioned/README.md versioned/install/install-extensions.md: versioned/install/README.md versioned/install/installation-files.md: versioned/install/README.md versioned/install/prerequisites.md: versioned/install/README.md @@ -186,7 +186,7 @@ plugins: versioned/serving/creating-domain-mappings.md: versioned/serving/services/custom-domains.md versioned/serving/debugging-application-issues.md: versioned/serving/troubleshooting/debugging-application-issues.md versioned/serving/feature-flags.md: versioned/serving/configuration/feature-flags.md - versioned/serving/getting-started-knative-app.md: versioned/getting-started/README.md + versioned/serving/getting-started-knative-app.md: versioned/README.md versioned/serving/installing-cert-manager.md: versioned/install/installing-cert-manager.md versioned/serving/metrics.md: versioned/serving/observability/metrics/serving-metrics.md versioned/serving/samples/README.md: versioned/samples/serving.md @@ -227,3 +227,20 @@ plugins: versioned/eventing/brokers/create-mtbroker.md: versioned/eventing/brokers/create-broker.md versioned/eventing/brokers/broker-admin-config-options.md: versioned/eventing/configuration/broker-configuration.md versioned/eventing/event-mesh.md: versioned/eventing/concepts/event-mesh.md + versioned/getting-started/README.md: versioned/README.md + versioned/getting-started/tutorial.md: versioned/README.md + versioned/getting-started/first-autoscale.md: versioned/getting-started/first-service.md#watch-autoscaling + versioned/getting-started/first-traffic-split.md: versioned/getting-started/first-service.md#split-traffic + versioned/getting-started/install-func.md: versioned/getting-started/about-knative-functions.md#prepare + versioned/getting-started/create-a-function.md: versioned/getting-started/about-knative-functions.md#create-and-change + versioned/getting-started/build-run-deploy-func.md: versioned/getting-started/about-knative-functions.md#run-and-test + versioned/getting-started/first-broker.md: versioned/getting-started/getting-started-eventing.md#prepare + versioned/getting-started/first-source.md: versioned/getting-started/getting-started-eventing.md#connect-the-player + versioned/getting-started/first-trigger.md: versioned/getting-started/getting-started-eventing.md#filter-events-optional + 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/snippets/about-functions.md b/docs/snippets/about-functions.md index 620e20e9964..3ac67b05f77 100644 --- a/docs/snippets/about-functions.md +++ b/docs/snippets/about-functions.md @@ -6,6 +6,6 @@ Knative Functions provides a simple programming model for using functions on Kna Knative Functions enables you to easily create, build, and deploy [stateless](https://www.techtarget.com/whatis/definition/stateless-app){target=_blank}, [event-driven](https://en.wikipedia.org/wiki/Event-driven_programming){target=_blank} functions as Knative Services by using the `func` CLI. -When you build or run a function, an [Open Container Initiative (OCI) format](https://opencontainers.org/about/overview/){target=_blank} container image is generated automatically for you, and is stored in a container registry. Each time you update your code and then run or deploy it, the container image is also updated. +Functions can be packaged as [Open Container Initiative (OCI) images](https://opencontainers.org/about/overview/){target=_blank} without writing a Dockerfile. A local container build does not publish an image to a registry. Deployment builds and pushes an image so the cluster can pull it. Supported host builders can also run functions locally without a container. You can create functions and manage function workflows by using the `func` CLI, or by using the `kn func` plugin for the Knative CLI. diff --git a/docs/snippets/install-func-CLI.md b/docs/snippets/install-func-CLI.md index db5b386b987..ebd4598e9f9 100644 --- a/docs/snippets/install-func-CLI.md +++ b/docs/snippets/install-func-CLI.md @@ -72,20 +72,3 @@ ```bash func version ``` - -=== "Container image" - - Run `func` from a container image. For example: - - ```bash - docker run --rm -it ghcr.io/knative/func/func create -l node -t http myfunc - ``` - - Links to images are available here: - - - [Latest release](https://gcr.io/knative-releases/knative.dev/client/cmd/kn){target=_blank} - - !!! note - Running `func` from a container image does not place the binary on a permanent path. This procedure must be repeated each time you want to use `func`. - - diff --git a/docs/snippets/install-kn.md b/docs/snippets/install-kn.md index a481a78c3a1..969fb79e562 100644 --- a/docs/snippets/install-kn.md +++ b/docs/snippets/install-kn.md @@ -10,6 +10,9 @@ The Knative CLI (`kn`) provides a quick and easy interface for creating Knative The `kn` CLI also simplifies completion of otherwise complex procedures such as autoscaling and traffic splitting. +Install `kn` on your local machine so you can run it directly and use plugins +such as `quickstart`. + === "Using Homebrew" Do one of the following: @@ -73,18 +76,3 @@ The `kn` CLI also simplifies completion of otherwise complex procedures such as ```bash kn version ``` - -=== "Using a container image" - - Links to images are available here: - - - [Latest release](https://gcr.io/knative-releases/knative.dev/client/cmd/kn){target=_blank} - - You can run `kn` from a container image. For example: - - ```bash - docker run --rm -v "$HOME/.kube/config:/root/.kube/config" gcr.io/knative-releases/knative.dev/client/cmd/kn:latest service list - ``` - - !!! note - Running `kn` from a container image does not place the binary on a permanent path. This procedure must be repeated each time you want to use `kn`. diff --git a/docs/snippets/proc-deploying-function.md b/docs/snippets/proc-deploying-function.md index 74943a0b0e6..b91cf4ef548 100644 --- a/docs/snippets/proc-deploying-function.md +++ b/docs/snippets/proc-deploying-function.md @@ -56,21 +56,25 @@ The `deploy` command uses the function project name as the Knative Service name. **Note:** Using environment variables is more secure than the `--password` flag because command-line arguments are visible to all users on the system via `ps`. -You can verify that your function has been successfully deployed by using the `invoke` command and observing the output: +Verify the deployed function with an explicit `remote` target, even if a local +function is also running. The response should contain your function's expected +output; deployment readiness alone does not prove you called the remote instance: === "func" ```bash - func invoke + func invoke --target remote ``` === "kn func" ```bash - kn func invoke + kn func invoke --target remote ``` -!!! Success "Expected output" +The response format varies by template. For example: + +!!! Success "Example response" ```{ .bash .no-copy } Received response POST / HTTP/1.1 hello.default.127.0.0.1.sslip.io diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index b9bb6c53e73..0de39b7cc4b 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -16,6 +16,12 @@ --site-nav-bg: #14385d; --site-nav-text: #d4e3f4; --site-nav-focus: #9bd5ff; + --knative-functions-color: #7a357d; + --knative-functions-background: #faf5fb; + --knative-serving-color: #125cb3; + --knative-serving-background: #f2f7fd; + --knative-eventing-color: #287867; + --knative-eventing-background: #f1f8f6; } /* Deep-navy canvas for elastic overscroll; regular page content stays white. */ @@ -406,6 +412,154 @@ body:not(:has(#__search:checked)) .md-header .md-search__icon[for='__search'] { overflow-wrap: anywhere; } +/* The docs front door reuses the splash page's component palette. */ +.md-typeset .knative-docs-home { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 1rem; + margin-block: 1.5rem; +} + +.knative-docs-panel { + display: flex; + flex-direction: column; + min-width: 0; + padding-block: 1rem 0.25rem; + border-top: 1px solid #e4e7ec; +} + +.knative-docs-panel--try { + display: block; + grid-column: 1 / -1; + padding: 0 0 0.5rem; + border: 0; +} + +.md-typeset .knative-docs-home h2 { + margin: 0 0 0.6rem; + font-size: 1.05rem; + line-height: 1.4; +} + +.md-typeset .knative-docs-panel--try > h2 { + font-size: 1.25rem; +} + +.knative-docs-tracks { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 1rem; + margin-block: 1.15rem 0.85rem; +} + +.knative-docs-track { + position: relative; + display: flex; + flex-direction: column; + min-width: 0; + padding: 1.15rem; + border: 1px solid transparent; + border-radius: 0.6rem; + background: var(--component-background); +} + +.knative-docs-track--serving { + --component-color: var(--knative-serving-color); + --component-background: var(--knative-serving-background); +} + +.knative-docs-track--functions { + --component-color: var(--knative-functions-color); + --component-background: var(--knative-functions-background); +} + +.knative-docs-track--eventing { + --component-color: var(--knative-eventing-color); + --component-background: var(--knative-eventing-background); +} + +.md-typeset .knative-docs-track h3 { + margin: 0 0 0.55rem; + color: var(--component-color); + font-size: 1.05rem; +} + +.md-typeset .knative-docs-track .headerlink { + display: none; +} + +.md-typeset .knative-docs-track p { + margin: 0; + line-height: 1.6; +} + +.md-typeset .knative-docs-track__link { + color: var(--component-color); + font-weight: 600; +} + +/* A single descriptive link makes the whole track card clickable. */ +.knative-docs-track__link::after { + position: absolute; + inset: 0; + border-radius: 0.6rem; + content: ""; +} + +@media (hover: hover) { + .knative-docs-track:hover { + border-color: var(--component-color); + } +} + +.knative-docs-track:has(:focus-visible) { + outline: 2px solid var(--component-color); + outline-offset: 2px; +} + +.md-typeset .knative-docs-panel > :last-child, +.md-typeset .knative-docs-track > :last-child { + margin-bottom: 0; +} + +.md-typeset .knative-docs-panel > ul { + margin: 0; + padding-top: 0.35rem; + list-style: none; +} + +.md-typeset .knative-docs-panel > ul > li { + margin: 0; + padding-block: 0.25rem; +} + +.md-typeset .knative-docs-panel > ul > li > a { + display: inline-block; +} + +.md-typeset .knative-docs-reference { + margin-block: 1.5rem; + padding-top: 1rem; + border-top: 1px solid #e4e7ec; +} + +.md-typeset .knative-docs-reference ul { + margin: 0; + list-style: none; +} + +.md-typeset .knative-docs-reference li { + margin: 0; + padding-block: 0.25rem; +} + +@media screen and (max-width: 47.5em) { + .md-typeset .knative-docs-home, + .knative-docs-tracks { + grid-template-columns: minmax(0, 1fr); + } +} + /* Ink/link colors differ by over 3:1; reserve persistent underlines for utilities. */ .md-typeset blockquote { color: var(--md-default-fg-color); diff --git a/docs/versioned/.nav.yml b/docs/versioned/.nav.yml index b1a9efc1e61..3c98e91b6d0 100644 --- a/docs/versioned/.nav.yml +++ b/docs/versioned/.nav.yml @@ -1,58 +1,38 @@ nav: -############################################################################### - # Concepts -############################################################################### - - Overview: README.md ############################################################################### # Getting started ############################################################################### - - Tutorials: - - Explore Knative: getting-started/tutorial.md - - Quickstart: - - Tutorial introduction: getting-started/README.md - - Install Knative using quickstart: getting-started/quickstart-install.md - - Knative Functions: - - Getting Started: getting-started/about-knative-functions.md - - Installing Knative Functions: getting-started/install-func.md - - Creating a function: getting-started/create-a-function.md - - Building, running, or deploying a function: getting-started/build-run-deploy-func.md - - Knative Serving: - - Deploying a Knative Service: getting-started/first-service.md - - Autoscaling: getting-started/first-autoscale.md - - Traffic splitting: getting-started/first-traffic-split.md - - Knative Eventing: - - Getting Started: getting-started/getting-started-eventing.md - - Sources, Brokers, and Triggers: getting-started/first-broker.md - - Using a Knative Service as a source: getting-started/first-source.md - - Using Triggers and sinks: getting-started/first-trigger.md - - What's Next?: getting-started/next-steps.md - - Clean Up: getting-started/clean-up.md - - "E2E tutorial: Knative Bookstore": - - Overview: bookstore/page-0/welcome-knative-bookstore-tutorial.md - - Disclaimer: bookstore/disclaimer/README.md - - Environment Setup: bookstore/page-0.5/environment-setup.md - - 1 - Send Comments to Broker: bookstore/page-1/send-review-comment-to-broker.md - - 2 - Create Sentiment Service: bookstore/page-2/sentiment-analysis-service-for-bookstore-reviews.md - - 3 - Create Bad Word Service: bookstore/page-3/create-bad-word-filter-service.md - - 4 - Create Sequence: bookstore/page-4/create-sequence-to-streamline-ML-workflows.md - - 5 - Create DB service: bookstore/page-5/deploy-database-service.md - - 6 - Advanced event filtering: bookstore/page-6/advanced-event-filtering.md - - 7 - Connect Slack via Camel-K: bookstore/page-7/slack-sink-learning-knative-eventing-and-apache-camel-K-integration.md - - 8 - Extra Challenges: bookstore/extra-challenge/README.md + - Get Started: + - README.md + - Component tutorials: + - Set up a cluster: getting-started/quickstart-install.md + - Try Serving: getting-started/first-service.md + - Try Functions: getting-started/about-knative-functions.md + - Try Eventing: getting-started/getting-started-eventing.md + - Next steps and cleanup: getting-started/next-steps.md + - Bookstore tutorial: + - Overview: bookstore/page-0/welcome-knative-bookstore-tutorial.md + - Disclaimer: bookstore/disclaimer/disclaimer.md + - Set up your environment: bookstore/page-0.5/environment-setup.md + - 1 - Send review comments: bookstore/page-1/send-review-comment-to-broker.md + - 2 - Analyze sentiment: bookstore/page-2/sentiment-analysis-service-for-bookstore-reviews.md + - 3 - Filter bad words: bookstore/page-3/create-bad-word-filter-service.md + - 4 - Connect a Sequence: bookstore/page-4/create-sequence-to-streamline-ML-workflows.md + - 5 - Deploy the database: bookstore/page-5/deploy-database-service.md + - 6 - Filter events: bookstore/page-6/advanced-event-filtering.md + - 7 - Connect Slack: bookstore/page-7/slack-sink-learning-knative-eventing-and-apache-camel-K-integration.md + - 8 - Extra challenges: bookstore/extra-challenge/extra-challenges.md + - Technical overview: overview.md ############################################################################### # Functions ############################################################################### - Functions: - - Knative Functions overview: functions/README.md - - Installing Knative Functions: functions/install-func.md - - Creating functions: functions/creating-functions.md - - Building functions: functions/building-functions.md - - Running functions: functions/running-functions.md - - Subscribing functions: functions/subscribing-functions.md - - Deploying functions: functions/deploying-functions.md - - Invoking functions: functions/invoking-functions.md - - Kafka functions: functions/kafka-functions.md - - Language packs: functions/language-packs.md + - Overview: functions/README.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 ############################################################################### @@ -100,19 +80,14 @@ nav: - About load balancing: serving/load-balancing/README.md - Configuring target burst capacity: serving/load-balancing/target-burst-capacity.md - Configuring Activator capacity: serving/load-balancing/activator-capacity.md - # Serving - Application Security - - Application security: - - Secure Pod Defaults: serving/app-security/secure-pod-defaults.md + - Secure Pod Defaults: serving/app-security/secure-pod-defaults.md # Serving - observability - Observability: - Collecting metrics: serving/observability/metrics/collecting-metrics.md - Metrics Reference: serving/observability/metrics/serving-metrics.md - # Serving - troubleshooting - - Troubleshooting: - - Debugging application issues: serving/troubleshooting/debugging-application-issues.md - # Serving reference docs - - Reference: - - Serving API: serving/reference/serving-api.md + - Troubleshooting: serving/troubleshooting/debugging-application-issues.md + - Serving API: serving/reference/serving-api.md + - Code samples: samples/serving.md ############################################################################### # Eventing ############################################################################### @@ -214,22 +189,18 @@ nav: - Collecting metrics: eventing/observability/metrics/collecting-metrics.md - Metrics Reference: eventing/observability/metrics/eventing-metrics.md - FAQ: eventing/faq/README.md - # Eventing reference docs - - Reference: - - Eventing API: eventing/reference/eventing-api.md -############################################################################### - # CLI + - Eventing API: eventing/reference/eventing-api.md + - Code samples: samples/eventing.md ############################################################################### - - CLI tools: - - CLI tools: client/README.md - - Installing the Knative CLI: client/install-kn.md - - Customizing kn: client/configure-kn.md - - kn plugins: client/kn-plugins.md + # Install and Manage ############################################################################### - # Administration -############################################################################### - - Administration: + - Install and Manage: - Overview: admin/admin-overview.md + - CLI tools: + - CLI tools: client/README.md + - Installing the Knative CLI: client/install-kn.md + - Customizing kn: client/configure-kn.md + - kn plugins: client/kn-plugins.md - Installing Knative: - Overview: install/README.md # YAML Installation @@ -327,11 +298,4 @@ nav: - Uninstalling Knative: install/uninstall.md # Troubleshooting - Troubleshooting Knative: install/troubleshooting.md -############################################################################### - # Code samples -############################################################################### - - Code samples: - - Code sample overview: samples/README.md - - Serving code samples: samples/serving.md - - Eventing code samples: samples/eventing.md diff --git a/docs/versioned/README.md b/docs/versioned/README.md index ee2487b9182..c0ccfe48a1e 100644 --- a/docs/versioned/README.md +++ b/docs/versioned/README.md @@ -1,269 +1,78 @@ --- +title: Get started with Knative audience: developer components: - eventing - functions - serving -function: explanation +hide_next: true +hide: + - toc --- -# Knative Technical Overview + -This comprehensive overview explains what Knative is, what problems it solves, and how its components work together. Whether you're evaluating Knative for your use case or need background information to understand the rest of the documentation, this section provides the conceptual foundation you need. +# Get started with Knative -## What is Knative? +Knative extends Kubernetes to build, deploy, and manage serverless workloads. +Its three components — **Serving**, **Functions**, and **Eventing** — can be +used independently or together. -Knative is a Kubernetes-based platform that provides a complete set of middleware components for building, deploying, and managing modern [serverless](https://en.wikipedia.org/wiki/Serverless_computing){target=_blank} workloads. Knative extends Kubernetes to provide higher-level abstractions that simplify the development and operation of cloud-native applications. + -### Problems Knative Solves +
-Knative addresses several key challenges in modern application development and deployment: +
-**Application Deployment Complexity**: Traditional Kubernetes requires deep knowledge of pods, services, deployments, and ingress resources. These constructs provide a lot of flexibility and complexity that most applications don't need. Knative provides simpler abstractions that handle these details automatically. +### [Try Serving →](getting-started/first-service.md){ .knative-docs-track__link } { #try-serving } -**Serverless Operations**: Manual scaling, cold starts, and traffic routing are complex to implement. Knative provides automatic scaling from zero to thousands of instances, intelligent traffic routing, and efficient resource utilization. +Deploy a container, observe autoscaling, and split traffic. Recommended first. -**Event-Driven Architecture**: Building reliable event-driven systems requires complex infrastructure for event ingestion, routing, and delivery. Building event routing and delivery into your application limits your choice of event delivery and architecture; Knative provides standardized event processing capabilities across multiple event implementations using CloudEvents for delivery and Kubernetes for configuration. +
-**Developer Experience**: Moving from code to running applications involves multiple steps and tools. Knative Functions provide a streamlined and standardized developer experience for building and deploying stateless functions as standard containers. Build and test locally without Kubernetes, and avoid managing build details like Dockerfiles and Kubernetes resources until you need them. +
-**Platform Lock-in**: Cloud-specific serverless solutions create vendor lock-in. Knative runs on any Kubernetes cluster, providing portability across cloud providers and on-premises environments. +### [Try Functions →](getting-started/about-knative-functions.md){ .knative-docs-track__link } { #try-functions } -## Background Knowledge +Create, change, and test a Go function locally. -While you didn't need any specific programming experience to get started with Knative, you'll pick up the following concepts along the way. Knative will manage a lot of these in the background, so you can dive in deep when you're ready to learn. +
-- **Basic Kubernetes knowledge**: Understanding of pods, services, and deployments -- **Container concepts**: How to build and manage container images -- **HTTP/REST APIs**: Understanding of web service fundamentals -- **Basic YAML**: Ability to read and write Kubernetes resource definitions +
-For event-driven features, familiarity with: -- **Event-driven patterns**: Basic understanding of producers, consumers, and message routing -- **CloudEvents specification**: Helpful but not required (Knative handles the details) +### [Try Eventing →](getting-started/getting-started-eventing.md){ .knative-docs-track__link } { #try-eventing } -## Architecture Overview +Send an event through a Broker and observe delivery. -Knative consists of three main components that work together to provide a complete serverless platform: +
-[![Knative High-Level Architecture: Functions, Serving, and Eventing. Functions creates containers and defines event triggers, Serving runs containers, and Eventing routes events based on triggers.](../images/home-images/knative_flowchart_graphic.svg){draggable=false}](../images/home-images/knative_flowchart_graphic.svg){.diagram-link} +
-**Knative Serving**: An HTTP-triggered autoscaling container runtime that manages the complete lifecycle of stateless HTTP services, including deployment, routing, and automatic scaling. +## Why Knative? -**Knative Eventing**: A CloudEvents-over-HTTP asynchronous routing layer that provides infrastructure for consuming and producing events, enabling loose coupling between event producers and consumers. +- **Simpler application deployment:** Define a Knative Service instead of wiring + Deployments, Services, Ingress, and autoscalers by hand. +- **Scale to zero and back:** Automatically scale pods from zero to match demand + and split traffic across immutable Revisions. +- **Loosely coupled events:** Route CloudEvents over HTTP between producers and + consumers without hard-coding endpoints into application code. +- **Code-to-container workflow:** Build, run, and test stateless functions + locally without writing Dockerfiles or Kubernetes manifests first. +- **Portable across Kubernetes:** Run on any Kubernetes cluster — cloud or + on-premises — without vendor lock-in. -**Knative Functions**: A developer-focused function framework that leverages Serving and Eventing components to provide a simplified experience for building and deploying stateless functions. +## When to use Knative -These components can be used independently or together, allowing you to adopt Knative incrementally based on your needs. +Knative is a strong fit for stateless HTTP APIs, event-driven pipelines, +microservices, AI/ML inference (directly or with +[KServe](https://kserve.github.io)), and on-demand development +environments. Consider alternatives if your workloads require sub-100ms cold +starts, persistent in-process state, or long-running stateful processes. -## Knative Serving +
---8<-- "about-serving.md" +- [Technical overview](overview.md) — Serving, Eventing, and Functions internals and Kubernetes ecosystem integration. +- [Install and Manage](admin/admin-overview.md) — install and operate Knative on your own cluster. +- [Next steps and cleanup](getting-started/next-steps.md) — continue after a tutorial or clean up. -### Key Serving Features - -**Automatic Scaling**: Services automatically scale from zero to handle incoming traffic and scale back down when idle, optimizing resource usage and costs. - -**Traffic Management**: Built-in support for blue-green deployments, canary releases, and traffic splitting between different revisions of your application. - -**Networking**: Automatic ingress configuration with support for custom domains, TLS termination, and integration with service mesh technologies. - -**Kubernetes Native**: Knative builds on the Kubernetes Pod abstraction, making it easy to access functionality like service accounts, accelerator access, and container sandboxing. - -**Configuration Management**: Clean separation between application code and configuration, following twelve-factor app principles. - -### Request Flow in Serving - -![Knative Serving data flow: requests arrive at an HTTP router, then travel to either the activator or a pod with a queue-proxy and the user application. The Knative autoscaler collects metrics from the activator and the queue-proxy to determine how many pods to run.](./serving/images/request-flow.png){draggable=false} - -When a request is made to a Knative Service: - -1. **Ingress Layer**: The request enters through the configured networking layer (Kourier, Istio, or Contour) -2. **Routing Decision**: Based on current traffic patterns and scaling state, requests are routed either to the Activator or directly to application pods -3. **Scaling**: If no pods are running (scale-to-zero), the Activator queues the request and signals the Autoscaler to create pods -4. **Queue-Proxy**: All requests pass through the Queue-Proxy sidecar, which enforces concurrency limits and collects metrics -5. **Application**: The request reaches your application container - -For detailed information, see the [request flow documentation](serving/request-flow.md). - -### GPU Resources and LLM Inference - -Knative Serving can leverage Kubernetes pod capabilities to access specialized hardware resources like GPUs, making it an excellent platform for AI/ML inference workloads: - -**GPU Resource Access**: Since Knative Services are implemented as Kubernetes pods, you can request GPU resources using standard Kubernetes resource specifications. This enables running inference models that require GPU acceleration while benefiting from Knative's automatic scaling and traffic management. - -**LLM Inference Support**: Knative Serving provides an ideal foundation for Large Language Model (LLM) inference services, offering: - -- **Automatic scaling** from zero to multiple GPU-enabled pods based on request demand -- **Traffic splitting** for A/B testing different model versions or configurations -- **Resource efficiency** by scaling down expensive GPU resources when not in use -- **Standard HTTP interfaces** for model serving and inference endpoints - -**KServe Integration**: For production LLM deployments, consider using [KServe](https://kserve.github.io), a Kubernetes-native model serving platform built on Knative Serving. KServe provides: - -- Standardized inference protocols and multi-framework support -- Advanced features like model ensembling, explainability, and drift detection -- Optimized serving runtimes for popular ML frameworks (TensorFlow, PyTorch, ONNX, etc.) -- Built-in support for autoscaling GPU workloads and batching requests - -Whether using Knative Serving directly for custom inference services or through KServe for standardized model serving, you get the benefits of Kubernetes-native resource management combined with serverless operational characteristics. - -## Knative Eventing - ---8<-- "about-eventing.md" - -### Key Eventing Concepts - -**Event Sources**: Components that generate events from external systems (databases, message queues, cloud services, etc.) and send them into the Knative event mesh. - -**Brokers**: Event routers that receive events from sources and forward them to interested consumers based on CloudEvent attributes. - -**Triggers**: Configuration objects that define which events should be delivered to which consumers, using filtering based on event metadata. - -**Sinks**: Event consumers that receive and process events. These can be Knative Services, Kubernetes Services, or external endpoints. - -**Channels**: Lower-level primitives for point-to-point event delivery between producers and consumers. - -### Event Flow in Eventing - -![Two event sources named 1 and 2 deliver events to a broker. One trigger attached to the broker delivers type 1 events to one sink (endpoint), and another trigger selects type 2 events to deliver to a different sink.](https://user-images.githubusercontent.com/16281246/116248768-1fe56080-a73a-11eb-9a85-8bdccb82d16c.png){draggable=false} - -A typical event flow involves: - -1. **Event Generation**: An event source detects a change or condition and creates a CloudEvent -2. **Event Ingestion**: The event is sent to a Broker via HTTP POST -3. **Event Routing**: The Broker evaluates Triggers to determine which consumers should receive the event -4. **Event Delivery**: The event is delivered to matching consumers as HTTP requests -5. **Event Processing**: Consumers process the event and optionally produce response events - -### Eventing Use Cases - -- **Data Pipeline Processing**: Transform and route data through multiple processing stages -- **Integration Patterns**: Connect disparate systems using event-driven communication -- **Workflow Orchestration**: Coordinate complex business processes across multiple services -- **Real-time Analytics**: Process streaming data for monitoring and alerting - -## Knative Functions - ---8<-- "about-functions.md" - -### Functions Development Model - -Knative Functions provide a simplified programming model that abstracts away infrastructure concerns: - -**Function Signature**: Functions follow a simple signature pattern leveraging standard libraries (such as HTTP and CloudEvents) to prevent lock-in. - -**Built-in Templates**: Language-specific templates provide starting points for common function patterns and integrate with popular frameworks. - -**Local Development**: Functions can be built, run, and tested locally before deployment to Kubernetes. - -**Automatic Containerization**: The `func` CLI automatically builds container images from your function code without requiring Dockerfile expertise. - -**Easy Deployment**: Function containers can be run anywhere you can run an HTTP application. `func` can also deploy your container to Knative Serving, where you can manage it with the `kn` CLI or standard Kubernetes YAML. - -### Supported Languages and Runtimes - -Functions support multiple programming languages through language packs: - -- **Node.js**: Using popular frameworks like Express -- **Python**: With Flask and FastAPI support -- **Go**: Native Go HTTP handlers -- **Java**: Using Spring Boot and Quarkus -- **TypeScript**: Full TypeScript support with Node.js - -You can also build your own language packs to customize the output container to your own specifications. - -### Function Deployment and Lifecycle - - -``` mermaid -flowchart TD - init>"`func init - to create a function`"] - git@{ shape: lin-cyl, label: "fa:fa-git-alt local repo" } - laptop@{ shape: win-pane, label: "Local Development fa:fa-docker" } - oci@{ shape: procs, label: "Container Registry" } - cluster@{ label: "fa:fa-dharmachakra Knative Serving" } - -init --> git -git -- develop and test locally--> laptop -laptop --> git -git -- "`func push -push container to registry`" --> oci -.-> cluster -git -- deploy container and triggers --> cluster -``` - -1. **Development**: Write your function using language-specific templates -2. **Building**: The `func` CLI creates an optimized container image -3. **Deployment**: Functions are deployed as Knative Services with automatic scaling -4. **Invocation**: Functions can be triggered by HTTP requests or CloudEvents -5. **Management**: Update, delete, and monitor functions using familiar Kubernetes tools - -## System Integration and Interoperability - -### How Components Work Together - -While each Knative component can be used independently, they're designed to work seamlessly together: - -**Functions + Serving**: Functions are deployed as Knative Services, inheriting all serving capabilities like autoscaling and traffic management. - -**Functions + Eventing**: Functions can be triggered by CloudEvents, enabling event-driven function execution and microservice orchestration. - -**Serving + Eventing**: Services can act as event sources or sinks, participating in complex event-driven workflows. - -### Integration with Kubernetes Ecosystem - -Knative integrates with standard Kubernetes resources and third-party tools: - -**Kubernetes-native resources**: Serving and Eventing are implemented as Kubernetes custom resources, meaning that you can use the same policy and IAM tools you use for Kubernetes. - -**Builds on Kubernetes**: Serving creates Pods (so you can use GPUs, service accounts, and other Kubernetes features), and Eventing can easily deliver events to Kubernetes services as well as Serving functions. - -**Networking**: Integrates with cert-manager for certificate management, and with Gateway API for ingress. Integrates with Istio, Envoy, and other service mesh technologies for advanced traffic management and security. - -**Monitoring**: Using [OpenTelemetry](https://opentelemetry.io/), integrates with Prometheus, Grafana, Jaeger, and many other observability tools for metrics and monitoring. - -**CI/CD**: Compatible with GitOps workflows, Tekton Pipelines, and other continuous deployment tools. - -## Use Cases and When to Choose Knative - -### Ideal Use Cases - -**API Development**: Rapidly develop and deploy REST APIs with built-in scaling and traffic management. - -**Event-Driven Applications**: Process events from various sources with reliable delivery and error handling. - -**Inference Services**: Use Knative directly, or integrate with [KServe](https://kserve.github.io) to easily manage AI inference models. - -**Microservices Architecture**: Build and deploy loosely coupled services with automatic scaling and service discovery. - -**Integration Workflows**: Connect legacy systems and SaaS applications using event-driven patterns. - -**Edge Computing**: Deploy lightweight functions and services closer to users or data sources. - -**Development Environments**: Automatically scale down development environments when not in use; start them up again when requests arrive. - -### Evaluation Criteria - -Choose Knative when you need: - -- **Kubernetes-native serverless** with no vendor lock-in -- **Automatic scaling** including scale-to-zero capabilities -- **Event-driven architecture** with standardized event processing -- **Developer productivity** improvements for cloud-native applications -- **Cost optimization** through efficient resource utilization -- **Flexibility** to use components independently based on your needs - -Consider alternatives when: - -- You need extremely low cold-start latency (sub-100ms) -- Your workloads require persistent state or long-running processes - -## Next Steps - -- **Installation**: Get started with [Knative installation](install/README.md) -- **Quick Start**: Try the [Knative Quickstart](getting-started/README.md) for hands-on experience -- **Serving Guide**: Learn more about [Knative Serving](serving/README.md) -- **Eventing Guide**: Explore [Knative Eventing](eventing/README.md) capabilities -- **Functions Guide**: Build your first [Knative Function](functions/README.md) -- **Examples**: Browse [sample applications](samples/README.md) and use cases +
diff --git a/docs/versioned/bookstore/disclaimer/README.md b/docs/versioned/bookstore/disclaimer/disclaimer.md similarity index 100% rename from docs/versioned/bookstore/disclaimer/README.md rename to docs/versioned/bookstore/disclaimer/disclaimer.md diff --git a/docs/versioned/bookstore/extra-challenge/README.md b/docs/versioned/bookstore/extra-challenge/extra-challenges.md similarity index 99% rename from docs/versioned/bookstore/extra-challenge/README.md rename to docs/versioned/bookstore/extra-challenge/extra-challenges.md index 606fe155f6c..1fda6d0d12c 100644 --- a/docs/versioned/bookstore/extra-challenge/README.md +++ b/docs/versioned/bookstore/extra-challenge/extra-challenges.md @@ -5,6 +5,7 @@ components: - serving - functions function: tutorial +hide_next: true --- # **Extra Challenges** diff --git a/docs/versioned/bookstore/page-0.5/environment-setup.md b/docs/versioned/bookstore/page-0.5/environment-setup.md index e7cd8f4b6f1..80355c060bb 100644 --- a/docs/versioned/bookstore/page-0.5/environment-setup.md +++ b/docs/versioned/bookstore/page-0.5/environment-setup.md @@ -8,262 +8,160 @@ function: tutorial # Environment Setup -![Image](images/image20.png) +Deploy the Bookstore frontend and Book Review backend using the provided images. +This is a larger application than the introductory tracks. Read the +[Bookstore introduction](../page-0/welcome-knative-bookstore-tutorial.md) and +[disclaimer](../disclaimer/disclaimer.md) before beginning. -In this page, we will be discussing how to set up your environment, and make sure to run up the UI front end and the Book Review Service’s node server. +## What does the final deliverable for this section look like? -## **What does the final deliverable for this section look like?** +- Your disposable Kubernetes cluster has Knative Serving and Eventing ready. +- The frontend and backend run in the same namespace. +- You can open the application from your browser using local port-forwarding. -- You have a running Kubernetes (k8s) cluster on your local machine, with Knative installed. -- You have your front end application deployed as Kubernetes deployment -- You have your Node.js application deployed as Kubernetes deployment +Reuse your Quickstart learning cluster if you kept it. You do not need another +cluster, a cloud account, or a LoadBalancer helper for the access method on this page. -We will be fulfilling each requirement with the order above. +## Clone the Repository -## **Clone the Repository** -![Next Step Image](images/image22.png) +From a directory where you keep projects, clone the repository and enter the +sample's working directory: -```sh +```bash git clone https://github.com/knative/docs.git +cd docs/code-samples/eventing/bookstore-sample-app/start ``` -???+ bug "Troubleshooting" - Having issue with cloning your repo? Check [here](https://docs.github.com/en/repositories/creating-and-managing-repositories/troubleshooting-cloning-errors){:target="_blank"} for help. -!!! warning +If you already cloned the repository, use its existing copy and change to that +same `code-samples/eventing/bookstore-sample-app/start` directory instead. - **IMPORTANT**: Please take some time to read the [Disclaimer](../disclaimer/README.md){:target="_blank"} before moving to the next page. +## File Structure +The sample has two sibling directories: -## **File Structure** +- `start`: the working directory for these lessons, containing the frontend, + backend, and starter configuration. +- `solution`: completed examples to consult when you are stuck. -![Image](images/image21.png) +When later lessons say to return to `start`, they mean this directory **inside +the cloned repository**, not a filesystem directory named `/start`. Run the +commands below from the `start` directory. -The code for the sample app is in `docs/code-samples/eventing/bookstore-sample-app` +## Shortcut -Under `bookstore-sample-app` folder, there are 2 folders: +These instructions use the manual steps and local port-forwarding below. +The optional `setup.sh` script instead reinstalls Knative components and waits +for real LoadBalancer addresses. Do not use it for this port-forwarding route +or run it over an existing Quickstart installation. -* **/solution**: this folder contains all the yaml files, and the code you needed. Check it when you got stuck. +## Instructions -* **/start**: this folder contains the necessary files for you to get started. Save there all the configuration files yourself following the tutorial! +### Task 1: Set Up a Running Kubernetes Cluster with Knative Installed -![Image](images/image16.png) +If needed, [create a learning cluster](../../getting-started/quickstart-install.md), +then return here. Otherwise keep your existing cluster. Follow the shared guide's +[context and namespace checks](../../getting-started/quickstart-install.md#create-and-verify) +so commands use the disposable cluster and its `default` namespace. -!!! tip - Kuack suggests you to start from **/start**, write all the configuration files as you go over the tutorial, and check solutions when you got stuck. +Check the Knative components: -![Image](images/image1.png) - -Always `cd` back to the root directory, which is `/start`, before running any commands. - -All the commands in the tutorial are written **assuming you are in the `/start` directory**. - - -## **Shortcut** - -![Image](images/image10.png) - -Running `docs/code-samples/eventing/bookstore-sample-app/start/setup.sh` will automatically complete all tasks in this section. - -!!! warning - - However, if you are not familiar with the process, we recommend reviewing the steps below. - -## **Instructions** - -### **Task 1: Set Up a Running Kubernetes Cluster with Knative Installed** - -![Image](images/image13.png) - -We recommend using [KinD (Kubernetes in Docker)](https://kind.sigs.k8s.io/docs/user/quick-start/) to run a Kubernetes cluster locally. - -In order to access Kubernetes services KinD provides a standalone binary in your host and connects to your cluster and provisions new Load Balancer containers for your Services. It requires privileges to open ports on the system and to connect to the container runtime. - -See instructions here: https://kind.sigs.k8s.io/docs/user/loadbalancer/ - -!!! tip - - We recommend you using `kn quickstart` plugin to install Knative. - -Please follow the instructions [here](https://knative.dev/docs/install/){:target="_blank"} to spin up your cluster with Knative installed! - -???+ success "Verify" - - You should see the pods in the `knative-eventing` and `knative-serving` namespaces running before proceeding. - - ``` - NAMESPACE NAME READY STATUS RESTARTS AGE - knative-eventing eventing-controller-645c4bcd55-fln6l 1/1 Running 0 17m - knative-eventing eventing-webhook-7fd9cb958f-ft9vj 1/1 Running 0 17m - knative-eventing imc-controller-6b9fbb6487-kwvbz 1/1 Running 0 17m - knative-eventing imc-dispatcher-6c4b5856d-hh7wq 1/1 Running 0 17m - knative-eventing job-sink-5cc89b5d95-fhlt5 1/1 Running 0 17m - knative-eventing mt-broker-controller-568d6b9c59-qk8dj 1/1 Running 0 17m - knative-eventing mt-broker-filter-db66554c4-sxxzr 1/1 Running 0 17m - knative-eventing mt-broker-ingress-774547844d-bbbdw 1/1 Running 0 17m - knative-serving activator-7bcd47489b-ljmt6 1/1 Running 0 17m - knative-serving autoscaler-65cf6767c4-v7rfn 1/1 Running 0 17m - knative-serving controller-964dcf97b-9qwsv 1/1 Running 0 17m - knative-serving net-kourier-controller-854b568d4f-6xhl5 1/1 Running 0 17m - knative-serving webhook-658b566b8-sxbdz 1/1 Running 0 17m - kourier-system 3scale-kourier-gateway-54fb555bd7-v2l8q 1/1 Running 0 17m - kube-system coredns-66bc5c9577-fhnxr 1/1 Running 0 18m - kube-system coredns-66bc5c9577-x299f 1/1 Running 0 18m - kube-system etcd-kind-control-plane 1/1 Running 0 18m - kube-system kindnet-gpq75 1/1 Running 0 18m - kube-system kube-apiserver-kind-control-plane 1/1 Running 0 18m - kube-system kube-controller-manager-kind-control-plane 1/1 Running 0 18m - kube-system kube-proxy-v2kdx 1/1 Running 0 18m - kube-system kube-scheduler-kind-control-plane 1/1 Running 0 18m - local-path-storage local-path-provisioner-7b8c8ddbd6-m5n2m 1/1 Running 0 18m - ``` - -### **Task 2: Running the Bookstore Web App** - -![Image](images/image12.png) +```bash +kubectl get pods -n knative-serving +kubectl get pods -n knative-eventing +``` -The Next.js frontend app is located in the `docs/code-samples/eventing/bookstore-sample-app/start/frontend` folder. +Check that the Serving and Eventing pods are ready before deploying the Bookstore +application. If these components are missing or not ready, resolve the installation +first. -#### **Deploy the Frontend App** +We will use `kubectl port-forward` to open a temporary connection from your +computer to a Service. It works with this tutorial's existing cluster and avoids +adapting another provider's sample cluster or relying on container IP addresses. +The forwarding command must stay running in its terminal while you use the app. -You can either [build the image locally](https://docs.docker.com/get-started/02_our_app/){:target="_blank"} or use our pre-built image. If you are using the pre-built image, you can proceed to the next step. +### Task 2: Running the Bookstore Web App -When ready, run the following command to deploy the frontend app: +The frontend and backend use ordinary Kubernetes Deployments and Services, +not the Knative Service resource used in the Serving track. -```shell -kubectl apply -f frontend/config/100-front-end-deployment.yaml -``` +#### Deploy the Frontend App -This will create the Deployment and expose it with a Service of type LoadBalancer to receive external traffic: +Use the pre-built image referenced by the starter configuration: -``` -deployment.apps/bookstore-frontend created -service/bookstore-frontend-svc created +```bash +kubectl apply -f frontend/config/ +kubectl rollout status deployment/bookstore-frontend ``` -???+ success "Verify" - Run the following command to check if the pod is running: - - ```shell - kubectl get pods - ``` - - You will see that your front end pod is running. - - ``` - NAME READY STATUS RESTARTS AGE - bookstore-frontend-7b879ffb78-9bln6 1/1 Running 0 4m37s - ``` +The rollout command waits for the frontend to become available. If it reports +an error, resolve it before opening the browser. #### Access the frontend workload -Follow the respective `minikube` or `kind` instructions to access Kubernetes Services locally from your machine. +In a dedicated terminal, using the same cluster context and namespace, run: -Check the running Kubernetes Services: - -```shell -kubectl get services +```bash +kubectl port-forward service/bookstore-frontend-svc 18080:80 ``` -And you will see the following console output: -``` -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -bookstore-frontend-svc LoadBalancer 10.99.187.173 172.18.0.6 80:31600/TCP 27m -kubernetes ClusterIP 10.96.0.1 443/TCP 39m -``` - -!!! note - If the `EXTERNAL-IP` for your frontend service is ``, then there you'll need to check that - your `minikube tunnel` or KinD `cloud-provider-kind` is working properly. - -???+ success "Verify" - Access the UI page using the `bookstore-frontend-svc` `EXTERNAL-IP` address. The UI page should appear! +Leave it running and open **http://127.0.0.1:18080** in your browser. `18080` is +on your computer; `80` is the Service's port inside the cluster. - ![Image](images/image19.png) +The UI should appear. Its backend connection may be unavailable until you complete +Task 3. If port `18080` is already in use, choose another free local port and use +that port in the browser URL; do not stop an unrelated application. -### **Task 3: Running the Book Review Service** +The manifest uses a LoadBalancer Service, but its `EXTERNAL-IP` may remain +`` on a local cluster. That is not a blocker for this port-forwarding +route. Use the localhost URL above, not a Docker/container IP or an example IP. -![Image](images/image6.png) +### Task 3: Running the Book Review Service -The Node.js server is located in the `node-server` folder. +Keep the frontend's port-forward running. Use another terminal for deployment, +and change back to the sample's `start` directory if necessary. -#### **Deploy the Book Review Service: Node.js Server** +#### Deploy the Book Review Service: Node.js Server -You can either [build the image locally](https://docs.docker.com/get-started/02_our_app/){:target="_blank"} or use our pre-built image. If you are using the pre-built image, you can proceed to the next step. - -When ready, run the following command to deploy the Node.js server: - -```shell -kubectl apply -f node-server/config/100-deployment.yaml -``` - -This command will pull the image and deploy it to your cluster as a Deployment. It will also expose it as a LoadBalancer to receive external traffic. - -``` -deployment.apps/node-server created -service/node-server-svc created +```bash +kubectl apply -f node-server/config/ +kubectl rollout status deployment/node-server ``` -???+ success "Verify" - - Run the following command to check if the pod is running: - - ```shell - kubectl get pods - ``` - - You will see that your Node.js server (node-server) pod is running. - ``` - NAME READY STATUS RESTARTS AGE - bookstore-frontend-7b879ffb78-9bln6 1/1 Running 0 39m - node-server-68bf98cdf4-skjmh 1/1 Running 0 38m - ``` - +This starts the backend. The frontend reaches it using the internal +`node-server-svc` Service address; no public backend address is needed for the +frontend to communicate with it. #### Access the node server backend -Follow the respective `minikube` or `kind` instructions to access Kubernetes Services locally from your machine. - -Check the running Kubernetes Services: +To check the backend directly, open another terminal and run: -```shell -kubectl get services -``` -And you will see the following console output: +```bash +kubectl port-forward service/node-server-svc 18081:80 ``` -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -bookstore-frontend-svc LoadBalancer 10.99.187.173 172.18.0.6 80:31600/TCP 73m -kubernetes ClusterIP 10.96.0.1 443/TCP 85m -node-server-svc LoadBalancer 10.101.90.35 172.18.0.8 80:31792/TCP 73m -``` - -!!! note - If the `EXTERNAL-IP` for your frontend service is ``, then there you'll need to check that - your `minikube tunnel` or KinD `cloud-provider-kind` is working properly. - -???+ success "Verify" - Access the node server page using the `node-server-svc` `EXTERNAL-IP` address. The UI page should appear! - - And in your front end page, you should see the status turns green and say "Connected to node server". - - ![Image](images/image18.png) - -## **Troubleshooting** -If you encounter any issues during the setup process, refer to the troubleshooting section in the documentation or check the logs of your Kubernetes pods for more details. -???+ bug "Troubleshooting" - To check the logs, use the following command: +Open **http://127.0.0.1:18081** to confirm that the backend responds. Then refresh +the frontend at **http://127.0.0.1:18080** and check its backend-connection status. +Do not enter the backend's localhost URL into cluster configuration; these +localhost addresses are only for your browser. - ```shell - kubectl logs - ``` +The backend check's port-forward can be stopped with ++ctrl+c++ afterward. +Keep the frontend's port-forward running for the following lessons. Neither +++ctrl+c++ nor closing a forwarding terminal deletes the application's resources. - Replace `` with the name of the pod you want to check. +## Troubleshooting -Secondly, ensure your KinD & minikube tunnels are running in order to access the websites. +- Check the cluster context and namespace before investigating the application. +- `kubectl get pods` shows whether the frontend and backend pods are ready. +- Inspect the relevant application logs with `kubectl logs deployment/bookstore-frontend` + or `kubectl logs deployment/node-server`. +- If the browser loses access, check that the corresponding port-forward terminal + is still running and that you are using its local port in the URL. +- If a command fails, [get help](../../getting-started/next-steps.md#get-help) + with its error rather than reinstalling Knative or creating another cluster. -## **Next Step** -![Image](images/image5.png) +## Next Step -You have successfully set up the cluster with Knative installed, and running your front end app and node server. You are all set to start learning. Your journey begins from here. +The frontend and backend are running. Continue using the sample's `start` +directory and keep the frontend port-forward open: -[Go to Lesson 1 - Send Review Comment to Broker :fontawesome-solid-paper-plane:](../page-1/send-review-comment-to-broker.md){ .md-button .md-button--primary } +[Go to Lesson 1: Send Review Comments to the Broker](../page-1/send-review-comment-to-broker.md){ .md-button .md-button--primary } diff --git a/docs/versioned/bookstore/page-0/welcome-knative-bookstore-tutorial.md b/docs/versioned/bookstore/page-0/welcome-knative-bookstore-tutorial.md index 32baa4ab100..2c60a3c4afa 100644 --- a/docs/versioned/bookstore/page-0/welcome-knative-bookstore-tutorial.md +++ b/docs/versioned/bookstore/page-0/welcome-knative-bookstore-tutorial.md @@ -5,24 +5,24 @@ components: - functions - serving function: tutorial +hide_prev: true --- -# Welcome: Knative Bookstore Tutorial + -![Welcome Image](images/1.png) - -**Welcome to Knative's End-to-End Sample Application Tutorial!** - -- Are you completely new to Knative and unsure where to start? -- Are you considering converting your application to an event-driven architecture but don't know how? -- Are you curious to see what Knative can do in real life? -- Are you new to the cloud computing world and looking to get started with open source? +# Knative Bookstore tutorial -!!! success "You found the right place" +Build a larger sample application that combines Functions, Serving, and Eventing. +The lessons follow reviews through an event-processing workflow and add the web +application, processing services, and database around it. - If any of these resonate with you, you've found the perfect starting point. +If you are new to Knative, begin with the independent [Get Started tracks](../../README.md) +first. Bookstore is a follow-on application exercise, not another universal +introduction, a migration guide, or a production bookstore. You can reuse your +learning cluster; the [environment setup](../page-0.5/environment-setup.md) describes +the extra application resources. -In this tutorial, we will construct an online bookstore application. This interactive guide, suitable for beginners and experienced engineers alike, will take you through the steps of building, deploying, and monitoring an application using Knative's powerful features. For those familiar with the process, concise graphics are available to streamline your learning experience. +![Welcome Image](images/1.png) ## **What are we building?** @@ -36,21 +36,16 @@ As the bookstore owner, you'll receive notifications via Slack each time if a co ![Learning Goal Image](images/3.png) -You will learn Event-Driven Architecture (EDA) and how it contrasts with traditional application designs that use microservices and REST APIs. You'll learn: - -- **The Fundamentals of EDA**: Explore the core principles of event-driven architecture and how it enhances responsiveness and scalability in applications. -- **Comparative Insights**: Understand the differences between EDA and traditional architectures, highlighting the benefits and use cases of each. -- **Practical Application**: Discover how to transition your existing applications to an event-driven model, utilizing the powerful features of Knative Eventing. +Follow a concrete event-driven application from its producer to its consumers: -![Knative Framework](images/4.png) +- Send review comments to a Broker and route them using Triggers. +- Connect processing functions in a Sequence to analyze and filter reviews. +- Store processed reviews and display them in the web application. +- Explore an external notification integration in the later Slack/Camel K lesson. -Knative is a powerful framework that operates on top of Kubernetes. This tutorial will guide you through: - -- **Setting Up Your Cluster**: You'll start by spinning up your own Kubernetes cluster, which is the foundation for deploying and managing containers. -- **Exploring Knative**: Gain hands-on experience with key Knative concepts and components. -- **Some example use cases of Knative**. - -By the end of this tutorial, you will not only understand these concepts but also feel comfortable implementing them, empowering you to build robust, scalable event-driven applications with Knative. +Reuse a ready learning cluster or create one through the shared setup guide. +The application adds its own frontend, backend, processing services, and database; +the introductory tracks do not create those resources for you. ## **Bookstore Architecture** @@ -80,7 +75,8 @@ There are 2 Machine learning workflows that can conduct sentiment analysis on us ### Book Store Broker -It acts as the central brain of our event-driven architecture. It connects all the microservices together, receives the event, and makes sure all the events are safely delivered to the correct destination. +It receives review events and routes them to the consumers selected by its Triggers. +This learning example does not establish production durability or delivery guarantees. ### Bad Word Broker @@ -91,7 +87,7 @@ It acts as the bridge between the book store Broker and the Slack Sink, so we ca We will be building the sample app in this order: -0. [**Environment Setup**](../page-0.5/environment-setup.md){:target="_blank"}: Set up the environment for the tutorial. This includes installing the cluster, the frontend and the backend. +0. [**Environment Setup**](../page-0.5/environment-setup.md): Reuse or create a learning cluster, then deploy the frontend and backend and open the local browser connection. 1. [**Send comments to the Broker**](../page-1/send-review-comment-to-broker.md){:target="_blank"}: Pass reviews from the frontend to event-display via the Broker. This involves learning about Broker, SinkBinding and CloudEvents event types. @@ -107,30 +103,39 @@ We will be building the sample app in this order: 7. [**Connect with External Services/API**](../page-7/slack-sink-learning-knative-eventing-and-apache-camel-K-integration.md){:target="_blank"}: Learn how to connect your application with external services and APIs using Knative Eventing and Apache Camel K integrations. -8. [**Extra Challenges**](../extra-challenge/README.md){:target="_blank"}: Additional challenges to test your understanding of the concepts learned in the tutorial. +8. [**Extra Challenges**](../extra-challenge/extra-challenges.md){:target="_blank"}: Additional challenges to test your understanding of the concepts learned in the tutorial. ## **How to properly learn?** -### Preview the Final Bookstore: 1-Minute Demo Video + -To help you visualize what you'll be creating, we've prepared a brief demo video. This two-minute preview showcases the final bookstore application, providing a clearer understanding of what you can expect to build. +### Preview the final application + +Watch the demo to see the application you will build. ???+ bug "Video not working above?" If the video is not working, you can watch it [here](https://www.youtube.com/watch?v=5D8pTcQSacw&ab_channel=Knative){:target="_blank"}. -### Step-by-Step Guidance for Beginners + + +### Follow the application sequence ![Beginner Guide](images/9.png) -This tutorial is meticulously structured to be beginner-friendly, featuring detailed, step-by-step instructions for building the sample app. Simply follow the sequence we've laid out: each section builds upon the previous, guiding you through the construction of the application. Should you encounter any hurdles, the Knative community is a fantastic resource for support. Don't hesitate to ask questions and seek advice. Check the [Help](#help) section below! +Unlike the independent Get Started tracks, these lessons build on one application. +Follow them in order and keep the frontend's port-forward running while you use +the browser UI. See [Help](#help) if a step fails rather than creating another +cluster or restarting from an unrelated introductory tutorial. ### Accelerated Learning Path for Advanced Users ![Advanced Users Guide](images/10.png) -If you find the tutorial too basic, or if it covers familiar territory, feel free to adjust your learning approach. Each section of the tutorial is accompanied by concise graphics that summarize key concepts. Advanced learners can choose to focus on these graphics to grasp the essentials faster, streamlining the learning experience without sacrificing depth or understanding. +If you already know the components, use the diagrams to orient yourself. Before +jumping to a later lesson, check that the resources created by its earlier steps +already exist; the later lessons are not independent setup paths. ## **Help** diff --git a/docs/versioned/bookstore/page-7/slack-sink-learning-knative-eventing-and-apache-camel-K-integration.md b/docs/versioned/bookstore/page-7/slack-sink-learning-knative-eventing-and-apache-camel-K-integration.md index f0a47892d8b..36b06588a76 100644 --- a/docs/versioned/bookstore/page-7/slack-sink-learning-knative-eventing-and-apache-camel-K-integration.md +++ b/docs/versioned/bookstore/page-7/slack-sink-learning-knative-eventing-and-apache-camel-K-integration.md @@ -439,4 +439,4 @@ Congratulations on successfully completing the bookstore sample app tutorial! If We've prepared additional challenges that build on top of the existing bookstore app for you to tackle. Some solutions are provided, while others are left open to encourage you to explore your own solutions. -[Go to Extra Challenges :fontawesome-solid-paper-plane:](../extra-challenge/README.md){ .md-button .md-button--primary } +[Go to Extra Challenges :fontawesome-solid-paper-plane:](../extra-challenge/extra-challenges.md){ .md-button .md-button--primary } diff --git a/docs/versioned/client/README.md b/docs/versioned/client/README.md index 1c37f3fb51e..28700ce25f9 100755 --- a/docs/versioned/client/README.md +++ b/docs/versioned/client/README.md @@ -22,7 +22,9 @@ See [Install and Set Up `kubectl`](https://kubernetes.io/docs/tasks/tools/instal `kn` provides a quick and easy interface for creating Knative resources such as services and event sources, without the need to create or modify YAML files directly. `kn` also simplifies completion of otherwise complex procedures such as autoscaling and traffic splitting. !!! note - `kn` cannot be used to install Knative components such as Serving or Eventing. + The core `kn` commands manage resources on an existing Knative installation. + The optional `quickstart` plugin creates a local learning cluster and installs + Serving and Eventing for you. ### Additional resources @@ -35,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 @@ -50,11 +52,10 @@ Using the `kn` CLI, you can specify the following options to connect to the clus - `--context`: use this option to specify the name of a context from the existing `kubeconfig` file. Use one of the contexts from the output of `kubectl config get-contexts`. -You can also specify a config file in the following ways: - -- Setting the environment variable `$KUBECONFIG`, and point it to the kubeconfig file. - -- Using the `kn` CLI `--config` option, for example, `kn service list --config path/to/config.yaml`. The default config is at `~/.config/kn/config.yaml`. +The `kn` CLI's `--config` option is different: it selects the +[kn configuration file](configure-kn.md), such as `~/.config/kn/config.yaml`. +It does not select Kubernetes cluster credentials. Use `--kubeconfig` or +`KUBECONFIG` for that. For more information about `kubeconfig` files, see [Organizing Cluster Access Using kubeconfig Files](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/){target=_blank}. diff --git a/docs/versioned/client/install-kn.md b/docs/versioned/client/install-kn.md index 31a97b480c2..0eedf9814fb 100644 --- a/docs/versioned/client/install-kn.md +++ b/docs/versioned/client/install-kn.md @@ -13,7 +13,10 @@ There are three CLI tools available for managing Knative: - Kubernetes CLI - `kubectl` - Knative CLI - `kn` -- Knative Operator CLI - `kn` +- Knative Functions CLI - `func` + +The Knative Operator CLI is an optional `kn operator` plugin for platform +administration; it is not required for the introductory tutorials. The `kn` CLI makes Knative operations easier, but all functionality is available in `kubectl` CLI provided you want to primarily use YAML representations of resources. @@ -26,7 +29,7 @@ Install the [Kubernetes CLI (`kubectl`)](https://kubernetes.io/docs/tasks/tools/ ### Install kn using the nightly-built binary !!! warning - Nightly container images include features which may not be included in the latest Knative release and are not considered to be stable. + Nightly binaries include features which may not be included in the latest Knative release and are not considered to be stable. Nightly-built executable binaries are available for users who want to install the latest pre-release build of `kn`. @@ -56,7 +59,7 @@ Before you install the Knative Operator CLI Plugin, first install the Knative CL === "Linux" - 1. Download the binary `kn-operator-linux-amd64` for your system from the [release page](https://github.com/knative-extensions/kn-plugin-operator/releases/tag/knative-v1.7.1). + 1. Download the binary `kn-operator-linux-amd64` for your system from the [release page](https://github.com/knative-extensions/kn-plugin-operator/releases/latest). 1. Rename the binary to `kn-operator`: diff --git a/docs/versioned/eventing/README.md b/docs/versioned/eventing/README.md index a0eaf2324f4..f92ba671a76 100644 --- a/docs/versioned/eventing/README.md +++ b/docs/versioned/eventing/README.md @@ -30,4 +30,10 @@ Examples of supported Knative Eventing use cases: ## Next steps +- Follow [Get started with Eventing](../getting-started/getting-started-eventing.md) + to send an event through a Broker and deliver it using a Trigger. This is the + same Eventing track linked from Get Started; it links to shared cluster setup. +- Once you know the basics, try the + [Bookstore tutorial](../bookstore/page-0/welcome-knative-bookstore-tutorial.md) + to combine the components in a larger application. - You can install Knative Eventing by using the methods listed on the [installation page](../install/README.md). diff --git a/docs/versioned/eventing/brokers/create-broker.md b/docs/versioned/eventing/brokers/create-broker.md index a409c75c636..50de1f8a87e 100644 --- a/docs/versioned/eventing/brokers/create-broker.md +++ b/docs/versioned/eventing/brokers/create-broker.md @@ -25,7 +25,9 @@ You can create a Broker by using the `kn` CLI or by applying YAML files using `k This will create a new Broker of your default Broker class and default Broker configuration (both defined in the `config-br-defaults` ConfigMap). !!! note - If you choose not to specify a namespace, the Broker will be created in the current namespace. + If you omit the namespace, the Broker is created in the current namespace. + Omit the namespace flag in both verification commands too, or explicitly + use that same namespace. !!! note If you have multiple Broker classes installed in your cluster, you can specify the Broker class via the `--class` parameter, e.g.: @@ -34,21 +36,25 @@ You can create a Broker by using the `kn` CLI or by applying YAML files using `k kn broker create -n --class MTChannelBasedBroker ``` - 1. Optional: Verify that the Broker was created by listing existing Brokers: + 1. Verify the Broker in the same namespace used for creation: ```bash - kn broker list + kn broker list -n ``` + Find `` and check that `READY` is `True`. If it is `False`, + wait and repeat the check, or inspect its condition messages below. + 1. Optional: You can also verify the Broker exists by describing the Broker you have created: ```bash - kn broker describe + kn broker describe -n ``` === "kubectl" - The YAML in the following example creates a Broker named `default`. + Supply the Broker name and namespace in this YAML template, then use those + same values in the verification command. 1. Create a Broker by creating a YAML file using the following template: diff --git a/docs/versioned/eventing/triggers/README.md b/docs/versioned/eventing/triggers/README.md index d019995f8c9..4230814ad8a 100644 --- a/docs/versioned/eventing/triggers/README.md +++ b/docs/versioned/eventing/triggers/README.md @@ -11,8 +11,23 @@ A trigger represents a desire to subscribe to events from a specific broker. The `subscriber` value must be a [Destination](https://pkg.go.dev/knative.dev/pkg/apis/duck/v1#Destination). +## Prerequisites + +- Knative Eventing is installed and you have a ready Broker in the namespace + selected by your `kubectl` context. [Create a Broker](../brokers/create-broker.md) + if needed. +- An event consumer is already running and ready. Use the correct reference kind + and API version for a Knative Service or an ordinary Kubernetes Service. +- Replace the example names with your resources. Here `default` is a **Broker + name**, not an instruction to create a Broker or select a namespace. The + Quickstart tutorial's Broker is named `example-broker`, so substitute that name + if you are reusing it. Replace `my-service` with your consumer's name too. + ## Example Triggers +Choose the subscriber form that matches your consumer; these are alternatives, +not two steps to apply to the same Trigger. + The following trigger receives all the events from the `default` broker and delivers them to the Knative Serving service `my-service`: @@ -67,6 +82,29 @@ delivers them to the custom path `/my-custom-path` for the Kubernetes service `m ``` Where `` is the name of the file you created in the previous step. +## Verify the subscription + +After applying your chosen example, check the Trigger, substituting its name if +it differs from `my-service-trigger`: + +```bash +kubectl get trigger my-service-trigger +``` + +Its `READY` condition should be `True`. If not, inspect the reported conditions: + +```bash +kubectl describe trigger my-service-trigger +``` + +Check the named Broker and consumer before changing the Trigger. To verify +end-to-end delivery, send a known CloudEvent from your producer to that Broker +and confirm its Event ID and data at your consumer. A ready Trigger means its +subscription is configured; it does not prove an event has been delivered. + +For a guided example with a sender and observable consumer, see +[Get started with Eventing](../../getting-started/getting-started-eventing.md). + ## Trigger filtering Various forms of filtering based on any number of CloudEvents attributes and extensions @@ -83,7 +121,7 @@ do not support filtering on the `data` field of CloudEvents. This example filters events from the `default` broker that are of type `dev.knative.foo.bar` and have the extension `myextension` which ends -with `-extensions. +with `-value`. 1. Create a YAML file using the following example: @@ -97,7 +135,7 @@ with `-extensions. filters: - exact: type: dev.knative.foo.bar - suffix: + - suffix: myextension: -value subscriber: ref: @@ -279,8 +317,8 @@ metadata: spec: broker: default filters: - exact: - type: dev.knative.a + - exact: + type: dev.knative.a filter: attributes: type: dev.knative.b @@ -312,9 +350,9 @@ spec: attributes: type: dev.knative.foo.bar myextension: my-extension-value - subscriber: - ref: - apiVersion: serving.knative.dev/v1 - kind: Service - name: my-service + subscriber: + ref: + apiVersion: serving.knative.dev/v1 + kind: Service + name: my-service ``` diff --git a/docs/versioned/functions/README.md b/docs/versioned/functions/README.md index dd869dba76b..7bdb8d08fa5 100644 --- a/docs/versioned/functions/README.md +++ b/docs/versioned/functions/README.md @@ -3,21 +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 - -Before you can use Knative Functions, you must have access to a Knative development environment. To set up a development environment, you can follow the [Knative Quickstart tutorial](../getting-started/README.md){target=_blank}. +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 75076b249fa..f6caf1138a7 100644 --- a/docs/versioned/functions/building-functions.md +++ b/docs/versioned/functions/building-functions.md @@ -3,50 +3,67 @@ audience: developer components: - functions function: how-to +hide_prev: true +hide_next: true --- -# Building functions +# Build an image ---8<-- "build-func-intro.md" +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 -You can build a container image for your function locally without deploying it to a cluster, by using the `build` command. +- 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. -### Prerequisites + -- You have a Docker daemon on your local machine. This is already provided if you have used the Quickstart installation. +## Build -### Procedure +Pass an explicit local image name so the build does not prompt for a registry: ---8<-- "proc-building-function.md" +=== "func" -## On-cluster Builds + ```bash + func build --builder pack \ + --image localhost/my-function:latest + ``` -If you do not have a local Docker daemon running, or you are using a CI/CD pipeline, you might want to build your function on the cluster instead of using a local build. You can create an on-cluster build by using the `func deploy --remote` command. +=== "kn func" -!!! note - If you're doing a direct-upload deployment (i.e. the source code is on your local machine instead of a git repo), you can create an on-cluster build without the need of specifying the Git URL, but if you already specified a Git URL before, you'll need to specify the flag as empty, using the command `func deploy --remote --git-url=""` + ```bash + kn func build --builder pack \ + --image localhost/my-function:latest + ``` -### Prerequisites +`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`. -- The function must exist in a Git repository. -- You must configure your cluster to use Tekton Pipelines. See the [on-cluster build](https://github.com/knative/func/blob/main/docs/building-functions/on_cluster_build.md){target=_blank} documentation. +## Verify the image -### Procedure +Confirm the image exists in Docker: -When running the command for the first time, you must specify the Git URL for the function: +```bash +docker image ls localhost/my-function:latest +``` -=== "func" +A row with tag `latest` and an image ID confirms the build succeeded. This does +not push or start the container. - ```{ .console } - func deploy --remote --registry --git-url -p hello - ``` - -=== "kn func" + - ```{ .console } - kn func deploy --remote --registry --git-url -p hello - ``` +## Other builders -After you have specified the Git URL for your function once, you can omit it in subsequent commands. +`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/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/deploying-functions.md b/docs/versioned/functions/deploying-functions.md index cb11900a3ef..587caa08dde 100644 --- a/docs/versioned/functions/deploying-functions.md +++ b/docs/versioned/functions/deploying-functions.md @@ -3,18 +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 Docker daemon on your local machine. This is already provided if you have used the Quickstart installation. +- 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 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. +## Deploy from your machine -## Procedure +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: ---8<-- "proc-deploying-function.md" +=== "func" + + ```bash + func deploy --registry + ``` + +=== "kn func" + + ```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/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/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