statefulsets

package
v0.7.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

pkg/resources/statefulsets/statefulset.go

pkg/resources/statefulsets/types.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

Create creates a StatefulSet owned by the CR if it does not already exist.

func Delete

Delete deletes the StatefulSet if it exists.

func DeleteIfOwned

func DeleteIfOwned(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, name, namespace string) error

DeleteIfOwned deletes the StatefulSet only if it is owned by the given CR.

func Update

Update reconciles an existing StatefulSet to match the resolved spec. Patches replicas and image when drift is detected.

Types

type ResolvedStatefulSetSpec

type ResolvedStatefulSetSpec struct {
	Name        string
	Namespace   string
	Image       string
	Replicas    int32
	Port        int32
	Protocol    corev1.Protocol
	ServiceName string

	// VolumeClaimTemplates — resolved PVC templates (may be multiple).
	VolumeClaimTemplates []ResolvedVolumeClaimTemplate

	Labels      map[string]string
	Annotations map[string]string

	Env       []orktypes.EnvVar
	EnvFrom   *orktypes.EnvFrom
	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

	VolumeClaimRetentionPolicy VolumeClaimRetentionPolicy

	// 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

	// RollingUpdate — resolved rolling update strategy. nil uses OnDelete (Orkestra default).
	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
}

ResolvedStatefulSetSpec is the fully resolved StatefulSet specification.

func Resolve

Resolve builds a ResolvedStatefulSetSpec from a StatefulSetTemplateSource.

type ResolvedVolumeClaimTemplate

type ResolvedVolumeClaimTemplate struct {
	Name         string
	StorageClass string
	StorageSize  string
	MountPath    string
	AccessModes  []string
}

ResolvedVolumeClaimTemplate is one resolved PVC template for a StatefulSet.

type VolumeClaimRetentionPolicy

type VolumeClaimRetentionPolicy struct {
	// WhenDeleted specifies what happens to PVCs created from StatefulSet
	// VolumeClaimTemplates when the StatefulSet is deleted. The default policy
	// of `Retain` causes PVCs to not be affected by StatefulSet deletion. The
	// `Delete` policy causes those PVCs to be deleted.
	WhenDeleted string
	// WhenScaled specifies what happens to PVCs created from StatefulSet
	// VolumeClaimTemplates when the StatefulSet is scaled down. The default
	// policy of `Retain` causes PVCs to not be affected by a scaledown. The
	// `Delete` policy causes the associated PVCs for any excess pods above
	// the replica count to be deleted.
	WhenScaled string
}

VolumeClaimRetentionPolicy describes the policy used for PVCs created from the StatefulSet VolumeClaimTemplates.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL