Skip to content

roshbhatia/kubanana

Repository files navigation

kubanana

Kubanana

THIS PROJECT IS NOT YET PRODUCTION READY AND IS SUBJECT TO BREAKING CHANGES

Kubanana is a Kubernetes controller that allows you to trigger a Kubernetes Job based on a Kubernetes event or status (eventually, any generic event sent to the Kubanana webhook).

This project is inspired by policy engines like Kyverno and operators like Metacontroller which allow for flexible controller-like logic as versioned Kubernetes resources.

This tool, however, is solely used to trigger a Job when an event happens in an opinionated fashion. Kyverno and Metacontroller can be used for similar purposes but are significantly heavier dependencies.

Using Kubanana: the EventTriggeredJob

Kubanana introduces the EventTriggeredJob CRD to help associate Jobs with events:

apiVersion: kubanana.roshanbhatia.com/v1alpha1
kind: EventTriggeredJob
metadata:
  name: example-job-template
spec:
  eventSelector:
    resourceKind: "Pod"
    namePattern: "web-*"
    namespacePattern: "prod-*"
    labelSelector:
      matchLabels:
        app: myapp
    eventTypes: ["CREATE", "DELETE"]
  statusSelector:
    resourceKind: "Pod"
    namePattern: "*"
    namespacePattern: "default"
    labelSelector:
      matchLabels:
        app: myapp
    conditions:
    - type: "Ready"
      status: "True"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox
            command: ["echo", "Hello from Kubanana!"]
          restartPolicy: Never

This CRD allows you to define:

  • Which resources to watch (by kind, name pattern, namespace pattern, labels)
  • Which event types should trigger a job (CREATE, UPDATE, DELETE)
  • The job template to execute when an event is triggered

Installation

Using Helm Chart

You can install Kubanana using our Helm chart hosted on GHCR:

# Add the Helm repository
helm pull oci://ghcr.io/roshbhatia/kubanana/charts/kubanana --version <version>

# Install the chart
helm install kubanana oci://ghcr.io/roshbhatia/kubanana/charts/kubanana --version <version> \
  --create-namespace \
  --namespace kubanana-system

Using Container Image

The Kubanana controller image is also available on GHCR:

docker pull ghcr.io/roshbhatia/kubanana/controller:v<version>

Raw manifests are present at deploy/manifests.

Local Development

Requirements

Dev Tooling

Run make help to list all available make targets for local development and testing.

Contributing

I don't actively watch this repo, but feel free to fork and do what you desire with it. I'll likely check the PRs every so often if you're willing to wait.

About

🐒 see, 🦧 do! Events in, Kubernetes jobs out!

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors