Documentation
¶
Overview ¶
pkg/resources/configmaps/configmap.go
Index ¶
- func CopyToNamespaces(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func Create(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func Delete(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func DeleteIfOwned(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func Update(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- type ConfigMapTemplateSource
- type ResolvedConfigMapSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyToNamespaces ¶
func CopyToNamespaces( ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedConfigMapSpec, toNamespaces []string, ) error
CopyToNamespaces copies a ConfigMap to multiple target namespaces. Reads the source once and creates copies in each namespace. Idempotent — skips namespaces where the ConfigMap already exists.
Example Katalog declaration:
onCreate:
configMaps:
- name: app-config
fromConfigMap: base-app-config
fromNamespace: platform
toNamespaces:
- "{{ .metadata.namespace }}"
- staging
- production
func Create ¶
func Create(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedConfigMapSpec) error
Create creates a ConfigMap if it does not already exist. Idempotent — skips if ConfigMap exists. Owner reference set for cascade deletion.
func Delete ¶
func Delete(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedConfigMapSpec) error
Delete deletes the ConfigMap if it exists.
func DeleteIfOwned ¶
func DeleteIfOwned(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, name, namespace string) error
DeleteIfOwned ConfigMaps the Job if it exists and is owned by the CR.
func Update ¶
func Update(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedConfigMapSpec) error
Update reconciles an existing ConfigMap to match the resolved spec. Re-syncs data from FromConfigMap on every reconcile if set. If ConfigMap does not exist, creates it.
Types ¶
type ConfigMapTemplateSource ¶
type ConfigMapTemplateSource struct {
// Version — OrkestraRegistry implementation version. Omit for latest.
Version string
// Name — ConfigMap name.
// Default: "{{ .metadata.name }}-config"
Name string
// Namespace — primary target namespace.
// Default: "{{ .metadata.namespace }}"
Namespace string
// ToNamespaces — create one copy in each listed namespace.
// Each element supports template expressions.
ToNamespaces []string
// FromConfigMap — name of an existing ConfigMap to copy data from.
// Orkestra reads this at reconcile time — copies stay in sync with the source.
FromConfigMap string
// FromNamespace — namespace where FromConfigMap lives.
// Default: same namespace as the CR.
FromNamespace string
// Data — static key-value entries.
// When FromConfigMap is also set, these entries override matching keys from the source.
Data map[string]string
// Labels — applied to all created ConfigMap copies.
Labels []orktypes.ResourceLabel
// Reconcile: true — sync on every reconcile.
// When true, if the source ConfigMap changes, all copies are updated automatically.
Reconcile bool
// Sleep injects an artificial delay into the reconcile of this resource.
// Useful for autoscale testing, latency simulation, and chaos engineering.
// Accepts extended duration units (s, m, h, d, w, mo, y).
Sleep string
}
ConfigMapTemplateSource declares one ConfigMap to be managed by Orkestra.
Three usage patterns:
1. Static data:
onCreate:
configMaps:
- name: "{{ .metadata.name }}-config"
data:
LOG_LEVEL: info
MAX_CONNECTIONS: "100"
2. Copy from existing ConfigMap:
onCreate:
configMaps:
- name: app-config
fromConfigMap: base-app-config
fromNamespace: platform
3. Copy + override specific keys:
onCreate:
configMaps:
- name: app-config
fromConfigMap: base-app-config
fromNamespace: platform
data:
LOG_LEVEL: debug # overrides the base value
4. Copy to multiple namespaces:
onCreate:
configMaps:
- name: app-config
fromConfigMap: base-app-config
toNamespaces:
- "{{ .metadata.namespace }}"
- staging
- production
type ResolvedConfigMapSpec ¶
type ResolvedConfigMapSpec struct {
// Name — ConfigMap name. Required.
Name string
// Namespace — target namespace. Required.
Namespace string
// Data — key-value configuration entries.
Data map[string]string
// FromConfigMap — name of a source ConfigMap to copy from.
// When set, copies all keys from the source into the target.
// Individual Data entries merge on top — override specific keys if needed.
FromConfigMap string
// FromNamespace — namespace where FromConfigMap lives.
// Default: same namespace as the CR.
FromNamespace string
// Labels — applied to ConfigMap metadata.
Labels map[string]string
// Sleep injects an artificial delay into the reconcile of this resource.
// Useful for autoscale testing, latency simulation, and chaos engineering.
// Accepts extended duration units (s, m, h, d, w, mo, y).
Sleep string
}
ResolvedConfigMapSpec is the fully resolved ConfigMap specification.
func Resolve ¶
func Resolve(src orktypes.ConfigMapTemplateSource, ownerName string) ResolvedConfigMapSpec
Resolve builds a ResolvedConfigMapSpec from a ConfigMapTemplateSource. Template expressions must already be evaluated by template.Resolver before calling.