boomerang-io / flow.service.handler

The Boomerang Flow Tekton Handler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Boomerang Handler Service

This service handles and translates the Events from Workflow Service that go to TektonCD (Kubernetes). This is used by Boomerang CICD and Boomerang Flow.

It uses the Fabric8 Kubernetes Java Client to interact with Kubernetes along with the Tekton extension to interact with the Tekton TaskRuns. When writing new controller integrations, it is recommended to look through the Kubernetes Client Docs to find the exact Client method to use and then look at the API code to see how it works for advance configurations such as the Watcher API.

Development

When running the service locally you need access to a kubernetes API endpoint. This service is set up to use whatever the kubeconfig is pointing to.

RBAC

The controller needs to run with special Kubernetes RBAC. Please see the helm charts rbac-role-controller.yaml to see more about whats needed.

Verification

kubectl auth can-i create taskruns --as=system:serviceaccount:bmrg-dev:bmrg-flow-controller

References

Fabric8 Kubernetes Java Client

Kubernetes ConfigMap

We currently use projected volumes however subpath was considered.

[Deprecated] Kubernetes Java Client

Stash

Container States

When monitoring the Job/Pod/Container there are additional error states in the waiting status that need to be accounted for

Lifecycle Container Hooks

The following code was written to interface with the container lifecycle hooks of postStart and preStop however there were two main issues:

  1. no guarantee that postStart would execute before the main container code -> we went with an initContainer
  2. preStop was not executing on jobs when the pod didn't get sent a SIG as it completed successfully so was technically never terminated.
V1Lifecycle lifecycle = new V1Lifecycle();
V1Handler postStartHandler = new V1Handler();
V1ExecAction postStartExec = new V1ExecAction();
postStartExec.addCommandItem("/bin/sh");
postStartExec.addCommandItem("-c");
postStartExec.addCommandItem("touch /lifecycle/lock");
postStartHandler.setExec(postStartExec);
lifecycle.setPostStart(postStartHandler);
V1Handler preStopHandler = new V1Handler();
V1ExecAction preStopExec = new V1ExecAction();
preStopExec.addCommandItem("/bin/sh");
preStopExec.addCommandItem("-c");
preStopExec.addCommandItem("rm -f /lifecycle/lock");
preStopHandler.setExec(preStopExec);
lifecycle.setPreStop(preStopHandler);
container.lifecycle(lifecycle);

Sidecars

Output Properties

Process Namespace Sharing

About

The Boomerang Flow Tekton Handler


Languages

Language:Java 99.7%Language:Dockerfile 0.3%