Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Commit 5c2de23

Browse files
Update README and manifests
1 parent 8c8ebe5 commit 5c2de23

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

README.md

+19-4
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,32 @@ label matching the repo name and are in a namespace matching the branch name.
88
If there are no other objects with the given label key in the namespace, it also
99
deletes the namespace and all remaining objects.
1010

11+
### PushEvent
12+
On push events, k8s-webhook-handler will checkout `.ci/workflow.yaml` from the
13+
repo the push was and submit it to the k8s api with the following annotations
14+
added:
15+
16+
- `k8s-webhook-handler.io/ref`: event.Ref
17+
- `k8s-webhook-handler.io/revision`: event.HeadCommit.ID
18+
- `k8s-webhook-handler.io/repo_name`: event.Repo.FullName
19+
- `k8s-webhook-handler.io/repo_url`: event.Repo.GitURL
20+
- `k8s-webhook-handler.io/repo_ssh`: event.Repo.SSHURL
21+
1122
## Binaries
1223
- cmd/webhook is the actual webhook handling server
1324
- cmd/reconciler iterates over all k8s namespaces and deletes all objects that
1425
are labeled for which there is no remote branch anymore.
1526

1627
## Usage
1728
Currently only github delete webhooks in json format are supported.
18-
Beside the manifests and templates in `deploy/`, a secret 'k8s-ci' with
19-
`GITHUB_SECRET` is expected. The value should match the "Secret" field in the
20-
GitHub webhook settings and can be created like this:
29+
Beside the manifests and templates in `deploy/`, a secret 'webhook-handler' with
30+
the following fields is expected:
31+
32+
- `GITHUB_TOKEN` Personal Access Token for API access
33+
- `WEBHOOK_SECRET` Secret for validating the webhook
34+
35+
The value should match the "Secret" field in the GitHub webhook settings and can be created like this:
2136

2237
```
23-
kubectl create secret generic k8s-ci --from-literal=GITHUB_SECRET=github-secret
38+
kubectl create secret generic k8s-ci --from-literal=GITHUB_SECRET=github-secret ...
2439
```

deploy/deployment.yaml

+8-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
labels:
55
k8s-app: k8s-webhook-handler
66
name: k8s-webhook-handler
7+
namespace: ci
78
spec:
89
selector:
910
matchLabels:
@@ -15,25 +16,20 @@ spec:
1516
name: k8s-webhook-handler
1617
spec:
1718
serviceAccountName: k8s-webhook-handler
18-
imagePullSecrets:
19-
- name: private-registry
2019
containers:
2120
- name: k8s-webhook-handler
22-
image: itskoko/k8s-webhook-handler
23-
command:
24-
- /bin/sh
25-
- -c
26-
- exec webhook -statsd.address $HOST_IP:8125
21+
image: itskoko/k8s-webhook-handler:v0.1.0
2722
env:
28-
- name: HOST_IP
29-
valueFrom:
30-
fieldRef:
31-
fieldPath: status.hostIP
3223
- name: WEBHOOK_SECRET
3324
valueFrom:
3425
secretKeyRef:
35-
name: k8s-ci
26+
name: webhook-handler
3627
key: WEBHOOK_SECRET
28+
- name: GITHUB_TOKEN
29+
valueFrom:
30+
secretKeyRef:
31+
name: webhook-handler
32+
key: GITHUB_TOKEN
3733
ports:
3834
- containerPort: 8080
3935
name: http

0 commit comments

Comments
 (0)