Documentation
¶
Overview ¶
pkg/children/builtins.go
Single authoritative registry for every Kubernetes built-in resource kind Orkestra knows about. Adding one entry here is the only change required to:
- Resolve GVR for children and GVR lookups
- Generate RBAC rules (ClusterRole) for any katalog that uses the resource
- Detect usage in onReconcile / onCreate / onDelete template blocks
- Expand kind shorthands (e.g. "hpa" → "horizontalpodautoscaler")
- Derive the canonical PascalCase Kind name
- Drive readiness and deletion-protection logic
Keys are lowercase singular Kind names (e.g. "deployment", "namespace"). Accessor functions live in builtins_accessors.go.
NOTE: If a new kind supports context enrichment, also add an entry to enrichmentMeta (in this same file) — it is intentionally a parallel map so enrichment concerns stay separate from Kubernetes API identity.
pkg/children/builtins_accessors.go
Accessor functions over the builtInRegistry defined in builtins.go. These are the public API for querying built-in kind metadata. To add a new built-in kind, edit builtins.go — not this file.
Package children reads and enriches child Kubernetes resources that are declared in a Katalog's operatorBox. It is the bridge between the template resolver (which holds the owner CR's fields) and the Kubernetes API (which holds the live state of every child resource).
The single entry point is ReadChildren. It:
- Merges onCreate and onReconcile template declarations.
- For each declared resource type, reads the live objects from Kubernetes.
- Applies enrichment layers (pods, endpoints, warnings, PV).
- Returns a structured map injected into the template resolver under "children".
File layout ¶
- children.go — this file; package doc and ReadChildren entry point
- read.go — readResourceGroup, firstValue, mergeTemplates
- names.go — name resolution (resolvedChildName, *Names helpers)
- foreach.go — forEach expansion for all built-in resource types
- foreach_customresources.go — forEach expansion for custom resources
- enrich_pods.go — _pods enrichment and pod summary building
- enrich_endpoints.go — _endpoints enrichment
- enrich_warnings.go — _warnings enrichment (workload + pod events)
- enrich_pvc.go — _pv enrichment for PersistentVolumeClaims
- enrich_pv.go — _pvc enrichment for PersistentVolumes
- enrich_replicasets.go — _owner for ReplicaSets; _replicaSets for Deployments
- enrich_cronjobs.go — _activeJobs, _lastJob, _lastSuccessfulJob for CronJobs
- enrich_statefulsets.go — _pvcs for StatefulSets
- enrich_storageclass.go — _storageClass for PersistentVolumeClaims
- enrich_service_pods.go — _backingPods for Services
- enrich_ingress.go — _loadBalancerIPs, _tlsSecrets for Ingresses
- enrich_node.go — _node for Pods
- enrich_hpa.go — _currentMetrics, _scaleTarget for HPAs
See docs/ for a progressive walkthrough of each layer.
pkg/children/foreach.go
forEach expansion — expands template sources with a forEach declaration into N resolved sources, one per element in the list field.
forEach works on every resource type. The expansion happens before the resource-specific run_*.go function is called — each run_*.go function receives an already-expanded slice and is unaware of forEach.
Expansion sequence in runTemplateReconcile:
deployments := ExpandForEachDeployments(resolver, t.Deployments) runDeployments(ctx, kube, resolver, obj, deployments, update)
YAML:
onReconcile:
deployments:
- name: "{{ .metadata.name }}-{{ .item }}"
image: "{{ .spec.image }}"
forEach:
field: spec.regions
as: item
For CR with spec.regions: ["us-east-1", "eu-west-1"]: Produces two DeploymentTemplateSources:
{Name: "my-app-us-east-1", Image: "nginx:latest", ...}
{Name: "my-app-eu-west-1", Image: "nginx:latest", ...}
The expansion resolves ALL template expressions immediately — the returned slice contains static (non-template) values ready for the registry functions.
when: and anyOf: on forEach sources are evaluated per-item — each expanded source may pass or fail conditions independently.
pkg/children/gvr.go
Index ¶
- Variables
- func AllBuiltInKinds() []string
- func ChildGVRs() []struct{ ... }
- func ExpandForEachConfigMaps(resolver *orktmpl.Resolver, srcs []orktypes.ConfigMapTemplateSource) []orktypes.ConfigMapTemplateSource
- func ExpandForEachCronJobs(resolver *orktmpl.Resolver, srcs []orktypes.CronJobTemplateSource) []orktypes.CronJobTemplateSource
- func ExpandForEachCustomResources(resolver *orktmpl.Resolver, srcs []orktypes.CustomResourceTemplateSource) []orktypes.CustomResourceTemplateSource
- func ExpandForEachDeployments(resolver *orktmpl.Resolver, srcs []orktypes.DeploymentTemplateSource) []orktypes.DeploymentTemplateSource
- func ExpandForEachHPAs(resolver *orktmpl.Resolver, srcs []orktypes.HPATemplateSource) []orktypes.HPATemplateSource
- func ExpandForEachIngresses(resolver *orktmpl.Resolver, srcs []orktypes.IngressTemplateSource) []orktypes.IngressTemplateSource
- func ExpandForEachJobs(resolver *orktmpl.Resolver, srcs []orktypes.JobTemplateSource) []orktypes.JobTemplateSource
- func ExpandForEachNamespaces(resolver *orktmpl.Resolver, srcs []orktypes.NamespaceTemplateSource) []orktypes.NamespaceTemplateSource
- func ExpandForEachPDBs(resolver *orktmpl.Resolver, srcs []orktypes.PDBTemplateSource) []orktypes.PDBTemplateSource
- func ExpandForEachPVCs(resolver *orktmpl.Resolver, srcs []orktypes.PVCTemplateSource) []orktypes.PVCTemplateSource
- func ExpandForEachPVs(resolver *orktmpl.Resolver, srcs []orktypes.PVTemplateSource) []orktypes.PVTemplateSource
- func ExpandForEachPods(resolver *orktmpl.Resolver, srcs []orktypes.PodTemplateSource) []orktypes.PodTemplateSource
- func ExpandForEachReplicaSets(resolver *orktmpl.Resolver, srcs []orktypes.ReplicaSetTemplateSource) []orktypes.ReplicaSetTemplateSource
- func ExpandForEachRoleBindings(resolver *orktmpl.Resolver, srcs []orktypes.RoleBindingTemplateSource) []orktypes.RoleBindingTemplateSource
- func ExpandForEachRoles(resolver *orktmpl.Resolver, srcs []orktypes.RoleTemplateSource) []orktypes.RoleTemplateSource
- func ExpandForEachSecrets(resolver *orktmpl.Resolver, srcs []orktypes.SecretTemplateSource) []orktypes.SecretTemplateSource
- func ExpandForEachServiceAccounts(resolver *orktmpl.Resolver, srcs []orktypes.ServiceAccountTemplateSource) []orktypes.ServiceAccountTemplateSource
- func ExpandForEachServices(resolver *orktmpl.Resolver, srcs []orktypes.ServiceTemplateSource) []orktypes.ServiceTemplateSource
- func ExpandForEachStatefulSets(resolver *orktmpl.Resolver, srcs []orktypes.StatefulSetTemplateSource) []orktypes.StatefulSetTemplateSource
- func GVRForBuiltIn(kind string) (schema.GroupVersionResource, bool)
- func IsBuiltIn(kind string) bool
- func IsValidEnrichmentTarget(name string) bool
- func ReadChildren(ctx context.Context, kube kubeclient.KubeClient, obj domain.Object, ...) map[string]interface{}
- func SkipObservedGenerationGVKs() []string
- func SkipStatusSubresourceGVKs() []string
- func StatuslessGVKs() []string
- func SupportedEnrichmentGroups() map[string][]string
- type BuiltInKind
- type EnrichmentResult
Constants ¶
This section is empty.
Variables ¶
var ( DeploymentGVR = gvrOrPanic("deployment") ServiceGVR = gvrOrPanic("service") SecretGVR = gvrOrPanic("secret") ConfigMapGVR = gvrOrPanic("configmap") JobGVR = gvrOrPanic("job") CronJobGVR = gvrOrPanic("cronjob") PodGVR = gvrOrPanic("pod") ServiceAccountGVR = gvrOrPanic("serviceaccount") StatefulSetGVR = gvrOrPanic("statefulset") IngressGVR = gvrOrPanic("ingress") PersistentVolumeClaimGVR = gvrOrPanic("persistentvolumeclaim") PersistentVolumeGVR = gvrOrPanic("persistentvolume") HorizontalPodAutoscalerGVR = gvrOrPanic("horizontalpodautoscaler") PodDisruptionBudgetGVR = gvrOrPanic("poddisruptionbudget") DaemonSetGVR = gvrOrPanic("daemonset") ReplicaSetGVR = gvrOrPanic("replicaset") NetworkPolicyGVR = gvrOrPanic("networkpolicy") RoleGVR = gvrOrPanic("role") RoleBindingGVR = gvrOrPanic("rolebinding") ClusterRoleGVR = gvrOrPanic("clusterrole") ClusterRoleBindingGVR = gvrOrPanic("clusterrolebinding") NamespaceGVR = gvrOrPanic("namespace") NodeGVR = gvrOrPanic("node") EndpointSliceGVR = gvrOrPanic("endpointslice") EventGVR = gvrOrPanic("event") StorageClassGVR = gvrOrPanic("storageclass") )
Functions ¶
func AllBuiltInKinds ¶
func AllBuiltInKinds() []string
AllBuiltInKinds returns all canonical Kind names, sorted alphabetically.
func ChildGVRs ¶
func ChildGVRs() []struct {
GVR schema.GroupVersionResource
Key string
}
ChildGVRs returns all built‑in child resource GVRs with their keys.
func ExpandForEachConfigMaps ¶
func ExpandForEachConfigMaps( resolver *orktmpl.Resolver, srcs []orktypes.ConfigMapTemplateSource, ) []orktypes.ConfigMapTemplateSource
func ExpandForEachCronJobs ¶
func ExpandForEachCronJobs( resolver *orktmpl.Resolver, srcs []orktypes.CronJobTemplateSource, ) []orktypes.CronJobTemplateSource
func ExpandForEachCustomResources ¶
func ExpandForEachCustomResources(resolver *orktmpl.Resolver, srcs []orktypes.CustomResourceTemplateSource) []orktypes.CustomResourceTemplateSource
ExpandForEachCustomResources expands any CustomResource entries that declare a ForEach. It returns a new slice with expanded items. Items without ForEach are copied verbatim.
func ExpandForEachDeployments ¶
func ExpandForEachDeployments( resolver *orktmpl.Resolver, srcs []orktypes.DeploymentTemplateSource, ) []orktypes.DeploymentTemplateSource
func ExpandForEachHPAs ¶
func ExpandForEachHPAs( resolver *orktmpl.Resolver, srcs []orktypes.HPATemplateSource, ) []orktypes.HPATemplateSource
func ExpandForEachIngresses ¶
func ExpandForEachIngresses( resolver *orktmpl.Resolver, srcs []orktypes.IngressTemplateSource, ) []orktypes.IngressTemplateSource
func ExpandForEachJobs ¶
func ExpandForEachJobs( resolver *orktmpl.Resolver, srcs []orktypes.JobTemplateSource, ) []orktypes.JobTemplateSource
func ExpandForEachNamespaces ¶
func ExpandForEachNamespaces( resolver *orktmpl.Resolver, srcs []orktypes.NamespaceTemplateSource, ) []orktypes.NamespaceTemplateSource
func ExpandForEachPDBs ¶
func ExpandForEachPDBs( resolver *orktmpl.Resolver, srcs []orktypes.PDBTemplateSource, ) []orktypes.PDBTemplateSource
func ExpandForEachPVCs ¶
func ExpandForEachPVCs( resolver *orktmpl.Resolver, srcs []orktypes.PVCTemplateSource, ) []orktypes.PVCTemplateSource
func ExpandForEachPVs ¶
func ExpandForEachPVs( resolver *orktmpl.Resolver, srcs []orktypes.PVTemplateSource, ) []orktypes.PVTemplateSource
func ExpandForEachPods ¶
func ExpandForEachPods( resolver *orktmpl.Resolver, srcs []orktypes.PodTemplateSource, ) []orktypes.PodTemplateSource
func ExpandForEachReplicaSets ¶
func ExpandForEachReplicaSets( resolver *orktmpl.Resolver, srcs []orktypes.ReplicaSetTemplateSource, ) []orktypes.ReplicaSetTemplateSource
func ExpandForEachRoleBindings ¶
func ExpandForEachRoleBindings( resolver *orktmpl.Resolver, srcs []orktypes.RoleBindingTemplateSource, ) []orktypes.RoleBindingTemplateSource
func ExpandForEachRoles ¶
func ExpandForEachRoles( resolver *orktmpl.Resolver, srcs []orktypes.RoleTemplateSource, ) []orktypes.RoleTemplateSource
func ExpandForEachSecrets ¶
func ExpandForEachSecrets( resolver *orktmpl.Resolver, srcs []orktypes.SecretTemplateSource, ) []orktypes.SecretTemplateSource
func ExpandForEachServiceAccounts ¶
func ExpandForEachServiceAccounts( resolver *orktmpl.Resolver, srcs []orktypes.ServiceAccountTemplateSource, ) []orktypes.ServiceAccountTemplateSource
func ExpandForEachServices ¶
func ExpandForEachServices( resolver *orktmpl.Resolver, srcs []orktypes.ServiceTemplateSource, ) []orktypes.ServiceTemplateSource
func ExpandForEachStatefulSets ¶
func ExpandForEachStatefulSets( resolver *orktmpl.Resolver, srcs []orktypes.StatefulSetTemplateSource, ) []orktypes.StatefulSetTemplateSource
func GVRForBuiltIn ¶
func GVRForBuiltIn(kind string) (schema.GroupVersionResource, bool)
GVRForBuiltIn returns the GroupVersionResource for a built-in kind.
func IsValidEnrichmentTarget ¶
IsValidEnrichmentTarget reports whether the given name is a supported context-enrichment target.
func ReadChildren ¶
func ReadChildren( ctx context.Context, kube kubeclient.KubeClient, obj domain.Object, resolver *orktmpl.Resolver, crd orktypes.CRDEntry, ) map[string]interface{}
ReadChildren reads all child resources declared in the Katalog's onCreate templates and returns a structured map for use in status field expressions.
The returned map is injected into the template resolver under the "children" key. Status field expressions can then reference child resource state:
# Singular — the first/only resource of this type
{{ .children.deployment.status.readyReplicas }}
{{ .children.service.status.loadBalancer.ingress }}
# Plural — all resources of this type, by name
{{ (index .children.deployments "my-site-api").status.readyReplicas }}
ReadChildren is called after runTemplateReconcile — child resources exist at this point. Missing status fields resolve to "" (missingkey=zero), which is correct eventual consistency behaviour for newly created resources.
API cost: one GET per child resource type × count. For the common case (one Deployment + one Service), this is two GETs.
This function never returns an error that should fail the reconcile. Read failures are logged and the child is omitted from the map. Status patching proceeds with whatever children were successfully read.
func SkipObservedGenerationGVKs ¶
func SkipObservedGenerationGVKs() []string
func SkipStatusSubresourceGVKs ¶
func SkipStatusSubresourceGVKs() []string
func StatuslessGVKs ¶
func StatuslessGVKs() []string
func SupportedEnrichmentGroups ¶
SupportedEnrichmentGroups returns all supported enrichment targets, including built-in Kubernetes resources and synthetic Orkestra-only targets.
Types ¶
type BuiltInKind ¶
type BuiltInKind struct {
Kind string // PascalCase Kind name (e.g. "Deployment")
Group string // API group; empty string for core
Version string // API version (e.g. "v1", "v2")
Plural string // plural resource name (e.g. "deployments")
Namespaced bool // true if resource is namespaced
APIPath string // "/api" for core, "/apis" otherwise
// Shorthands are case-insensitive aliases resolved by LookupBuiltIn.
// e.g. "hpa" → "horizontalpodautoscaler"
Shorthands []string
// Detect reports whether a CRD's operatorBox uses this resource in any
// hook template block (onCreate / onReconcile / onDelete).
// nil for resources that cannot appear in hook templates (e.g. Node, Event).
Detect func(crd orktypes.CRDEntry) bool
Statusless bool // No meaningful status; treat as ready on existence
SkipStatusSubresource bool // No /status subresource; never PATCH status
SkipObservedGeneration bool // Has status but no observedGeneration; skip generation check
IsChild bool // Orkestra may create this as a child resource
OrkestraInternal bool // Part of Orkestra's own control-plane installation
}
BuiltInKind holds the fully-qualified API metadata for a Kubernetes built-in resource kind, plus Orkestra-specific readiness and usage metadata.
func AllBuiltInKindDefs ¶
func AllBuiltInKindDefs() []BuiltInKind
AllBuiltInKindDefs returns all entries from the built-in registry. Entries with a nil Detect field represent aliases or internal entries without RBAC detection logic. Callers that need only detectable entries should filter on Detect != nil.
func BuiltInMeta ¶
func BuiltInMeta(kind string) BuiltInKind
BuiltInMeta returns metadata for a built-in kind. Zero value when unknown.
func LookupBuiltInByResource ¶
func LookupBuiltInByResource(resource string) (BuiltInKind, bool)
LookupBuiltInByResource looks up a built-in by singular key, shorthand, or plural resource name. Returns (BuiltInKind, true) when found. Used by RBAC generation and any caller that works with resource strings rather than Kind names.
type EnrichmentResult ¶
type EnrichmentResult struct {
Found bool
Kind string // canonical PascalCase name (e.g. "Deployment")
BuiltIn BuiltInKind
DisplayGroup string // "core" for empty group, otherwise the group string
}
EnrichmentResult holds the result of a built-in lookup.
func LookupBuiltIn ¶
func LookupBuiltIn(kind string) EnrichmentResult
LookupBuiltIn looks up a Kind in the built-in registry. Case-insensitive. Expands shorthands (e.g. "hpa" → "horizontalpodautoscaler").
Source Files
¶
- builtins.go
- builtins_accessors.go
- children.go
- enrich_cronjobs.go
- enrich_endpoints.go
- enrich_helper.go
- enrich_hpa.go
- enrich_ingress.go
- enrich_node.go
- enrich_pods.go
- enrich_pv.go
- enrich_pvc.go
- enrich_replicasets.go
- enrich_service_pods.go
- enrich_statefulsets.go
- enrich_storageclass.go
- enrich_warnings.go
- foreach.go
- foreach_customresources.go
- gvr.go
- names.go
- read.go