[#3085] Enhance PingSource example with kn (#3191)

- use kn rather than `kubectl -f some-file.yaml` as thats a wasted
  opportunity and doesn't add any value.
- show examples of kn side by side with the declarative form

Signed-off-by: Sameer Vohra <vsameer@vmware.com>
This commit is contained in:
Sameer Vohra 2021-01-30 22:18:32 -06:00 committed by GitHub
parent 02e91b2b62
commit 996fae334c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 31 deletions

View File

@ -20,8 +20,8 @@ a Knative Service.
To verify that `PingSource` is working, create a simple Knative To verify that `PingSource` is working, create a simple Knative
Service that dumps incoming messages to its log. Service that dumps incoming messages to its log.
{{< tabs name="create-service" default="By YAML" >}} {{< tabs name="create-service" default="YAML" >}}
{{% tab name="By YAML" %}} {{% tab name="YAML" %}}
Use following command to create the service from STDIN: Use following command to create the service from STDIN:
```shell ```shell
@ -39,11 +39,11 @@ EOF
``` ```
{{< /tab >}} {{< /tab >}}
{{% tab name="By filename" %}} {{% tab name="kn" %}}
Use following command to create the service from the `service.yaml` file: Use following command to create the service using the kn cli:
```shell ```shell
kubectl apply --filename service.yaml kn service create event-display --image gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display
``` ```
{{< /tab >}} {{< /tab >}}
{{< /tabs >}} {{< /tabs >}}
@ -53,8 +53,8 @@ kubectl apply --filename service.yaml
For each set of ping events that you want to request, create an Event For each set of ping events that you want to request, create an Event
Source in the same namespace as the destination. Source in the same namespace as the destination.
{{< tabs name="create-source" default="By YAML" >}} {{< tabs name="create-source" default="YAML" >}}
{{% tab name="By YAML" %}} {{% tab name="YAML" %}}
Use following command to create the event source from STDIN: Use following command to create the event source from STDIN:
```shell ```shell
@ -76,11 +76,14 @@ EOF
``` ```
{{< /tab >}} {{< /tab >}}
{{% tab name="By filename" %}} {{% tab name="kn" %}}
Use following command to create the event source from the `ping-source.yaml` file: Use following command to create the event source from the `ping-source.yaml` file:
```shell ```shell
kubectl apply --filename ping-source.yaml kn source ping create test-ping-source \
--schedule "*/2 * * * *" --data \
'{ "message": "Hello world!" }' \
--sink ksvc:event-display
``` ```
{{< /tab >}} {{< /tab >}}
{{< /tabs >}} {{< /tabs >}}
@ -91,8 +94,6 @@ Sometimes you may want to send binary data, which cannot be directly serialized
Please note that `data` and `dataBase64` cannot co-exist. Please note that `data` and `dataBase64` cannot co-exist.
{{< tabs name="create-source" default="By YAML" >}}
{{% tab name="By YAML" %}}
Use the following command to create the event source with binary data from STDIN: Use the following command to create the event source with binary data from STDIN:
```shell ```shell
@ -112,17 +113,6 @@ spec:
name: event-display name: event-display
EOF EOF
``` ```
{{< /tab >}}
{{% tab name="By filename" %}}
Use the following command to create the event source from the `ping-source-binary.yaml` file:
```shell
kubectl apply --filename ping-source-binary.yaml
```
{{< /tab >}}
{{< /tabs >}}
## Verify ## Verify
@ -189,18 +179,18 @@ Data,
You can delete the PingSource instance by entering the following command: You can delete the PingSource instance by entering the following command:
{{< tabs name="delete-source" default="By name" >}} {{< tabs name="delete-source" default="kubectl" >}}
{{% tab name="By name" %}} {{% tab name="kubectl" %}}
```shell ```shell
kubectl delete pingsources.sources.knative.dev test-ping-source kubectl delete pingsources.sources.knative.dev test-ping-source
kubectl delete pingsources.sources.knative.dev test-ping-source-binary kubectl delete pingsources.sources.knative.dev test-ping-source-binary
``` ```
{{< /tab >}} {{< /tab >}}
{{% tab name="By filename" %}} {{% tab name="kn" %}}
```shell ```shell
kubectl delete --filename ping-source.yaml kn source ping delete test-ping-source
kubectl delete --filename ping-source-binary.yaml kn source ping delete test-ping-source-binary
``` ```
{{< /tab >}} {{< /tab >}}
{{< /tabs >}} {{< /tabs >}}
@ -208,15 +198,15 @@ kubectl delete --filename ping-source-binary.yaml
Similarly, you can delete the Service instance via: Similarly, you can delete the Service instance via:
{{< tabs name="delete-service" default="By name" >}} {{< tabs name="delete-service" default="kubectl" >}}
{{% tab name="By name" %}} {{% tab name="kubectl" %}}
```shell ```shell
kubectl delete service.serving.knative.dev event-display kubectl delete service.serving.knative.dev event-display
``` ```
{{< /tab >}} {{< /tab >}}
{{% tab name="By filename" %}} {{% tab name="kn" %}}
```shell ```shell
kubectl delete --filename service.yaml kn service delete event-display
``` ```
{{< /tab >}} {{< /tab >}}