mirror of https://github.com/knative/docs.git
Format markdown (#1288)
Produced via: `prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github)`
This commit is contained in:
parent
4d7064dcf9
commit
8d62a0b066
|
@ -13,7 +13,7 @@ something isn't working, lend a helping hand and fix it in a PR.
|
|||
Knative Serving sample apps.
|
||||
|
||||
| Sample Name | Description | Language(s) |
|
||||
| ----------- | ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ----------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| Hello World | A quick introduction to Knative Serving that highlights how to deploy an app. | [Clojure](./serving/helloworld-clojure/README.md), [Dart](./serving/helloworld-dart/README.md), [Elixir](./serving/helloworld-elixir/README.md), [Haskell](./serving/helloworld-haskell/README.md), [Java - Quarkus](./serving/helloworld-java-quarkus/README.md), [Rust](./serving/helloworld-rust/README.md), [Swift](./serving/helloworld-swift/README.md), [Vertx](./serving/helloworld-vertx/README.md) |
|
||||
|
||||
#### Build samples
|
||||
|
|
|
@ -27,7 +27,7 @@ be created using the following instructions.
|
|||
description: Hello world server example in Dart
|
||||
|
||||
environment:
|
||||
sdk: '>=2.1.0 <3.0.0'
|
||||
sdk: ">=2.1.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
shelf: ^0.7.3
|
||||
|
|
|
@ -1,27 +1,35 @@
|
|||
A simple [JAX-RS REST API](https://github.com/jax-rs) application that is written in Java and uses [Quarkus](https://quarkus.io/).
|
||||
A simple [JAX-RS REST API](https://github.com/jax-rs) application that is
|
||||
written in Java and uses [Quarkus](https://quarkus.io/).
|
||||
|
||||
This samples uses Docker to build locally. The app reads in a `TARGET` env variable and then prints "Hello World: \${TARGET}!". If a value for `TARGET` is not specified, the "NOT SPECIFIED" default value is used.
|
||||
This samples uses Docker to build locally. The app reads in a `TARGET` env
|
||||
variable and then prints "Hello World: \${TARGET}!". If a value for `TARGET` is
|
||||
not specified, the "NOT SPECIFIED" default value is used.
|
||||
|
||||
## Before you begin
|
||||
|
||||
You must meet the following requirements to run this sample:
|
||||
|
||||
- Have a Kubernetes cluster running with the Knative Serving component installed. For more information, see the
|
||||
- Have a Kubernetes cluster running with the Knative Serving component
|
||||
installed. For more information, see the
|
||||
[Knative instruction guides](https://github.com/knative/docs/blob/master/docs/install/README.md).
|
||||
- An installed version of the following tools:
|
||||
- [Docker](https://www.docker.com)
|
||||
- [Java SE 8 or later JDK](https://www.eclipse.org/openj9/)
|
||||
- [Maven](https://maven.apache.org/download.cgi)
|
||||
- A [Docker Hub account](https://hub.docker.com/) to which you are able to upload your sample's container image.
|
||||
- A [Docker Hub account](https://hub.docker.com/) to which you are able to
|
||||
upload your sample's container image.
|
||||
|
||||
## Getting the code
|
||||
|
||||
You can either clone a working copy of the sample code from the repository, or following the steps in the
|
||||
[Recreating the sample code](#recreating-the-sample-code) to walk through the steps of updating all the files.
|
||||
You can either clone a working copy of the sample code from the repository, or
|
||||
following the steps in the
|
||||
[Recreating the sample code](#recreating-the-sample-code) to walk through the
|
||||
steps of updating all the files.
|
||||
|
||||
### Cloning the sample code
|
||||
|
||||
Use this method to clone and then immediate run the sample. To clone the sample code, run the following commands:
|
||||
Use this method to clone and then immediate run the sample. To clone the sample
|
||||
code, run the following commands:
|
||||
|
||||
```
|
||||
git clone https://github.com/knative/docs.git knative/docs
|
||||
|
@ -32,8 +40,8 @@ You are now ready to [run the sample locally](#locally-testing-your-sample).
|
|||
|
||||
### Recreating the sample code
|
||||
|
||||
Use the following steps to obtain an incomplete copy of the sample code for which you update and create the
|
||||
necessary build and configuration files:
|
||||
Use the following steps to obtain an incomplete copy of the sample code for
|
||||
which you update and create the necessary build and configuration files:
|
||||
|
||||
1. From the console, create a new empty web project using the Maven archetype
|
||||
commands:
|
||||
|
@ -47,7 +55,9 @@ necessary build and configuration files:
|
|||
```
|
||||
|
||||
1. Update the `GreetingResource` class in
|
||||
`src/main/java/com/redhat/developer/demos/GreetingResource.java` to handle the "/" mapping and also add a `@ConfigProperty` field to provide the TARGET environment variable:
|
||||
`src/main/java/com/redhat/developer/demos/GreetingResource.java` to handle
|
||||
the "/" mapping and also add a `@ConfigProperty` field to provide the TARGET
|
||||
environment variable:
|
||||
|
||||
```java
|
||||
package com.redhat.developer.demos;
|
||||
|
@ -71,7 +81,9 @@ necessary build and configuration files:
|
|||
}
|
||||
```
|
||||
|
||||
1. Update `src/main/resources/application.properties` to configuration the application to default to port 8080, but allow the port to be overriden by the `PORT` environmental variable:
|
||||
1. Update `src/main/resources/application.properties` to configuration the
|
||||
application to default to port 8080, but allow the port to be overriden by
|
||||
the `PORT` environmental variable:
|
||||
|
||||
```
|
||||
# Configuration file
|
||||
|
@ -80,7 +92,8 @@ necessary build and configuration files:
|
|||
quarkus.http.port=${PORT:8080}
|
||||
```
|
||||
|
||||
1. Update `src/test/java/com/redhat/developer/demos/GreetingResourceTest.java` test to reflect the change:
|
||||
1. Update `src/test/java/com/redhat/developer/demos/GreetingResourceTest.java`
|
||||
test to reflect the change:
|
||||
|
||||
```java
|
||||
package com.redhat.developer.demos;
|
||||
|
@ -106,7 +119,8 @@ necessary build and configuration files:
|
|||
|
||||
```
|
||||
|
||||
1. Remove `src/main/resources/META-INF/resources/index.html` file since it's unncessary for this example.
|
||||
1. Remove `src/main/resources/META-INF/resources/index.html` file since it's
|
||||
unncessary for this example.
|
||||
|
||||
```shell
|
||||
rm src/main/resources/META-INF/resources/index.html
|
||||
|
@ -142,7 +156,8 @@ necessary build and configuration files:
|
|||
ENTRYPOINT [ "/deployments/run-java.sh" ]
|
||||
```
|
||||
|
||||
If you want to build Quarkus native image, then copy the following code block in to file called `Dockerfile.native`
|
||||
If you want to build Quarkus native image, then copy the following code block
|
||||
in to file called `Dockerfile.native`
|
||||
|
||||
```docker
|
||||
FROM quay.io/rhdevelopers/quarkus-java-builder:graal-1.0.0-rc15 as builder
|
||||
|
@ -194,9 +209,12 @@ necessary build and configuration files:
|
|||
|
||||
## Building and deploying the sample
|
||||
|
||||
Once you have recreated the sample code files (or used the files in the sample folder) you're ready to build and deploy the sample app.
|
||||
Once you have recreated the sample code files (or used the files in the sample
|
||||
folder) you're ready to build and deploy the sample app.
|
||||
|
||||
1. Use Docker to build the sample code into a container. To build and push with Docker Hub, run these commands replacing `{username}` with your Docker Hub username:
|
||||
1. Use Docker to build the sample code into a container. To build and push with
|
||||
Docker Hub, run these commands replacing `{username}` with your Docker Hub
|
||||
username:
|
||||
|
||||
```shell
|
||||
# Build the container on your local machine
|
||||
|
@ -267,9 +285,8 @@ the configuration using `kubectl`:
|
|||
--output jsonpath={.status.domain}
|
||||
```
|
||||
|
||||
1. Now you can make a request to your app to see the result. Presuming,
|
||||
the IP address you got in the step above is in the `${IP_ADDRESS}`
|
||||
env variable:
|
||||
1. Now you can make a request to your app to see the result. Presuming, the IP
|
||||
address you got in the step above is in the `${IP_ADDRESS}` env variable:
|
||||
|
||||
```shell
|
||||
curl -H "Host: ${DOMAIN_NAME}" http://${IP_ADDRESS}
|
||||
|
@ -284,4 +301,3 @@ To remove the sample app from your cluster, delete the service record:
|
|||
```shell
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
|
|
|
@ -1,19 +1,25 @@
|
|||
These samples show how to configure a Camel source. It is a event source that
|
||||
can leverage one of the [250+ Apache Camel components](https://github.com/apache/camel/tree/master/components)
|
||||
can leverage one of the
|
||||
[250+ Apache Camel components](https://github.com/apache/camel/tree/master/components)
|
||||
for generating events.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. [Install Knative Serving and Eventing](../../../install).
|
||||
|
||||
1. Install the [Apache Camel K](https://github.com/apache/camel-k) Operator in any namespace where you want to run Camel sources.
|
||||
1. Install the [Apache Camel K](https://github.com/apache/camel-k) Operator in
|
||||
any namespace where you want to run Camel sources.
|
||||
|
||||
The preferred version that is compatible with Camel sources is [Camel K v0.2.0](https://github.com/apache/camel-k/releases/tag/0.2.0).
|
||||
The preferred version that is compatible with Camel sources is
|
||||
[Camel K v0.2.0](https://github.com/apache/camel-k/releases/tag/0.2.0).
|
||||
|
||||
Installation instruction are provided on the [Apache Camel K Github repository](https://github.com/apache/camel-k#installation).
|
||||
Documentation includes specific instructions for common Kubernetes environments, including development clusters.
|
||||
Installation instruction are provided on the
|
||||
[Apache Camel K Github repository](https://github.com/apache/camel-k#installation).
|
||||
Documentation includes specific instructions for common Kubernetes
|
||||
environments, including development clusters.
|
||||
|
||||
1. Install the Camel Source from the `camel.yaml` in the [Eventing Sources release page](https://github.com/knative/eventing-sources/releases):
|
||||
1. Install the Camel Source from the `camel.yaml` in the
|
||||
[Eventing Sources release page](https://github.com/knative/eventing-sources/releases):
|
||||
|
||||
```shell
|
||||
kubectl apply --filename camel.yaml
|
||||
|
@ -24,8 +30,10 @@ for generating events.
|
|||
In order to check if a `CamelSource` is fully working, we will create:
|
||||
|
||||
- a simple Knative event display service that prints incoming events to its log
|
||||
- a in-memory channel named `camel-test` that will buffer events created by the event source
|
||||
- a subscription to direct events from the test channel to the event display service
|
||||
- a in-memory channel named `camel-test` that will buffer events created by the
|
||||
event source
|
||||
- a subscription to direct events from the test channel to the event display
|
||||
service
|
||||
|
||||
Deploy the [`display_resources.yaml`](./display_resources.yaml):
|
||||
|
||||
|
@ -35,11 +43,14 @@ kubectl apply --filename display_resources.yaml
|
|||
|
||||
## Run a CamelSource using the Timer component
|
||||
|
||||
The simplest example of CamelSource, that does not require additional configuration, is the "timer" source.
|
||||
The simplest example of CamelSource, that does not require additional
|
||||
configuration, is the "timer" source.
|
||||
|
||||
If you want, you can customize the source behavior using options available in the Apache Camel documentation for the
|
||||
If you want, you can customize the source behavior using options available in
|
||||
the Apache Camel documentation for the
|
||||
[timer component](https://github.com/apache/camel/blob/master/components/camel-timer/src/main/docs/timer-component.adoc).
|
||||
All Camel components are documented in the [Apache Camel github repository](https://github.com/apache/camel/tree/master/components).
|
||||
All Camel components are documented in the
|
||||
[Apache Camel github repository](https://github.com/apache/camel/tree/master/components).
|
||||
|
||||
Install the [`source_timer.yaml`](source_timer.yaml) resource:
|
||||
|
||||
|
@ -54,22 +65,29 @@ system by looking at what is downstream of the `CamelSource`.
|
|||
kubectl logs --selector serving.knative.dev/service=camel-event-display -c user-container
|
||||
```
|
||||
|
||||
If you've deployed the timer source, you should see log lines appearing every 3 seconds.
|
||||
If you've deployed the timer source, you should see log lines appearing every 3
|
||||
seconds.
|
||||
|
||||
## Run a CamelSource using the Telegram component
|
||||
|
||||
Another useful component available with Camel is the Telegram component. It can be used to forward messages of
|
||||
a [Telegram](https://telegram.org/) chat into Knative channels as events.
|
||||
Another useful component available with Camel is the Telegram component. It can
|
||||
be used to forward messages of a [Telegram](https://telegram.org/) chat into
|
||||
Knative channels as events.
|
||||
|
||||
Before using the provided Telegram CamelSource example, you need to follow the instructions on the Telegram website for
|
||||
creating a [Telegram Bot](https://core.telegram.org/bots).
|
||||
The quickest way to create a bot is to contact the [Bot Father](https://telegram.me/botfather), another Telegram Bot,
|
||||
using your preferred Telegram client (mobile or web).
|
||||
After you create the bot, you'll receive an **authorization token** that is needed for the source to work.
|
||||
Before using the provided Telegram CamelSource example, you need to follow the
|
||||
instructions on the Telegram website for creating a
|
||||
[Telegram Bot](https://core.telegram.org/bots). The quickest way to create a bot
|
||||
is to contact the [Bot Father](https://telegram.me/botfather), another Telegram
|
||||
Bot, using your preferred Telegram client (mobile or web). After you create the
|
||||
bot, you'll receive an **authorization token** that is needed for the source to
|
||||
work.
|
||||
|
||||
First, download and edit the [`source_telegram.yaml`](source_telegram.yaml) file and put the authorization token, replacing the `<put-your-token-here>` placeholder.
|
||||
First, download and edit the [`source_telegram.yaml`](source_telegram.yaml) file
|
||||
and put the authorization token, replacing the `<put-your-token-here>`
|
||||
placeholder.
|
||||
|
||||
To reduce noise in the event display, you can remove the previously created timer CamelSource from the namespace:
|
||||
To reduce noise in the event display, you can remove the previously created
|
||||
timer CamelSource from the namespace:
|
||||
|
||||
```shell
|
||||
kubectl delete camelsource camel-timer-source
|
||||
|
@ -89,4 +107,5 @@ Check again the logs on the event display:
|
|||
kubectl logs --selector serving.knative.dev/service=camel-event-display -c user-container
|
||||
```
|
||||
|
||||
Each message you send to the bot will be printed by the event display as a cloudevent.
|
||||
Each message you send to the bot will be printed by the event display as a
|
||||
cloudevent.
|
||||
|
|
|
@ -128,8 +128,9 @@ We will verify that the published message was sent into the Knative eventing
|
|||
system by looking at the logs of the function subscribed to the `pubsub-test`
|
||||
channel.
|
||||
|
||||
The function and the subscription were created by applying the [`trigger.yaml`](./trigger.yaml)
|
||||
manifest in the [deployment](#deployment) section above.
|
||||
The function and the subscription were created by applying the
|
||||
[`trigger.yaml`](./trigger.yaml) manifest in the [deployment](#deployment)
|
||||
section above.
|
||||
|
||||
1. We need to wait for the downstream pods to get started and receive our event,
|
||||
wait 60 seconds.
|
||||
|
|
Loading…
Reference in New Issue