Documentation ¶
Index ¶
- Constants
- func AddFinalizer(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, logger logr.Logger, ...)
- func CheckIfEmptyMasters(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...)
- func CheckRedisClusterState(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...) int
- func CheckRedisNodeCount(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...) int32
- func ClusterFailover(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...)
- func CreateMasterSlaveReplication(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...) error
- func CreateMultipleLeaderRedisCommand(client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster) []string
- func CreateOrUpdatePodDisruptionBudget(pdbDef *policyv1.PodDisruptionBudget, cl kubernetes.Interface) error
- func CreateOrUpdateService(namespace string, serviceMeta metav1.ObjectMeta, ...) error
- func CreateOrUpdateStateFul(cl kubernetes.Interface, logger logr.Logger, namespace string, ...) error
- func CreateRedisFollower(cr *redisv1beta2.RedisCluster, cl kubernetes.Interface) error
- func CreateRedisFollowerService(cr *redisv1beta2.RedisCluster, cl kubernetes.Interface) error
- func CreateRedisLeader(cr *redisv1beta2.RedisCluster, cl kubernetes.Interface) error
- func CreateRedisLeaderService(cr *redisv1beta2.RedisCluster, cl kubernetes.Interface) error
- func CreateRedisSentinel(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...) error
- func CreateRedisSentinelService(cr *redisv1beta2.RedisSentinel, cl kubernetes.Interface) error
- func CreateReplicationRedis(cr *redisv1beta2.RedisReplication, cl kubernetes.Interface) error
- func CreateReplicationService(cr *redisv1beta2.RedisReplication, cl kubernetes.Interface) error
- func CreateSingleLeaderRedisCommand(logger logr.Logger, cr *redisv1beta2.RedisCluster) []string
- func CreateStandaloneRedis(cr *redisv1beta2.Redis, cl kubernetes.Interface) error
- func CreateStandaloneService(cr *redisv1beta2.Redis, cl kubernetes.Interface) error
- func ExecuteFailoverOperation(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...) error
- func ExecuteRedisClusterCommand(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...)
- func ExecuteRedisReplicationCommand(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...)
- func GenerateK8sClient(configProvider K8sConfigProvider) (kubernetes.Interface, error)
- func GenerateK8sDynamicClient(configProvider K8sConfigProvider) (dynamic.Interface, error)
- func GenerateTLSEnvironmentVariables(tlsconfig *redisv1beta2.TLSConfig) []corev1.EnvVar
- func GetPodDisruptionBudget(namespace string, pdb string, cl kubernetes.Interface) (*policyv1.PodDisruptionBudget, error)
- func GetRedisNodesByRole(ctx context.Context, cl kubernetes.Interface, logger logr.Logger, ...) []string
- func GetRedisReplicationLabels(cr *redisv1beta2.RedisReplication) map[string]string
- func GetRedisReplicationRealMaster(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...) string
- func GetStatefulSet(cl kubernetes.Interface, logger logr.Logger, namespace string, name string) (*appsv1.StatefulSet, error)
- func HandleRedisClusterFinalizer(ctrlclient client.Client, k8sClient kubernetes.Interface, logger logr.Logger, ...) error
- func HandleRedisFinalizer(ctrlclient client.Client, k8sClient kubernetes.Interface, logger logr.Logger, ...) error
- func HandleRedisReplicationFinalizer(ctrlclient client.Client, k8sClient kubernetes.Interface, logger logr.Logger, ...) error
- func HandleRedisSentinelFinalizer(ctrlclient client.Client, logger logr.Logger, cr *redisv1beta2.RedisSentinel) error
- func IsRedisReplicationReady(ctx context.Context, logger logr.Logger, client kubernetes.Interface, ...) bool
- func LabelSelectors(labels map[string]string) *metav1.LabelSelector
- func RebalanceRedisCluster(client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster)
- func RebalanceRedisClusterEmptyMasters(client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster)
- func ReconcileRedisPodDisruptionBudget(cr *redisv1beta2.RedisCluster, role string, ...) error
- func ReconcileSentinelPodDisruptionBudget(cr *redisv1beta2.RedisSentinel, pdbParams *commonapi.RedisPodDisruptionBudget, ...) error
- func RedisClusterStatusHealth(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...) bool
- func RemoveRedisFollowerNodesFromCluster(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...)
- func RemoveRedisNodeFromCluster(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...)
- func ReshardRedisCluster(client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster, ...)
- func UpdateRedisClusterStatus(cr *redisv1beta2.RedisCluster, state status.RedisClusterState, reason string, ...) error
- func VerifyLeaderPod(ctx context.Context, client kubernetes.Interface, logger logr.Logger, ...) bool
- type K8sConfigProvider
- type Pod
- type PodService
- type RedisClusterSTS
- type RedisClusterService
- type RedisDetails
- type RedisReplicationObject
- type RedisSentinelSTS
- type RedisSentinelService
- type StatefulSet
- type StatefulSetService
Constants ¶
const ( RedisRoleLabelKey = "redis-role" RedisRoleLabelMaster = "master" RedisRoleLabelSlave = "slave" )
const ( RedisFinalizer string = "redisFinalizer" RedisClusterFinalizer string = "redisClusterFinalizer" RedisReplicationFinalizer string = "redisReplicationFinalizer" RedisSentinelFinalizer string = "redisSentinelFinalizer" )
const (
AnnotationKeyRecreateStatefulset = "redis.opstreelabs.in/recreate-statefulset"
)
const (
EnvOperatorSTSPVCTemplateName = "OPERATOR_STS_PVC_TEMPLATE_NAME"
)
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, logger logr.Logger, cr *redisv1beta2.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, logger logr.Logger, cr *redisv1beta2.RedisCluster)
func CheckRedisClusterState ¶
func CheckRedisClusterState(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster) int
CheckRedisClusterState will check the redis cluster state
func CheckRedisNodeCount ¶
func CheckRedisNodeCount(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster, nodeType string) int32
CheckRedisNodeCount will check the count of redis nodes
func ClusterFailover ¶
func ClusterFailover(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster)
func CreateMasterSlaveReplication ¶
func CreateMasterSlaveReplication(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisReplication, masterPods []string, realMasterPod string) error
func CreateMultipleLeaderRedisCommand ¶
func CreateMultipleLeaderRedisCommand(client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster) []string
CreateMultipleLeaderRedisCommand will create command for single leader cluster creation
func CreateOrUpdatePodDisruptionBudget ¶
func CreateOrUpdatePodDisruptionBudget(pdbDef *policyv1.PodDisruptionBudget, cl kubernetes.Interface) error
CreateOrUpdateService method will create or update Redis service
func CreateOrUpdateService ¶
func CreateOrUpdateService(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(cl kubernetes.Interface, logger logr.Logger, namespace string, stsMeta metav1.ObjectMeta, params statefulSetParameters, ownerDef metav1.OwnerReference, initcontainerParams initContainerParameters, containerParams containerParameters, sidecars *[]redisv1beta2.Sidecar) error
CreateOrUpdateStateFul method will create or update Redis service
func CreateRedisFollower ¶
func CreateRedisFollower(cr *redisv1beta2.RedisCluster, cl kubernetes.Interface) error
CreateRedisFollower will create a follower redis setup
func CreateRedisFollowerService ¶
func CreateRedisFollowerService(cr *redisv1beta2.RedisCluster, cl kubernetes.Interface) error
CreateRedisFollowerService method will create service for Redis Follower
func CreateRedisLeader ¶
func CreateRedisLeader(cr *redisv1beta2.RedisCluster, cl kubernetes.Interface) error
CreateRedisLeader will create a leader redis setup
func CreateRedisLeaderService ¶
func CreateRedisLeaderService(cr *redisv1beta2.RedisCluster, cl kubernetes.Interface) error
CreateRedisLeaderService method will create service for Redis Leader
func CreateRedisSentinel ¶
func CreateRedisSentinel(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisSentinel, cl kubernetes.Interface, dcl dynamic.Interface) error
Redis Sentinel Create the Redis Sentinel Setup
func CreateRedisSentinelService ¶
func CreateRedisSentinelService(cr *redisv1beta2.RedisSentinel, cl kubernetes.Interface) error
Create RedisSentinel Service
func CreateReplicationRedis ¶
func CreateReplicationRedis(cr *redisv1beta2.RedisReplication, cl kubernetes.Interface) error
CreateReplicationRedis will create a replication redis setup
func CreateReplicationService ¶
func CreateReplicationService(cr *redisv1beta2.RedisReplication, cl kubernetes.Interface) error
CreateReplicationService method will create replication service for Redis
func CreateSingleLeaderRedisCommand ¶
func CreateSingleLeaderRedisCommand(logger logr.Logger, cr *redisv1beta2.RedisCluster) []string
CreateSingleLeaderRedisCommand will create command for single leader cluster creation
func CreateStandaloneRedis ¶
func CreateStandaloneRedis(cr *redisv1beta2.Redis, cl kubernetes.Interface) error
CreateStandaloneRedis will create a standalone redis setup
func CreateStandaloneService ¶
func CreateStandaloneService(cr *redisv1beta2.Redis, cl kubernetes.Interface) error
CreateStandaloneService method will create standalone service for Redis
func ExecuteFailoverOperation ¶
func ExecuteFailoverOperation(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster) error
ExecuteFailoverOperation will execute redis failover operations
func ExecuteRedisClusterCommand ¶
func ExecuteRedisClusterCommand(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster)
ExecuteRedisClusterCommand will execute redis cluster creation command
func ExecuteRedisReplicationCommand ¶
func ExecuteRedisReplicationCommand(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster)
ExecuteRedisReplicationCommand will execute the replication command
func GenerateK8sClient ¶
func GenerateK8sClient(configProvider K8sConfigProvider) (kubernetes.Interface, error)
GenerateK8sClient create client for kubernetes
func GenerateK8sDynamicClient ¶
func GenerateK8sDynamicClient(configProvider K8sConfigProvider) (dynamic.Interface, error)
GenerateK8sClient create Dynamic client for kubernetes
func GenerateTLSEnvironmentVariables ¶
func GenerateTLSEnvironmentVariables(tlsconfig *redisv1beta2.TLSConfig) []corev1.EnvVar
func GetPodDisruptionBudget ¶
func GetPodDisruptionBudget(namespace string, pdb string, cl kubernetes.Interface) (*policyv1.PodDisruptionBudget, error)
GetPodDisruptionBudget is a method to get PodDisruptionBudgets in Kubernetes
func GetRedisNodesByRole ¶
func GetRedisNodesByRole(ctx context.Context, cl kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisReplication, redisRole string) []string
Get Redis nodes by it's role i.e. master, slave and sentinel
func GetRedisReplicationLabels ¶
func GetRedisReplicationLabels(cr *redisv1beta2.RedisReplication) map[string]string
func GetRedisReplicationRealMaster ¶
func GetRedisReplicationRealMaster(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisReplication, masterPods []string) string
func GetStatefulSet ¶
func GetStatefulSet(cl kubernetes.Interface, logger logr.Logger, namespace string, name string) (*appsv1.StatefulSet, error)
GetStateFulSet is a method to get statefulset in Kubernetes
func HandleRedisClusterFinalizer ¶
func HandleRedisClusterFinalizer(ctrlclient client.Client, k8sClient kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster) error
HandleRedisClusterFinalizer finalize resource if instance is marked to be deleted
func HandleRedisFinalizer ¶
func HandleRedisFinalizer(ctrlclient client.Client, k8sClient kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.Redis) error
HandleRedisFinalizer finalize resource if instance is marked to be deleted
func HandleRedisReplicationFinalizer ¶
func HandleRedisReplicationFinalizer(ctrlclient client.Client, k8sClient kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisReplication) error
Handle RedisReplicationFinalizer finalize resource if instance is marked to be deleted
func HandleRedisSentinelFinalizer ¶
func HandleRedisSentinelFinalizer(ctrlclient client.Client, logger logr.Logger, cr *redisv1beta2.RedisSentinel) error
HandleRedisSentinelFinalizer finalize resource if instance is marked to be deleted
func IsRedisReplicationReady ¶
func IsRedisReplicationReady(ctx context.Context, logger logr.Logger, client kubernetes.Interface, dClient dynamic.Interface, rs *redisv1beta2.RedisSentinel) bool
func LabelSelectors ¶
func LabelSelectors(labels map[string]string) *metav1.LabelSelector
LabelSelectors generates object for label selection
func RebalanceRedisCluster ¶
func RebalanceRedisCluster(client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster)
Rebalance Redis Cluster Would Rebalance the Redis Cluster without using the empty masters
func RebalanceRedisClusterEmptyMasters ¶
func RebalanceRedisClusterEmptyMasters(client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster)
Rebalance the Redis CLuster using the Empty Master Nodes
func ReconcileRedisPodDisruptionBudget ¶
func ReconcileRedisPodDisruptionBudget(cr *redisv1beta2.RedisCluster, role string, pdbParams *commonapi.RedisPodDisruptionBudget, cl kubernetes.Interface) error
CreateRedisLeaderPodDisruptionBudget check and create a PodDisruptionBudget for Leaders
func ReconcileSentinelPodDisruptionBudget ¶
func ReconcileSentinelPodDisruptionBudget(cr *redisv1beta2.RedisSentinel, pdbParams *commonapi.RedisPodDisruptionBudget, cl kubernetes.Interface) error
func RedisClusterStatusHealth ¶
func RedisClusterStatusHealth(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster) bool
RedisClusterStatusHealth use `redis-cli --cluster check 127.0.0.1:6379`
func RemoveRedisFollowerNodesFromCluster ¶
func RemoveRedisFollowerNodesFromCluster(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster)
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, logger logr.Logger, cr *redisv1beta2.RedisCluster, removePod RedisDetails)
Remove redis cluster node would remove last node to the existing redis cluster using redis-cli
func ReshardRedisCluster ¶
func ReshardRedisCluster(client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster, remove bool)
ReshardRedisCluster transfer the slots from the last node to the first node.
NOTE: when all slot been transferred, the node become slave of the first master node.
func UpdateRedisClusterStatus ¶
func UpdateRedisClusterStatus(cr *redisv1beta2.RedisCluster, state status.RedisClusterState, reason string, readyLeaderReplicas, readyFollowerReplicas int32, dcl dynamic.Interface) error
UpdateRedisClusterStatus will update the status of the RedisCluster
func VerifyLeaderPod ¶
func VerifyLeaderPod(ctx context.Context, client kubernetes.Interface, logger logr.Logger, cr *redisv1beta2.RedisCluster) 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 PodService ¶
type PodService struct {
// contains filtered or unexported fields
}
func NewPodService ¶
func NewPodService(kubeClient kubernetes.Interface, log logr.Logger) *PodService
func (*PodService) PatchPodLabels ¶
type RedisClusterSTS ¶
type RedisClusterSTS struct { RedisStateFulType string ExternalConfig *string 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 Tolerations *[]corev1.Toleration }
RedisClusterSTS is a interface to call Redis Statefulset function
func (RedisClusterSTS) CreateRedisClusterSetup ¶
func (service RedisClusterSTS) CreateRedisClusterSetup(cr *redisv1beta2.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(cr *redisv1beta2.RedisCluster, cl kubernetes.Interface) error
CreateRedisClusterService method will create service for Redis
type RedisDetails ¶
RedisDetails will hold the information for Redis Pod
type RedisReplicationObject ¶
type RedisReplicationObject struct {
RedisReplication *redisv1beta2.RedisReplication
}
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, logger logr.Logger, cr *redisv1beta2.RedisSentinel, cl kubernetes.Interface, dcl dynamic.Interface) 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(cr *redisv1beta2.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, log logr.Logger) *StatefulSetService
func (*StatefulSetService) IsStatefulSetReady ¶
func (s *StatefulSetService) IsStatefulSetReady(ctx context.Context, namespace, name string) bool