mirror of https://github.com/knative/docs.git
Simplify the Github sample. (#587)
* Simplify the Github sample. This simplifies the Github sample as outlined in #586 to drop the concepts that aren't needed for the sample to work end-to-end. Fixes: https://github.com/knative/docs/issues/586 Fixes: https://github.com/knative/docs/issues/584 Fixes: https://github.com/knative/docs/issues/552 Fixes: https://github.com/knative/docs/issues/551 Progress on: https://github.com/knative/docs/issues/541 * Update eventing/samples/github-source/README.md Co-Authored-By: mattmoor <mattmoor@google.com>
This commit is contained in:
parent
b11a0d4de3
commit
cadea5ebe1
|
@ -21,13 +21,32 @@ You will need:
|
|||
Eventing](https://github.com/knative/docs/tree/master/eventing). Those
|
||||
instructions also install the default eventing sources, including
|
||||
the `GitHubSource` we'll use.
|
||||
1. Create a `Channel`. You can use your own `Channel` or use the
|
||||
provided sample, which creates a channel called `githubchannel`. If
|
||||
you use your own `Channel` with a different name, then you will
|
||||
need to alter other commands later.
|
||||
|
||||
### Create a Knative Service
|
||||
|
||||
To verify the `GitHubSource` is working, we will create a simple Knative
|
||||
`Service` that dumps incoming messages to its log. The `service.yaml` file
|
||||
defines this basic service.
|
||||
|
||||
```yaml
|
||||
apiVersion: serving.knative.dev/v1alpha1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: github-message-dumper
|
||||
spec:
|
||||
runLatest:
|
||||
configuration:
|
||||
revisionTemplate:
|
||||
spec:
|
||||
container:
|
||||
image: gcr.io/knative-releases/github.com/knative/eventing-sources/cmd/message_dumper
|
||||
```
|
||||
|
||||
Enter the following command to create the service from `service.yaml`:
|
||||
|
||||
|
||||
```shell
|
||||
kubectl --namespace default apply --filename eventing/samples/github-source/channel.yaml
|
||||
kubectl --namespace default apply --filename eventing/samples/github-source/service.yaml
|
||||
```
|
||||
|
||||
### Create GitHub Tokens
|
||||
|
@ -49,9 +68,8 @@ recommended scopes:
|
|||

|
||||
|
||||
Update `githubsecret.yaml` with those values. If your generated access
|
||||
token is `'asdfasfdsaf'` and you choose your *secretToken* as
|
||||
`'personal_access_token_value'`, you'd modify `githubsecret.yaml` like
|
||||
so:
|
||||
token is `'personal_access_token_value'` and you choose your *secretToken*
|
||||
as `'asdfasfdsaf'`, you'd modify `githubsecret.yaml` like so:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
|
@ -60,11 +78,11 @@ metadata:
|
|||
name: githubsecret
|
||||
type: Opaque
|
||||
stringData:
|
||||
accessToken: asdfasfdsaf
|
||||
secretToken: personal_access_token_value
|
||||
accessToken: personal_access_token_value
|
||||
secretToken: asdfasfdsaf
|
||||
```
|
||||
|
||||
Hint: you can makeup a random *accessToken* with:
|
||||
Hint: you can makeup a random *secretToken* with:
|
||||
|
||||
```shell
|
||||
head -c 8 /dev/urandom | base64
|
||||
|
@ -81,8 +99,7 @@ kubectl --namespace default apply --filename eventing/samples/github-source/gith
|
|||
In order to receive GitHub events, you have to create a concrete Event
|
||||
Source for a specific namespace. Be sure to replace the
|
||||
`ownerAndRepository` value with a valid GitHub public repository owned
|
||||
by your GitHub user. If you are using a different `Secret` name or
|
||||
`Channel`, modify the yaml accordingly.
|
||||
by your GitHub user.
|
||||
|
||||
```yaml
|
||||
apiVersion: sources.eventing.knative.dev/v1alpha1
|
||||
|
@ -102,9 +119,9 @@ spec:
|
|||
name: githubsecret
|
||||
key: secretToken
|
||||
sink:
|
||||
apiVersion: eventing.knative.dev/v1alpha1
|
||||
kind: Channel
|
||||
name: githubchannel
|
||||
apiVersion: serving.knative.dev/v1alpha1
|
||||
kind: Service
|
||||
name: github-message-dumper
|
||||
|
||||
```
|
||||
|
||||
|
@ -114,62 +131,6 @@ Then, apply that yaml using `kubectl`:
|
|||
kubectl --namespace default apply --filename eventing/samples/github-source/github-source.yaml
|
||||
```
|
||||
|
||||
### Subscription
|
||||
|
||||
To verify the `GitHubSource` is fully working, create a simple Knative
|
||||
`Service` that dumps incoming messages to its log and create a
|
||||
`Subscription` from the `Channel` to that Knative `Service`.
|
||||
|
||||
If the deployed `GitHubEventSource` is pointing at a `Channel` other
|
||||
than `githubchannel`, modify `subscription.yaml` by replacing
|
||||
`githubchannel` with that `Channel`'s name.
|
||||
|
||||
```yaml
|
||||
apiVersion: eventing.knative.dev/v1alpha1
|
||||
kind: Subscription
|
||||
metadata:
|
||||
name: github-source-sample
|
||||
namespace: knative-demo
|
||||
spec:
|
||||
channel:
|
||||
apiVersion: eventing.knative.dev/v1alpha1
|
||||
kind: Channel
|
||||
name: githubchannel
|
||||
subscriber:
|
||||
ref:
|
||||
apiVersion: serving.knative.dev/v1alpha1
|
||||
kind: Service
|
||||
name: github-message-dumper
|
||||
|
||||
---
|
||||
# This is a very simple Knative Service that writes the input request to its log.
|
||||
|
||||
apiVersion: serving.knative.dev/v1alpha1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: github-message-dumper
|
||||
namespace: knative-demo
|
||||
spec:
|
||||
runLatest:
|
||||
configuration:
|
||||
revisionTemplate:
|
||||
spec:
|
||||
container:
|
||||
image: github.com/knative/eventing-sources/cmd/message_dumper
|
||||
|
||||
```
|
||||
|
||||
Then, deploy `subscription.yaml`, creating both the `Service` and
|
||||
`Subscription`.
|
||||
|
||||
```shell
|
||||
ko apply --filename eventing/samples/github-source/subscription.yaml
|
||||
```
|
||||
|
||||
### Create Events
|
||||
|
||||
Create a Pull Request in your GitHub repository.
|
||||
|
||||
### Verify
|
||||
|
||||
Verify the GitHub webhook was created by looking at the list of
|
||||
|
@ -179,10 +140,12 @@ check mark to the left of the hook URL, as shown below.
|
|||
|
||||

|
||||
|
||||
We will verify that the GitHub events were sent into the Knative
|
||||
eventing system by looking at our message dumper function logs. If you
|
||||
deployed the [Subscription](#subscription), then continue using this
|
||||
section. If not, then you will need to look downstream yourself.
|
||||
### Create Events
|
||||
|
||||
Create a pull request in your GitHub repository. We will verify
|
||||
that the GitHub events were sent into the Knative eventing system
|
||||
by looking at our message dumper function logs.
|
||||
|
||||
|
||||
```shell
|
||||
kubectl --namespace default get pods
|
||||
|
@ -215,3 +178,19 @@ X-Request-Id: 8a2201af-5075-9447-b593-ec3a243aff52
|
|||
|
||||
{"action":"opened","number":1,"pull_request": ...}
|
||||
```
|
||||
|
||||
### Cleanup
|
||||
|
||||
You can remove the Github webhook by deleting the Github source:
|
||||
|
||||
```shell
|
||||
kubectl --namespace default delete --filename eventing/samples/github-source/github-source.yaml
|
||||
```
|
||||
|
||||
Similarly, you can remove the Service and Secret via:
|
||||
|
||||
```shell
|
||||
kubectl --namespace default delete --filename eventing/samples/github-source/service.yaml
|
||||
kubectl --namespace default delete --filename eventing/samples/github-source/githubsecret.yaml
|
||||
|
||||
```
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
apiVersion: eventing.knative.dev/v1alpha1
|
||||
kind: Channel
|
||||
metadata:
|
||||
name: githubchannel
|
||||
spec:
|
||||
provisioner:
|
||||
apiVersion: eventing.knative.dev/v1alpha1
|
||||
kind: ClusterChannelProvisioner
|
||||
name: in-memory-channel
|
|
@ -15,6 +15,6 @@ spec:
|
|||
name: githubsecret
|
||||
key: secretToken
|
||||
sink:
|
||||
apiVersion: eventing.knative.dev/v1alpha1
|
||||
kind: Channel
|
||||
name: githubchannel
|
||||
apiVersion: serving.knative.dev/v1alpha1
|
||||
kind: Service
|
||||
name: github-message-dumper
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
# This is a very simple Knative Service that writes the input request to its log.
|
||||
apiVersion: serving.knative.dev/v1alpha1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: github-message-dumper
|
||||
spec:
|
||||
runLatest:
|
||||
configuration:
|
||||
revisionTemplate:
|
||||
spec:
|
||||
container:
|
||||
image: gcr.io/knative-releases/github.com/knative/eventing-sources/cmd/message_dumper
|
|
@ -1,31 +0,0 @@
|
|||
apiVersion: eventing.knative.dev/v1alpha1
|
||||
kind: Subscription
|
||||
metadata:
|
||||
name: github-source-sample
|
||||
namespace: knative-demo
|
||||
spec:
|
||||
channel:
|
||||
apiVersion: eventing.knative.dev/v1alpha1
|
||||
kind: Channel
|
||||
name: githubchannel
|
||||
subscriber:
|
||||
ref:
|
||||
apiVersion: serving.knative.dev/v1alpha1
|
||||
kind: Service
|
||||
name: github-message-dumper
|
||||
|
||||
---
|
||||
# This is a very simple Knative Service that writes the input request to its log.
|
||||
|
||||
apiVersion: serving.knative.dev/v1alpha1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: github-message-dumper
|
||||
namespace: knative-demo
|
||||
spec:
|
||||
runLatest:
|
||||
configuration:
|
||||
revisionTemplate:
|
||||
spec:
|
||||
container:
|
||||
image: github.com/knative/eventing-sources/cmd/message_dumper
|
Loading…
Reference in New Issue