- Notifications
You must be signed in to change notification settings - Fork27
Kn plugin for sending events to Knative sinks.
License
knative-extensions/kn-plugin-event
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
kn-plugin-event
is a plugin of Knative Client, for managing cloud events fromcommand line.
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.
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.
$ 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
$ 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=" }}
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.
To send an event to a public address, you should pass the address to the--to
option:
$ 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 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.
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
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
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/bin
dir.
You could list all available build targets with:
$ ./mage -l
To update dependencies, please utilize the standardhack/update-deps.sh
script. 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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors10
Uh oh!
There was an error while loading.Please reload this page.