Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding initial doc for func subscribe #5754

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ nav:
- 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
- Language packs: functions/language-packs.md
Expand Down
37 changes: 37 additions & 0 deletions docs/functions/subscribing-functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Subscribe functions to CloudEvents

### Prerequisites

- Knative Eventing installed on the cluster

### Procedure

--8<-- "proc-subscribe-function.md"

### Deployment with Triggers

When invoking `func deploy` the CLI will create Knative Triggers for the function.

=== "func"

Deploy the function with Triggers by running the command inside the project directory:

```bash
func deploy
```

=== "kn func"

Deploy the function with Triggers by running the command inside the project directory:

```bash
kn func deploy
```

!!! Success "Expected output"
```{ .bash .no-copy }
🙌 Function image built: <registry>/hello:latest
🎯 Creating Triggers on the cluster
✅ Function deployed in namespace "default" and exposed at URL:
http://hello.default.127.0.0.1.sslip.io
```
33 changes: 33 additions & 0 deletions docs/snippets/proc-subscribe-function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- Snippet used in the following topics:
- /docs/functions/subscribing-functions.md
-->
The `subscribe` command will connect the function to a set of events, matching a series of filters for Cloud Event metadata
and a Knative Broker as the source of events, from where they are consumed.

=== "func"

To subscribe the function to events for a given broker, run the following command:

```bash
func subscribe --filter type=com.example --filter extension=my-extension-value --source my-broker
```

To subscribe the function to events for the default broker, run the following command:

```bash
func subscribe --filter type=com.example --filter extension=my-extension-value
```

=== "kn func"

To subscribe the function to events for a given broker, run the following command:

```bash
kn func subscribe --filter type=com.example --filter extension=my-extension-value --source my-broker
```

To subscribe the function to events for the default broker, run the following command:

```bash
kn func subscribe --filter type=com.example --filter extension=my-extension-value
```