Configure S2I and B2I Webhooks
This tutorial demonstrates how to configure S2I and B2I webhooks.
- You need to enable the KubeSphere DevOps System.
- You need to create a workspace, a project () and a user (
project-regular
). The user must be invited to the project with the role ofoperator
. For more information, see .
Log in to the KubeSphere web console as . Click Platform in the upper-left corner and then select Cluster Management.
In Services under Application Workloads, select kubesphere-devops-system from the drop-down list and click s2ioperator-trigger-service to go to its details page.
Click More and select Edit External Access.
In the displayed dialog box, select NodePort from the drop-down list for Access Method and then click OK.
Note
This tutorial selects NodePort for demonstration purposes. You can also select LoadBalancer based on your needs.
Step 2: Configure an S2I webhook
Log out of KubeSphere and log back in as
project-regular
. Go todemo-project
.In Image Builders, click the S2I Image Builder to go to its details page.
Log in to your GitHub account and go to the source code repository used for the S2I Image Builder. Go to Webhooks under Settings and then click Add webhook.
In Payload URL, enter
http://<IP>:<Service NodePort>/s2itrigger/v1alpha1/general/namespaces/demo-project/s2ibuilders/felixnoo-s2i-sample-latest-zhd/
. You can select trigger events based on your needs and then click Add webhook. This tutorial selects Just the push event for demonstration purposes.Note
<IP>
is your own IP address, is the NodePort you get in step 1, and/s2itrigger/v1alpha1/general/namespaces/demo-project/s2ibuilders/felixnoo-s2i-sample-latest-zhd/
is from the S2I remote trigger link. Make sure you use your own IP, Service NodePort and S2I remote trigger link. You may also need to configure necessary port forwarding rules and open the port in your security groups depending on where your Kubernetes cluster is deployed.After you finish all the above operations, the S2I image builder will be automatically triggered if there is a push event to the source code repository.
You can follow the same steps to configure a B2I webhook.
Expose the S2I trigger Service.
View the Remote Trigger on the details page of your B2I image builder.
Add the payload URL in the source code repository. The B2I payload URL format is the same as that of S2I payload URL.
Note
You may need to configure necessary port forwarding rules and open the port in your security groups depending on where your Kubernetes cluster is deployed.