🚀 Kroc - Kubernetes Reactive Object Creator

An educational hobby project demonstrating Kubernetes Operator creation using Go (Golang) and kubebuilder. It introduces the custom resource `Kroc` for reactive resource derivation by watching arbitrary cluster objects and creating derived objects based on their attributes.

✨ Key Features & Architecture

1. Kroc Controller: Config Manager. Initializes the Watch Controller based on the `Kroc` resource spec.
2. Watch Controller: The Observer. Sets up watches on target objects (via `nameRegex`, `kind`) and triggers the Creator Controller upon changes.
3. Creator Controller: Derivation Handler. Applies the dynamic Go Template (`resourceToCreate`) to manage the derived child objects.

Automatic Synchronization: Watched object changes trigger regeneration of derived children. Manually deleted children are automatically recreated.

💡 Example Usage (Go Template)

# Define variables for use in the template
{{- $pod1 := 1 -}}
{{- $pod2 := 2 -}}

# --- Pod 1: Dynamically named and labeled using parent UID ---
apiVersion: v1
kind: Pod
metadata:
    name: nginx-pod-{{ $pod1 }}
    namespace: pawel
    labels:
    environment: development
    # Inject attribute from the watched (parent) object
    parentuid: "{{.parent.metadata.uid}}"
spec:
    containers:
    - name: nginx-container
    image: nginx:latest
    ports:
    - containerPort: 80
        protocol: TCP
---
# --- Pod 2: Second object definition in the same template ---
apiVersion: v1
kind: Pod
metadata:
    name: nginx-pod-{{ $pod2 }}
    namespace: pawel
    labels:
    environment: development
spec:
    containers:
    - name: nginx-container
    # Corrected image tag for example clarity
    image: nginx:latest 
    ports:
    - containerPort: 80 
        protocol: TCP

https://github.com/pawelcit/kroc