Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Kn plugin for sending events to Knative sinks.

License

NotificationsYou must be signed in to change notification settings

knative-extensions/kn-plugin-event

MageGo Report CardReleasesLICENSEMaturity level

kn-plugin-event is a plugin of Knative Client, for managing cloud events fromcommand line.

Description

With this plugin, you can build and send the cloud events to publicly availableaddresses (URLs) or to Addressable (Kubernetes service, Knative service, broker,channels, etc) inside of Kubernetes cluster.

Usage

Build an event

You could usebuild subcommand to create an event with a help of convenientbuilder-like interface. It may be helpful to send that even later or use it inother context.

Simplest event

$ kn event build -o yamldata: {}datacontenttype: application/jsonid: 81a402a2-9c29-4c27-b8ed-246a253c9e58source: kn-event/v0.4.0specversion:"1.0"time:"2021-10-15T10:42:57.713226203Z"type: dev.knative.cli.plugin.event.generic

More complex example

$ kn event build \    --field operation.type=local-wire-transfer \    --field operation.amount=2345.40 \    --field operation.from=87656231 \    --field operation.to=2344121 \    --field automated=true \    --field signature='FGzCPLvYWdEgsdpb3qXkaVp7Da0=' \    --type org.example.bank.bar \    --id$(head -c 10< /dev/urandom| base64 -w 0) \    --output json{"specversion":"1.0","id":"RjtL8UH66X+UJg==","source":"kn-event/v0.4.0","type":"org.example.bank.bar","datacontenttype":"application/json","time":"2021-10-15T10:43:23.113187943Z","data": {"automated": true,"operation": {"amount":"2345.40","from": 87656231,"to": 2344121,"type":"local-wire-transfer"    },"signature":"FGzCPLvYWdEgsdpb3qXkaVp7Da0="  }}

Send an event

To send an event, you should use thesend subcommand. Thesend command usesthe same builder-like interface as thebuild command. You can send an event tothe public address of your application or to a supported in-cluster resource byusing the--to option.

Sending to a public address

To send an event to a public address, you should pass the address to the--tooption:

$ kn event send \    --field player.id=6354aa60-ddb1-452e-8c13-24893667de20 \    --field player.game=2345 \    --field points=456 \    --type org.example.gaming.foo \    --to http://ce-api.foo.example.org/

NOTE: All arguments, except--to are optional. Usekn event send --help to see full usage information.

Sending to the in-cluster resources

Sending events to the in-cluster resources is done with a companionJobthat is deployed on your cluster. This allowskn-event to send your events toresources that are not publicly accessible.

Send an event to a Knative serviceshowcase in current namespace:

$ kn event send \    --type org.example.kn.ping \    --id$(uuidgen) \    --field event.data=98765 \    --to showcase

To send the event to the broker namedfoo inmy-ns namespace:

$ kn event send --to broker:foo:my-ns

NOTE: The--to option followsthe Kn sink format.Usekn event send --help to see full format description.

Install

You can download a pre-built version ofkn-plugin-event fromour release page. Choose the one that fits your platform.

When the download is ready, you should be ready to usekn-plugin-event as astandalone binary. Check the available commands with:

kn-event-<OS>-<ARCH> --help

Install to work withkn CLI

If you'd like to use the plugin withkn CLI, install the plugin by simplycopying the executable file underkn plugins directory as:

$ mkdir -p~/.config/kn/plugins$ cp build/_output/bin/kn-event-<OS>-<ARCH> \~/.config/kn/plugins/kn-event

Check if plugin is loaded

$ kn -h

Run it

$ kn event -h

Building

If you'd like to build the plugin yourself, you will need to haveGolang installed on your machine. Check thego.mod filefor current minimum version.

To build the plugin, just invoke the following script:

$ ./mage

Project will check, test and build binaries for various platforms. You'll get anexecutable plugin binary namedkn-event-<OS>-<ARCH> inbuild/_output/bindir.

You could list all available build targets with:

$ ./mage -l

Updating dependencies

To update dependencies, please utilize the standardhack/update-deps.shscript. It's also needed to run this script if you are doing any changes to Golibraries. Read more about it atknative/hackrepository.

About

Kn plugin for sending events to Knative sinks.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors10


[8]ページ先頭

©2009-2025 Movatter.jp