https://github.com/roshbhatia/kubanana
🐒 see, 🦧 do! Events in, Kubernetes jobs out!
https://github.com/roshbhatia/kubanana
devops event-driven homelab homelab-automation kubernetes kubernetes-controller
Last synced: about 2 months ago
JSON representation
🐒 see, 🦧 do! Events in, Kubernetes jobs out!
- Host: GitHub
- URL: https://github.com/roshbhatia/kubanana
- Owner: roshbhatia
- Created: 2025-02-25T00:57:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-28T01:09:35.000Z (over 1 year ago)
- Last Synced: 2025-02-28T08:10:42.089Z (over 1 year ago)
- Topics: devops, event-driven, homelab, homelab-automation, kubernetes, kubernetes-controller
- Language: Go
- Homepage:
- Size: 477 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Roadmap: ROADMAP.md
Awesome Lists containing this project
README
# 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](https://kubernetes.io/docs/concepts/workloads/controllers/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](https://kyverno.io/) and operators like [Metacontroller](https://metacontroller.github.io/metacontroller/intro.html) 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:
```yaml
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:
```bash
# Add the Helm repository
helm pull oci://ghcr.io/roshbhatia/kubanana/charts/kubanana --version
# Install the chart
helm install kubanana oci://ghcr.io/roshbhatia/kubanana/charts/kubanana --version \
--create-namespace \
--namespace kubanana-system
```
### Using Container Image
The Kubanana controller image is also available on GHCR:
```bash
docker pull ghcr.io/roshbhatia/kubanana/controller:v
```
Raw manifests are present at `deploy/manifests`.
## Local Development
### Requirements
- [Go 1.21+](https://go.dev/)
- [Docker](https://www.docker.com/)
- [Kind](https://kind.sigs.k8s.io/)
- [kubectl](https://kubernetes.io/docs/reference/kubectl/)
- [chainsaw](https://kyverno.github.io/chainsaw/0.2.3/)
### 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.