PLEASE CONSIDER USING ALTERNATIVE WAYS OF CREATING YOUR KEPTN INTEGRATION.
There are more ways to integrate with your service that don't require creating a service from this template, see https://keptn.sh/docs/0.17.x/integrations/how_integrate/ for more details.
Examples:
- Webhooks: https://keptn.sh/docs/0.17.x/integrations/webhooks/
- Job-Executor-Service: https://github.com/keptn-sandbox/job-executor-service
In addition, creating your own integration based on the service-template has been reduced to just using Keptn's go-utils and is based on the example provided in go-utils.
This is a Keptn Service Template written in GoLang. Follow the instructions below for writing your own Keptn integration.
Quick start:
- In case you want to contribute your service to keptn-sandbox or keptn-contrib, make sure you have read and understood the Contributing Guidelines.
- Click Use this template on top of the repository, or download the repo as a zip-file, extract it into a new folder named after the service you want to create (e.g., simple-service)
- Required: Run GitHub workflow
One-time repository initialization
to tailor deployment files and go modules to the new instance of the keptn service template. This will create a Pull Request containing the necessary changes, review it, adjust if necessary and merge it. - Figure out whether your Kubernetes Deployment requires any RBAC rules or a different service-account, and adapt chart/templates/serviceaccount.yaml accordingly for the roles.
- Last but not least: Remove this intro within the README file and make sure the README file properly states what this repository is about
This implements a keptn-service-template-go for Keptn. If you want to learn more about Keptn visit us on keptn.sh
Please fill in your versions accordingly
Keptn Version* | Keptn-service-template-go version |
---|---|
0.13.x | 0.13.0 |
0.14.x | 0.14.0 |
0.17.x | 0.17.0 |
* This is the Keptn version we aim to be compatible with. Other versions should work too, but there is no guarantee.
Note: Versions compatible with Keptn 0.14.x and newer are not backward compatible due to a change in NATS cluster name (see https://github.com/keptn/keptn/releases/tag/0.14.1 for more info about the breaking change).
The keptn-service-template-go can be installed as a part of Keptn's uniform.
To deploy the current version of the keptn-service-template-go in your Keptn Kubernetes cluster use the helm chart
file,
for example:
helm install -n keptn keptn-service-template-go chart/
This should install the keptn-service-template-go
into the keptn
namespace, which you can verify using
kubectl -n keptn get deployment keptn-service-template-go -o wide
kubectl -n keptn get pods -l run=keptn-service-template-go
Adapt and use the following command in case you want to up- or downgrade your installed version (specified by the $VERSION
placeholder):
helm upgrade -n keptn --set image.tag=$VERSION keptn-service-template-go chart/
To delete a deployed keptn-service-template-go, use the file deploy/*.yaml
files from this repository and delete the Kubernetes resources:
helm uninstall -n keptn keptn-service-template-go
Development can be conducted using any GoLang compatible IDE/editor (e.g., Jetbrains GoLand, VSCode with Go plugins).
It is recommended to make use of branches as follows:
main
/master
contains the latest potentially unstable version- releases are handled via git tags (and GitHub releases)
- create a new branch for any changes that you are working on, e.g.,
feature/my-cool-stuff
orbug/overflow
- once ready, create a pull request from your branch back to the
main
/master
branch
When writing code, it is recommended to follow the coding style suggested by the Golang community.
Please read the documentation provided by Keptn/go-utils, as it explains how to integrate with Keptn.
To better understand all variants of Keptn CloudEvents, please look at the Keptn Spec.
If you want to look at handler implementations, you can take a look at the go-utils based example, as well as the concrete implementations within the handler/ folder, e.g.:
- Build the binary:
go build -ldflags '-linkmode=external' -v -o keptn-service-template-go
- Run tests:
go test -race -v ./...
- Build the docker image:
docker build . -t keptn-sandbox/keptn-service-template-go:dev
(Note: Ensure that you use the correct DockerHub account/organization) - Run the docker image locally:
docker run --rm -it -p 8080:8080 keptn-sandbox/keptn-service-template-go:dev
- Push the docker image to DockerHub:
docker push keptn-sandbox/keptn-service-template-go:dev
(Note: Ensure that you use the correct DockerHub account/organization) - Get logs using
kubectl
:kubectl -n keptn logs deployment/keptn-service-template-go -f
- Watch the deployed pods using
kubectl
:kubectl -n keptn get pods -l run=keptn-service-template-go
- Deploy the service using Skaffold:
skaffold run --default-repo=your-docker-registry --tail
(Note: Replaceyour-docker-registry
with your container image registry (defaults to ghcr.io/keptn-sandbox/keptn-service-template-go); also make sure to adapt the image name in skaffold.yaml)
We have dummy cloud-events in the form of RFC 2616 requests in the test-events/ directory. These can be easily executed using third party plugins such as the Huachao Mao REST Client in VS Code.
This repo uses reviewdog for automated reviews of Pull Requests.
You can find the details in .github/workflows/reviewdog.yml.
This repo has automated unit tests for pull requests.
You can find the details in .github/workflows/CI.yml.
This repo uses GH Actions and Workflows to test the code and automatically build containers and upload it to ghcr.io
.
It is assumed that the current development takes place in the main
/master
branch (either via Pull Requests or directly).
Once you're ready, go to the Actions tab on GitHub, select Pre-Release or Release, and run the action.
Please find more information in the LICENSE file.