This topic describes how to use Knative to manage GitHub events.
Prerequisites
- Knative Serving, Knative Eventing, and the GitHub add-on are deployed in the Container Service for Kubernetes (ACK) cluster. For more information, see Deploy a Knative component.
- A custom domain name is configured in Knative. For more information, see Set a custom domain name for Knative Serving.
Step 1: Create a Knative Service
For more information, see Create a Knative Service.
Step 2: Create a GitHub token
Step 3: Create a GitHub event source
You can create a GitHub event source to receive events generated by GitHub.
Result
Note The domain name must have an Internet Content Provider (ICP) number. Otherwise, the
domain name is inaccessible.
Run the following command in the GitHub repository to create a
pull request
. Then, an event is triggered. kubectl --namespace default get pods
kubectl --namespace default logs github-event-display-XXXX user-container
In Knative Eventing, you can view event details that are similar to the following
content:
2018/11/08 18:25:34 Message Dumper received a message: POST / HTTP/1.1
Host: github-event-display.knative-demo.svc.cluster.local
Accept-Encoding: gzip
Ce-Cloudeventsversion: 0.1
Ce-Eventid: a8d4cf20-e383-11e8-8069-46e3c8ad****
Ce-Eventtime: 2018-11-08T18:25:32.819548012Z
Ce-Eventtype: dev.knative.source.github.pull_request
Ce-Source: https://github.com/someuser/somerepo/pull/1
Content-Length: 21060
Content-Type: application/json
User-Agent: Go-http-client/1.1
X-B3-Parentspanid: b2e514c3dbe94c03
X-B3-Sampled: 1
X-B3-Spanid: c85e346d89c8be4e
X-B3-Traceid: abf6292d458fb8e7
X-Envoy-Expected-Rq-Timeout-Ms: 60000
X-Envoy-Internal: true
X-Forwarded-For: 12*.*.*.*, 12*.*.*.*
X-Forwarded-Proto: http
X-Request-Id: 8a2201af-5075-9447-b593-ec3a243a****
{"action":"opened","number":1,"pull_request": ...}