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.
Automatic Synchronization: Watched object changes trigger regeneration of derived children. Manually deleted children are automatically recreated.
# 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