Documentation
¶
Overview ¶
pkg/resources/deployments/deployment.go
pkg/resources/deployments/types.go
Index ¶
- 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 ResolvedDeploymentSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedDeploymentSpec) error
Create creates a Deployment owned by the CR if it does not already exist. Idempotent — if the Deployment exists, does nothing and returns nil. Sets owner reference so the Deployment is garbage collected when the CR is deleted.
func Delete ¶
func Delete(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedDeploymentSpec) error
Delete deletes the Deployment if it exists. For most cases owner references handle cascade deletion — use this only for explicit cleanup declared in onDelete templates.
func DeleteIfOwned ¶
func DeleteIfOwned(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, name, namespace string) error
DeleteIfOwned deletes the Deployment if it exists and is owned by the CR.
func Update ¶
func Update(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedDeploymentSpec) error
Update reconciles an existing Deployment to match the resolved spec. Handles drift — if replicas or image have changed, patches the Deployment. If the Deployment does not exist, creates it.
Types ¶
type ResolvedDeploymentSpec ¶
type ResolvedDeploymentSpec struct {
// Name — resolved Deployment name. Required.
Name string
// Image — container image. Required.
Image string
// Replicas — number of pod replicas. Default: 1.
Replicas int32
// Port — container port. 0 means no port exposed.
Port int32
// Protocol — resolved container port protocol. Defaults to TCP when not declared.
Protocol corev1.Protocol
// Namespace — target namespace. Required.
Namespace string
// Labels — applied to Deployment and pod template.
// Orkestra always adds: managed-by=orkestra, orkestra-owner=<cr-name>
Labels map[string]string
// Annotations — applied to the Deployment.
Annotations map[string]string
// Env — environment variables.
Env []orktypes.EnvVar
EnvFrom *orktypes.EnvFrom
// Resources — CPU and memory requests/limits. nil means no limits set.
Resources *orktypes.ResourceRequirements
// NodeSelector is a selector which must be true for the pod to fit on a node.
// Selector which must match a node's labels for the pod to be scheduled on that node.
// More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
// +optional
// +mapType=atomic
NodeSelector map[string]string
// ServiceAccountName is the name of the ServiceAccount to use to run this pod.
// More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
// +optional
ServiceAccountName string
// ImagePullSecrets is an optional list of references to secrets in the same namespace to use
// for pulling any of the images used by this PodSpec.
// If specified, these secrets will be passed to individual puller implementations for them to use.
ImagePullSecrets []string
// Probes — startup, liveness, and readiness probe configuration.
Probes *orktypes.ProbesConfig
// SecurityContext — container-level security settings.
SecurityContext *orktypes.ContainerSecurityContext
// PodSecurity — pod-level security settings.
PodSecurity *orktypes.PodSecurityContext
// Profiles — user-defined profile registry for runtime profile resolution.
Profiles orktypes.ProfileRegistry
// RollingUpdate — resolved rolling update strategy.
// nil means use Kubernetes defaults (25%/25%).
RollingUpdate *orktypes.RollingUpdateBehavior
// Volumes / VolumeMounts — pod volumes and container mounts.
Volumes []orktypes.VolumeSource
VolumeMounts []orktypes.VolumeMount
// 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
}
ResolvedDeploymentSpec is the fully resolved Deployment specification. Produced by resolving template expressions and merging static values. Passed directly to Create, Update, and Delete.
func Resolve ¶
func Resolve(src orktypes.DeploymentTemplateSource, ownerName string, reg orktypes.ProfileRegistry) ResolvedDeploymentSpec
Resolve builds a ResolvedDeploymentSpec from a DeploymentTemplateSource. Fields with template expressions must already be evaluated before calling Resolve. Use pkg/orkestra-registry/template.Resolver to evaluate expressions first.
The resolver already evaluated template expressions — here we just merge.