Documentation
¶
Index ¶
- func AddFinalizer(ctx context.Context, cr client.Object, finalizer string, cl client.Client) error
- func AddOwnerRefToObject(obj metav1.Object, ownerRef metav1.OwnerReference)
- func AddRedisNodeToCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
- func CheckIfEmptyMasters(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
- func CheckRedisNodeCount(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, ...) int32
- func ClusterFailover(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, ...) error
- func CreateMasterSlaveReplication(ctx context.Context, client kubernetes.Interface, cr *rrvb2.RedisReplication, ...) error
- func CreateOrUpdatePodDisruptionBudget(ctx context.Context, pdbDef *policyv1.PodDisruptionBudget, ...) error
- func CreateOrUpdateService(ctx context.Context, namespace string, serviceMeta metav1.ObjectMeta, ...) error
- func CreateOrUpdateStateFul(ctx context.Context, cl kubernetes.Interface, namespace string, ...) error
- func CreateRedisFollower(ctx context.Context, cr *rcvb2.RedisCluster, cl kubernetes.Interface) error
- func CreateRedisFollowerService(ctx context.Context, cr *rcvb2.RedisCluster, cl kubernetes.Interface) error
- func CreateRedisLeader(ctx context.Context, cr *rcvb2.RedisCluster, cl kubernetes.Interface) error
- func CreateRedisLeaderService(ctx context.Context, cr *rcvb2.RedisCluster, cl kubernetes.Interface) error
- func CreateRedisSentinel(ctx context.Context, client kubernetes.Interface, cr *rsvb2.RedisSentinel, ...) error
- func CreateRedisSentinelService(ctx context.Context, cr *rsvb2.RedisSentinel, cl kubernetes.Interface) error
- func CreateReplicationRedis(ctx context.Context, cr *rrvb2.RedisReplication, cl kubernetes.Interface) error
- func CreateReplicationService(ctx context.Context, cr *rrvb2.RedisReplication, cl kubernetes.Interface) error
- func CreateStandaloneRedis(ctx context.Context, cr *rvb2.Redis, cl kubernetes.Interface) error
- func CreateStandaloneService(ctx context.Context, cr *rvb2.Redis, cl kubernetes.Interface) error
- func ExecuteFailoverOperation(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster) error
- func ExecuteRedisClusterCommand(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
- func ExecuteRedisReplicationCommand(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
- func GenerateAuthAndTLSArgs(enableAuth, enableTLS bool) (string, string)
- func GenerateK8sClient(configProvider K8sConfigProvider) (kubernetes.Interface, error)
- func GeneratePreStopCommand(role string, enableAuth, enableTLS bool) string
- func GenerateTLSEnvironmentVariables(tlsconfig *commonapi.TLSConfig) []corev1.EnvVar
- func GetRedisNodesByRole(ctx context.Context, cl kubernetes.Interface, cr *rrvb2.RedisReplication, ...) ([]string, error)
- func GetRedisReplicationRealMaster(ctx context.Context, client kubernetes.Interface, cr *rrvb2.RedisReplication, ...) string
- func GetStatefulSet(ctx context.Context, cl kubernetes.Interface, namespace string, name string) (*appsv1.StatefulSet, error)
- func HandlePVCResizing(ctx context.Context, storedStateful, newStateful *appsv1.StatefulSet, ...) error
- func HandleRedisClusterFinalizer(ctx context.Context, ctrlclient client.Client, cr *rcvb2.RedisCluster, ...) error
- func HandleRedisFinalizer(ctx context.Context, ctrlclient client.Client, cr *rvb2.Redis, ...) error
- func HandleRedisReplicationFinalizer(ctx context.Context, ctrlclient client.Client, cr *rrvb2.RedisReplication, ...) error
- func HandleRedisSentinelFinalizer(ctx context.Context, ctrlclient client.Client, cr *rsvb2.RedisSentinel, ...) error
- func IsDeleted(obj client.Object) bool
- func IsRedisReplicationReady(ctx context.Context, client kubernetes.Interface, ctrlClient client.Client, ...) bool
- func LabelSelectors(labels map[string]string) *metav1.LabelSelector
- func RebalanceRedisCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
- func RebalanceRedisClusterEmptyMasters(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
- func ReconcileRedisPodDisruptionBudget(ctx context.Context, cr *rcvb2.RedisCluster, role string, ...) error
- func ReconcileReplicationPodDisruptionBudget(ctx context.Context, cr *rrvb2.RedisReplication, ...) error
- func ReconcileSentinelPodDisruptionBudget(ctx context.Context, cr *rsvb2.RedisSentinel, ...) error
- func RedisClusterStatusHealth(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster) bool
- func RemoveRedisFollowerNodesFromCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, ...)
- func RemoveRedisNodeFromCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, ...)
- func RepairDisconnectedMasters(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster) error
- func ReshardRedisCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, ...)
- func SetRedisClusterDynamicConfig(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster) error
- func UnhealthyNodesInCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster) (int, error)
- func VerifyLeaderPod(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, ...) bool
- type K8sConfigProvider
- type RedisClusterSTS
- type RedisClusterService
- type RedisDetails
- type RedisInvocation
- type RedisSentinelSTS
- type RedisSentinelService
- type StatefulSet
- type StatefulSetService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFinalizer ¶
AddFinalizer add finalizer for graceful deletion
func AddOwnerRefToObject ¶
func AddOwnerRefToObject(obj metav1.Object, ownerRef metav1.OwnerReference)
AddOwnerRefToObject adds the owner references to object
func AddRedisNodeToCluster ¶
func AddRedisNodeToCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
Add redis cluster node would add a node to the existing redis cluster using redis-cli
func CheckIfEmptyMasters ¶
func CheckIfEmptyMasters(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
func CheckRedisNodeCount ¶
func CheckRedisNodeCount(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, nodeType string) int32
CheckRedisNodeCount will check the count of redis nodes
func ClusterFailover ¶
func ClusterFailover(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, shardIdx int32) error
func CreateMasterSlaveReplication ¶
func CreateMasterSlaveReplication(ctx context.Context, client kubernetes.Interface, cr *rrvb2.RedisReplication, masterPods []string, realMasterPod string) error
func CreateOrUpdatePodDisruptionBudget ¶
func CreateOrUpdatePodDisruptionBudget(ctx context.Context, pdbDef *policyv1.PodDisruptionBudget, cl kubernetes.Interface) error
CreateOrUpdateService method will create or update Redis service
func CreateOrUpdateService ¶
func CreateOrUpdateService(ctx context.Context, namespace string, serviceMeta metav1.ObjectMeta, ownerDef metav1.OwnerReference, epp exporterPortProvider, headless bool, serviceType string, port int, cl kubernetes.Interface, extra ...corev1.ServicePort) error
CreateOrUpdateService method will create or update Redis service
func CreateOrUpdateStateFul ¶
func CreateOrUpdateStateFul(ctx context.Context, cl kubernetes.Interface, namespace string, stsMeta metav1.ObjectMeta, params statefulSetParameters, ownerDef metav1.OwnerReference, initcontainerParams initContainerParameters, containerParams containerParameters, sidecars *[]commonapi.Sidecar) error
CreateOrUpdateStateFul method will create or update Redis service
func CreateRedisFollower ¶
func CreateRedisFollower(ctx context.Context, cr *rcvb2.RedisCluster, cl kubernetes.Interface) error
CreateRedisFollower will create a follower redis setup
func CreateRedisFollowerService ¶
func CreateRedisFollowerService(ctx context.Context, cr *rcvb2.RedisCluster, cl kubernetes.Interface) error
CreateRedisFollowerService method will create service for Redis Follower
func CreateRedisLeader ¶
func CreateRedisLeader(ctx context.Context, cr *rcvb2.RedisCluster, cl kubernetes.Interface) error
CreateRedisLeader will create a leader redis setup
func CreateRedisLeaderService ¶
func CreateRedisLeaderService(ctx context.Context, cr *rcvb2.RedisCluster, cl kubernetes.Interface) error
CreateRedisLeaderService method will create service for Redis Leader
func CreateRedisSentinel ¶
func CreateRedisSentinel(ctx context.Context, client kubernetes.Interface, cr *rsvb2.RedisSentinel, cl kubernetes.Interface, ctrlClient client.Client) error
Redis Sentinel Create the Redis Sentinel Setup
func CreateRedisSentinelService ¶
func CreateRedisSentinelService(ctx context.Context, cr *rsvb2.RedisSentinel, cl kubernetes.Interface) error
Create RedisSentinel Service
func CreateReplicationRedis ¶
func CreateReplicationRedis(ctx context.Context, cr *rrvb2.RedisReplication, cl kubernetes.Interface) error
CreateReplicationRedis will create a replication redis setup
func CreateReplicationService ¶
func CreateReplicationService(ctx context.Context, cr *rrvb2.RedisReplication, cl kubernetes.Interface) error
CreateReplicationService method will create replication service for Redis
func CreateStandaloneRedis ¶
CreateStandaloneRedis will create a standalone redis setup
func CreateStandaloneService ¶
CreateStandaloneService method will create standalone service for Redis
func ExecuteFailoverOperation ¶
func ExecuteFailoverOperation(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster) error
ExecuteFailoverOperation will execute redis failover operations
func ExecuteRedisClusterCommand ¶
func ExecuteRedisClusterCommand(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
ExecuteRedisClusterCommand will execute redis cluster creation command
func ExecuteRedisReplicationCommand ¶
func ExecuteRedisReplicationCommand(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
ExecuteRedisReplicationCommand will execute the replication command
func GenerateAuthAndTLSArgs ¶
GenerateAuthAndTLSArgs constructs authentication and TLS arguments for redis-cli.
func GenerateK8sClient ¶
func GenerateK8sClient(configProvider K8sConfigProvider) (kubernetes.Interface, error)
GenerateK8sClient create client for kubernetes
func GeneratePreStopCommand ¶
GeneratePreStopCommand generates the preStop script based on the Redis role. Only "cluster" role is supported for now; other roles return an empty string.
func GetRedisNodesByRole ¶
func GetRedisNodesByRole(ctx context.Context, cl kubernetes.Interface, cr *rrvb2.RedisReplication, redisRole string) ([]string, error)
Get Redis nodes by it's role i.e. master, slave and sentinel
func GetRedisReplicationRealMaster ¶
func GetRedisReplicationRealMaster(ctx context.Context, client kubernetes.Interface, cr *rrvb2.RedisReplication, masterPods []string) string
func GetStatefulSet ¶
func GetStatefulSet(ctx context.Context, cl kubernetes.Interface, namespace string, name string) (*appsv1.StatefulSet, error)
GetStateFulSet is a method to get statefulset in Kubernetes
func HandlePVCResizing ¶
func HandlePVCResizing(ctx context.Context, storedStateful, newStateful *appsv1.StatefulSet, cl kubernetes.Interface) error
HandlePVCResizing checks and updates the PVC storage capacity for the target VolumeClaimTemplate. It filters out any template with name "node-conf", and only processes the first template that does not have that name. If the storage capacity defined in the new StatefulSet's target template (i.e. for Redis RDB data) differs from the actual PVC capacity, it attempts to update the PVC and adjusts the annotation accordingly. Returns an error if any update fails.
func HandleRedisClusterFinalizer ¶
func HandleRedisClusterFinalizer(ctx context.Context, ctrlclient client.Client, cr *rcvb2.RedisCluster, finalizer string) error
HandleRedisClusterFinalizer finalize resource if instance is marked to be deleted
func HandleRedisFinalizer ¶
func HandleRedisFinalizer(ctx context.Context, ctrlclient client.Client, cr *rvb2.Redis, finalizer string) error
HandleRedisFinalizer finalize resource if instance is marked to be deleted
func HandleRedisReplicationFinalizer ¶
func HandleRedisReplicationFinalizer(ctx context.Context, ctrlclient client.Client, cr *rrvb2.RedisReplication, finalizer string) error
Handle RedisReplicationFinalizer finalize resource if instance is marked to be deleted
func HandleRedisSentinelFinalizer ¶
func HandleRedisSentinelFinalizer(ctx context.Context, ctrlclient client.Client, cr *rsvb2.RedisSentinel, finalizer string) error
HandleRedisSentinelFinalizer finalize resource if instance is marked to be deleted
func IsRedisReplicationReady ¶
func IsRedisReplicationReady(ctx context.Context, client kubernetes.Interface, ctrlClient client.Client, rs *rsvb2.RedisSentinel) bool
func LabelSelectors ¶
func LabelSelectors(labels map[string]string) *metav1.LabelSelector
LabelSelectors generates object for label selection
func RebalanceRedisCluster ¶
func RebalanceRedisCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
Rebalance Redis Cluster Would Rebalance the Redis Cluster without using the empty masters
func RebalanceRedisClusterEmptyMasters ¶
func RebalanceRedisClusterEmptyMasters(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster)
Rebalance the Redis CLuster using the Empty Master Nodes
func ReconcileRedisPodDisruptionBudget ¶
func ReconcileRedisPodDisruptionBudget(ctx context.Context, cr *rcvb2.RedisCluster, role string, pdbParams *common.RedisPodDisruptionBudget, cl kubernetes.Interface) error
CreateRedisLeaderPodDisruptionBudget check and create a PodDisruptionBudget for Leaders
func ReconcileReplicationPodDisruptionBudget ¶
func ReconcileReplicationPodDisruptionBudget(ctx context.Context, cr *rrvb2.RedisReplication, pdbParams *common.RedisPodDisruptionBudget, cl kubernetes.Interface) error
func ReconcileSentinelPodDisruptionBudget ¶
func ReconcileSentinelPodDisruptionBudget(ctx context.Context, cr *rsvb2.RedisSentinel, pdbParams *common.RedisPodDisruptionBudget, cl kubernetes.Interface) error
func RedisClusterStatusHealth ¶
func RedisClusterStatusHealth(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster) bool
RedisClusterStatusHealth use `redis-cli --cluster check 127.0.0.1:6379`
func RemoveRedisFollowerNodesFromCluster ¶
func RemoveRedisFollowerNodesFromCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, shardIdx int32)
Remove redis follower node would remove all follower nodes of last leader node using redis-cli
func RemoveRedisNodeFromCluster ¶
func RemoveRedisNodeFromCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, removePod RedisDetails)
Remove redis cluster node would remove last node to the existing redis cluster using redis-cli
func RepairDisconnectedMasters ¶
func RepairDisconnectedMasters(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster) error
RepairDisconnectedMasters attempts to repair disconnected/failed masters by issuing a CLUSTER MEET with the updated address of the host
func ReshardRedisCluster ¶
func ReshardRedisCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, shardIdx int32, transferNodeIdx int32, remove bool)
ReshardRedisCluster transfer the slots from the last node to the provided transfer node.
NOTE: when all slot been transferred, the node become slave of the transfer node.
func SetRedisClusterDynamicConfig ¶
func SetRedisClusterDynamicConfig(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster) error
SetRedisClusterDynamicConfig applies dynamic configuration to each Redis instance in the cluster
func UnhealthyNodesInCluster ¶
func UnhealthyNodesInCluster(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster) (int, error)
UnhealthyNodesInCluster returns the number of unhealthy nodes in the cluster cr
func VerifyLeaderPod ¶
func VerifyLeaderPod(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster, leadIndex int32) bool
verifyLeaderPod return true if the pod is leader/master
Types ¶
type K8sConfigProvider ¶
func GenerateK8sConfig ¶
func GenerateK8sConfig() K8sConfigProvider
GenerateK8sConfig will load the kube config file
type RedisClusterSTS ¶
type RedisClusterSTS struct { RedisStateFulType string ExternalConfig *string Resources *corev1.ResourceRequirements SecurityContext *corev1.SecurityContext Affinity *corev1.Affinity `json:"affinity,omitempty"` TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty" protobuf:"varint,4,opt,name=terminationGracePeriodSeconds"` ReadinessProbe *corev1.Probe LivenessProbe *corev1.Probe NodeSelector map[string]string TopologySpreadConstraints []corev1.TopologySpreadConstraint Tolerations *[]corev1.Toleration }
RedisClusterSTS is a interface to call Redis Statefulset function
func (RedisClusterSTS) CreateRedisClusterSetup ¶
func (service RedisClusterSTS) CreateRedisClusterSetup(ctx context.Context, cr *rcvb2.RedisCluster, cl kubernetes.Interface) error
CreateRedisClusterSetup will create Redis Setup for leader and follower
type RedisClusterService ¶
type RedisClusterService struct {
RedisServiceRole string
}
RedisClusterService is a interface to call Redis Service function
func (RedisClusterService) CreateRedisClusterService ¶
func (service RedisClusterService) CreateRedisClusterService(ctx context.Context, cr *rcvb2.RedisCluster, cl kubernetes.Interface) error
CreateRedisClusterService method will create service for Redis
type RedisDetails ¶
RedisDetails will hold the information for Redis Pod
type RedisInvocation ¶ added in v0.22.1
type RedisInvocation struct { Command []string // e.g. {"redis-cli", "--cluster", "create"} Flags []string // e.g. {"-h", "localhost", "-p", "6379"} RedisCommand []string // e.g. {"CLUSTER", "ADDSLOTS", "1", "2", "3"} }
RedisInvocation models an invocation of redis-cli
func CreateMultipleLeaderRedisCommand ¶
func CreateMultipleLeaderRedisCommand(ctx context.Context, client kubernetes.Interface, cr *rcvb2.RedisCluster) RedisInvocation
CreateMultipleLeaderRedisCommand will create command for single leader cluster creation
func CreateSingleLeaderRedisCommand ¶
func CreateSingleLeaderRedisCommand(ctx context.Context, cr *rcvb2.RedisCluster) RedisInvocation
CreateSingleLeaderRedisCommand will create command for single leader cluster creation
func (*RedisInvocation) AddFlag ¶ added in v0.22.1
func (ri *RedisInvocation) AddFlag(flag ...string) *RedisInvocation
func (*RedisInvocation) Args ¶ added in v0.22.1
func (ri *RedisInvocation) Args() []string
Builds the full argv for executeCommand
type RedisSentinelSTS ¶
type RedisSentinelSTS struct { RedisStateFulType string ExternalConfig *string Affinity *corev1.Affinity `json:"affinity,omitempty"` TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty" protobuf:"varint,4,opt,name=terminationGracePeriodSeconds"` ReadinessProbe *corev1.Probe LivenessProbe *corev1.Probe }
RedisSentinelSTS is a interface to call Redis Statefulset function
func (RedisSentinelSTS) CreateRedisSentinelSetup ¶
func (service RedisSentinelSTS) CreateRedisSentinelSetup(ctx context.Context, client kubernetes.Interface, cr *rsvb2.RedisSentinel, cl kubernetes.Interface, ctrlClient client.Client) error
Create Redis Sentinel Cluster Setup
type RedisSentinelService ¶
type RedisSentinelService struct {
RedisServiceRole string
}
RedisSentinelService is a interface to call Redis Service function
func (RedisSentinelService) CreateRedisSentinelService ¶
func (service RedisSentinelService) CreateRedisSentinelService(ctx context.Context, cr *rsvb2.RedisSentinel, cl kubernetes.Interface) error
Create the Service for redis sentinel
type StatefulSet ¶
type StatefulSetService ¶
type StatefulSetService struct {
// contains filtered or unexported fields
}
func NewStatefulSetService ¶
func NewStatefulSetService(kubeClient kubernetes.Interface) *StatefulSetService
func (*StatefulSetService) GetStatefulSetReplicas ¶
func (s *StatefulSetService) GetStatefulSetReplicas(ctx context.Context, namespace, name string) int32
func (*StatefulSetService) IsStatefulSetReady ¶
func (s *StatefulSetService) IsStatefulSetReady(ctx context.Context, namespace, name string) bool