Skip to content

Commit

Permalink
Update readme and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Daishan committed Jun 10, 2021
1 parent dbd9fdf commit 4ba8493
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 115 deletions.
78 changes: 3 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ spec:
git:
branch: master
repo: https://github.com/StrongMonkey/gitjob-example
provider: polling
jobSpec:
template:
spec:
Expand Down Expand Up @@ -122,7 +121,6 @@ spec:
git:
branch: master
repo: [email protected]:StrongMonkey/priv-repo.git
provider: polling
gitSecretName: ssh-key-secret
gitHostName: github.com
jobSpec:
Expand All @@ -144,7 +142,7 @@ spec:

### Webhook

gitjob can be configured to use webhook to receive git event. This currently supports Github. More providers will be added later.
gitjob can be configured to use webhook to receive git event. This currently supports Github, GitLab, Bitbucket, Bitbucket Server and Gogs.

1. Create a gitjob that is configured with webhook.

Expand All @@ -158,9 +156,6 @@ spec:
git:
branch: master
repo: https://github.com/StrongMonkey/gitjob-example
provider: github
github:
token: randomtoken
jobSpec:
template:
spec:
Expand All @@ -178,8 +173,6 @@ spec:
workingDir: /workspace/source
```

Note: you can configure a secret token so that webhook server will validate the request and filter requests that are only coming from Github.

2. Create an ingress that allows traffic.

```yaml
Expand All @@ -193,7 +186,7 @@ spec:
- host: your.domain.com
http:
paths:
- path: /hooks
- path: /
pathType: Prefix
backend:
serviceName: gitjob
Expand All @@ -202,77 +195,12 @@ spec:

Note: To configure a HTTPS receiver, make sure you have proper TLS configuration on your ingress

3. Create a Github webhook that sends payload to `http://your.domain.com/hooks?gitjobId=default:example-webhook`.
3. Create Your webhook that sends payload to `http://your.domain.com/`.

![webhook](/webhook.png)

You can choose which event to send when creating the webhook. Gitjob currently supports push and pull-request event.

#### Auto-Configuring github webhook

GitJob will create webhook for you if you have proper setting created

1. Create a configmap in kube-system namespace

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: github-setting
namespace: kube-system
data:
WebhookURL: https://webhook.example.com #This will be your webhook callback URL
SecretName: githubtoken
```

2. Create a secret that contains your github access token

```bash
kubectl create secret generic -n kube-system githubtoken --from-literal=token=$ACCESS_TOKEN
```

3. Create a gitjob CR and set provider to github

```yaml
apiVersion: gitjob.cattle.io/v1
kind: GitJob
metadata:
name: example-webhook
namespace: default
spec:
git:
branch: master
repo: https://github.com/StrongMonkey/gitjob-example
provider: github
jobSpec:
...
```

GitJob controller will automatically create webhook with callback URL `https://webhook.example.com?gitjobId=default:example-webhook` based on the global setting. At this time it doesn't delete webhook if CR is deleted from cluster, so make sure to clean up webhook if not used.

4. Setup ingress and TLS to allow traffic to go into GitJob controller so that it can start receiving events.

```yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: webhook-ingress
namespace: gitjob
spec:
rules:
- host: webhook.example.com
http:
paths:
- pathType: Prefix
backend:
serviceName: gitjob
servicePort: 80
tls:
- hosts:
- webhook.example.com
secretName: testsecret-tls
```

### API reference

API types are defined in [here](./pkg/apis/gitjob.cattle.io/v1/types.go)
Expand Down
1 change: 0 additions & 1 deletion example/gitjob-private-repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ spec:
git:
branch: master
repo: [email protected]:StrongMonkey/priv-repo.git
provider: polling
clientSecretName: ssh-key-secret
jobSpec:
template:
Expand Down
1 change: 0 additions & 1 deletion example/gitjob-termination.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ spec:
git:
branch: master
repo: https://github.com/StrongMonkey/gitjobs-example
provider: polling
jobSpec:
backoffLimit: 1
template:
Expand Down
33 changes: 0 additions & 33 deletions example/gitjob-webhook-auto.yaml

This file was deleted.

5 changes: 1 addition & 4 deletions example/gitjob-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ spec:
git:
branch: master
repo: https://github.com/StrongMonkey/gitjobs-example
provider: github
github:
token: randomtoken
jobSpec:
template:
spec:
Expand All @@ -37,7 +34,7 @@ spec:
- host: daishan.do.rancher.space
http:
paths:
- path: /hooks
- path: /
pathType: Prefix
backend:
serviceName: gitjob
Expand Down
1 change: 0 additions & 1 deletion example/gitjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ spec:
git:
branch: master
repo: https://github.com/StrongMonkey/gitjobs-example
provider: polling
jobSpec:
template:
spec:
Expand Down

0 comments on commit 4ba8493

Please sign in to comment.