Add guide for openshift webhook
As we now have working triggers for openshift webhooks, let's document it. Signed-off-by: Michal Konecny <mkonecny@redhat.com>
This commit is contained in:
parent
ac455983be
commit
ce32b6799e
2 changed files with 94 additions and 0 deletions
93
modules/ROOT/pages/webhook_openshift.adoc
Normal file
93
modules/ROOT/pages/webhook_openshift.adoc
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
= Webhook for build trigger in Fedora OpenShift
|
||||
|
||||
== Purpose
|
||||
|
||||
This document explains how to setup an automatic build trigger for OpenShift deployment from
|
||||
Forgejo instance.
|
||||
|
||||
== Setting up the OpenShift trigger
|
||||
|
||||
. Request a new secret for your project from Fedora Infrastructure. Open a ticket on
|
||||
https://forge.fedoraproject.org/infra/tickets/issues and request a secret
|
||||
for your OpenShift project for both staging and/or production.
|
||||
|
||||
. Add this secret to secret file in your OpenShift project. The secret file could look like this:
|
||||
+
|
||||
....
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: generic-webhook-secret
|
||||
data:
|
||||
WebHookSecretKey: "{{ (env == 'production')|ternary(<project>_prod_generic_secret, <project>_stg_generic_secret) | b64encode }}"
|
||||
type: Opaque
|
||||
....
|
||||
|
||||
. Add generic build trigger to `buildconfig` file.
|
||||
+
|
||||
....
|
||||
triggers:
|
||||
- type: Generic
|
||||
generic:
|
||||
secretReference:
|
||||
name: generic-webhook-secret
|
||||
....
|
||||
|
||||
== Obtain webhook URL
|
||||
|
||||
. Install the OpenShift client from OKD tools. See
|
||||
link:https://docs.okd.io/latest/cli_reference/openshift_cli/getting-started-cli.html#cli-getting-started[Kubernetes documentation].
|
||||
|
||||
. Login to OpenShift instance you want to work with (
|
||||
link:https://console-openshift-console.apps.ocp.fedoraproject.org/[production] or
|
||||
link:https://console-openshift-console.apps.ocp.stg.fedoraproject.org/[staging]) and copy the
|
||||
login command (you can find it under your profile in top right corner)
|
||||
|
||||
. Login using the `oc` tool.
|
||||
+
|
||||
....
|
||||
oc login --token=XXX --server=https://api.ocp.[stg.]fedoraproject.org:6443
|
||||
....
|
||||
|
||||
. Switch to your project
|
||||
+
|
||||
....
|
||||
oc project <project>
|
||||
....
|
||||
|
||||
. Get the webhook url from the buildconfig
|
||||
+
|
||||
....
|
||||
oc describe bc
|
||||
....
|
||||
+
|
||||
And look for the Webhook Generic section, where you will find the URL.
|
||||
|
||||
. Obtain the secret to fill in to URL.
|
||||
+
|
||||
....
|
||||
oc get secret generic-webhook-secret -o jsonpath='{.data.WebHookSecretKey}' | base64 -d
|
||||
....
|
||||
|
||||
Now you should have everything to construct the URL for webhook.
|
||||
|
||||
== Add webhook to Forgejo project
|
||||
|
||||
. Go to project `Settings` and `Webhooks`
|
||||
|
||||
. Add webhook and choose Forgejo
|
||||
|
||||
. Fill in the webhook
|
||||
+
|
||||
....
|
||||
Target URL: https://api.ocp.fedoraproject.org:6443/apis/build.openshift.io/v1/namespaces/poddlers/buildconfigs/toddlers/webhooks/<secret>/generic
|
||||
HTTP method: POST
|
||||
Post content type: application/json
|
||||
Secret:
|
||||
Trigger on: Push events
|
||||
Branch filter: <branch you want to trigger the build from>
|
||||
Authorization header:
|
||||
....
|
||||
|
||||
Now the trigger should work everytime you push in the selected branch.
|
||||
Loading…
Add table
Add a link
Reference in a new issue