In this final part, we’ll explore how to set up and integrate the created golang pipeline using GitHub and GitHub webhooks with Tekton pipelines running on GCP.
A simple GoLang project has been created, comprising a basic health endpoint for system monitoring especially for kubernetes probes. Its primary functionality centers on a sum function, which accepts two input parameters and communicates the result back to the client via RESTful API. The project also includes thorough testing to guarantee its sum function is working as expected.
The app is available under https://github.com/c-linse/go-add-app.
1 Setting up GitHub webhook
To set up a GitHub webhook for triggering Tekton pipelines, follow these steps:
Copy the external IP address of the Tekton event listener service. Using the following command:
$ kubectl get svc
In the GitHub repository settings, navigate to Webhooks and add a new webhook. Set the payload URL to `http://<EXTERNAL_IP>:<PORT>/`, replacing `<EXTERNAL_IP>` with the Tekton event listener external IP and `<PORT>` with the port configured for the Tekton event listener service.
Note: In an enterprise environment, it is of course important to use an ingress controller with a valid server certificate!
2 Testing pipeline execution happy path
Git commit on feature branch
Lets create a feature branch and trigger the pipeline.
$ git fetch origin $ git checkout main $ git checkout -b feature/division $ git push --set-upstream origin feature/division
We see already that the build has been started, indicated by the orange circle. We can monitor the pipeline execution via the Tekton dashboard to ensure the pipeline triggers and completes successfully.
This can be done by simple clicking on the orange circle and by clicking on «details».
We can see that the build only contains the lint, test and go build job, showcasing that the strategy for feature branches works just fine.
Git commit on main branch
Similarly on the main branch we can for example merge a pull request which has been reviewed and can be merged.
After merging we can observe in the details that the job contains the whole chain from linting, testing, building, to creating container images,
helm packages and the deploy step to a dev stage. After only 2 minutes we got the whole cycle executed.
Creating a git tag
Finally we can create a Git tag to trigger the pipeline for creating releases or deploying specific versions of the application.
$ git fetch origin $ git checkout$ git tag -a -m "Description of the tag" $ git push origin
When we monitor the pipeline execution, we can see that we deploy this time to the qa namespace instead of the dev namespace, since the qa namespaces
deserves a higher quality level. This staging principle could be extended to a different level, f.e. when working with release candidates.
4 Verifying artifact availability
As the pipeline turns green for building and pushing the container image and the helm package lets observe if thats
really the case.
Checking container image availability
After pipeline execution, verify the availability of the container image
$ podman pull quay.io/christoph_linse/go-add-app
Of course, since this registry is accisble only after authentication, ensure to be logged in.
$ podman login quay.io/christoph_linse
Checking helm repository publication
Check if the Helm repository has been published
$ helm repo add tekton-course-charts https://c-linse.github.io/tekton-course-charts $ helm repo update $ helm search repo tekton-course-charts
We should see that the helm chart has been published successfully.
Note: This helm repository is served via github pages, since it is really fast to setup and easy to use. That makes it
simple to showcase helm in demo like this. To know more about github pages check this link.
A helm repository contains basically the index.yaml with a list of packaged helm charts as leveraged in the custom
helm chart task.
5 Verifying continuous deployment
We would be able now to deploy this helm chart as any other to the kubernetes cluster to see if our app is working as
supposed to. Fortunately we have the continues deployment step developed, so we can check the status of this app.
A brief look to into the cluster itself shows that we have indeed the golang app running in the dev namespace.
$ kubectl get deployments
6 Conclusion
In conclusion, we’ve established a streamlined Go development pipeline leveraging GitProject and WebHooks. Our pipeline
exhibits enterprise-grade functionality by incorporating reusable tasks from Tekton Hub and customizing tasks to suit
project requirements. With an agnostic approach, our pipeline can be easily adapted for other Go projects, providing
flexibility and total control over the development and deployment process.
By following the steps outlined in this article, you can elevate your Go development workflows, enhance collaboration,
and accelerate project delivery while maintaining reliability and flexibility. Streamline your development journey
today with GitProject and WebHooks!