common

package
v1.10.6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package common provides shared labels, constants, and utility functions used across the Valkey operator.

Index

Constants

View Source
const (
	// LabelComponent is the standard Kubernetes recommended label for the component.
	LabelComponent = "app.kubernetes.io/component"
	// LabelInstance is the standard Kubernetes recommended label for the instance.
	LabelInstance = "app.kubernetes.io/instance"
	// LabelManagedBy is the standard Kubernetes recommended label for the manager.
	LabelManagedBy = "app.kubernetes.io/managed-by"
	// LabelName is the standard Kubernetes recommended label for the name.
	LabelName = "app.kubernetes.io/name"
	// LabelVersion is the standard Kubernetes recommended label for the version.
	LabelVersion = "app.kubernetes.io/version"

	// LabelCluster is the operator-specific label for the cluster name.
	LabelCluster = "vko.gtrfc.com/cluster"
	// LabelInstanceName is the operator-specific label for the instance name.
	LabelInstanceName = "vko.gtrfc.com/instanceName"
	// LabelInstanceRole is the operator-specific label for the instance role.
	LabelInstanceRole = "vko.gtrfc.com/instanceRole"

	// ComponentValkey is the component value for Valkey instances.
	ComponentValkey = "valkey"
	// ComponentSentinel is the component value for Sentinel instances.
	ComponentSentinel = "sentinel"

	// RoleMaster is the role value for the master instance.
	RoleMaster = "master"
	// RoleReplica is the role value for a replica instance.
	RoleReplica = "replica"
	// RoleDraining is the role value for a pod undergoing graceful failover drain.
	// When set, the pod is removed from the -rw Service immediately.
	RoleDraining = "draining"

	// ManagedBy is the constant value for the managed-by label.
	ManagedBy = "vko.gtrfc.com"
)

Variables

This section is empty.

Functions

func BaseLabels

func BaseLabels(v *vkov1.Valkey, component string) map[string]string

BaseLabels returns the common labels shared by all resources managed by the operator. These labels do NOT include pod-specific labels (instanceName, instanceRole).

func ExtractVersionFromImage

func ExtractVersionFromImage(image string) string

ExtractVersionFromImage extracts the tag portion from a container image string. Returns "latest" if no tag is present.

func HeadlessServiceName

func HeadlessServiceName(v *vkov1.Valkey, component string) string

HeadlessServiceName returns the name for a headless Service.

func MasterSelectorLabels added in v1.1.0

func MasterSelectorLabels(v *vkov1.Valkey) map[string]string

MasterSelectorLabels returns selector labels that match only the master pod. Used by the -rw Service.

func MergeAnnotations

func MergeAnnotations(maps ...map[string]string) map[string]string

MergeAnnotations merges multiple annotation maps. Later maps take precedence.

func MergeLabels

func MergeLabels(maps ...map[string]string) map[string]string

MergeLabels merges multiple label maps. Later maps take precedence over earlier ones.

func PodLabels

func PodLabels(v *vkov1.Valkey, component, podName, role string, userLabels map[string]string) map[string]string

PodLabels returns the full set of labels for a pod, including instance-specific labels. userLabels are merged in, but operator-managed labels take precedence to prevent overwrites.

func ReplicaSelectorLabels added in v1.1.0

func ReplicaSelectorLabels(v *vkov1.Valkey) map[string]string

ReplicaSelectorLabels returns selector labels that match only replica pods. Used by the -r Service.

func SelectorLabels

func SelectorLabels(v *vkov1.Valkey, component string) map[string]string

SelectorLabels returns the minimal label set used for label selectors (e.g., Services, StatefulSets).

func StatefulSetName

func StatefulSetName(v *vkov1.Valkey, component string) string

StatefulSetName returns the name for a Valkey or Sentinel StatefulSet.

Types

This section is empty.

Jump to

Keyboard shortcuts

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