cache

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorGetRedisClient               = "Get redis client error"
	ErrorGenerateRedisCr              = "Generate redis cr error"
	ErrorSetOwnerReference            = "Set owner reference error"
	ErrorCreateRedisSecret            = "Create redis secret error" // nolint:gosec
	ErrorCreateRedisCr                = "Create redis cr error"
	ErrorDefaultUnstructuredConverter = "Default unstructured converter error"
)
View Source
const (
	ComponentName  = "cluster-redis"
	ConfigImageKey = "redis-docker-image"
)
View Source
const (
	RedisSentinelConnPort  = 26379
	RedisSentinelConnGroup = "mymaster"
)

Variables

This section is empty.

Functions

func BuildRedisClient

func BuildRedisClient(host []string, port, password string, index int) *rediscli.Client

BuildRedisClient returns redis connection client.

func BuildRedisPool

func BuildRedisPool(redisSentinelIP []string, redisSentinelPort, redisSentinelPassword, redisGroupName string, redisIndex int) *rediscli.Client

BuildRedisPool returns redis connection pool client.

func GenHostInfo

func GenHostInfo(endpoint []string, port string) []string

GenHostInfo splice host and port.

func GenerateResourceList

func GenerateResourceList(cpu, memory string) (resources corev1.ResourceList, err error)

GenerateResourceList generates resource list by parsing parameters cpu and memory.

func GenerateStoragePVC

func GenerateStoragePVC(storageClass, name, size string, labels map[string]string) (*corev1.PersistentVolumeClaim, error)

GeneratePVC generates pvc by name and size.

func IsEqual

func IsEqual(obj1, obj2 interface{}) bool

IsEqual check two object is equal.

func MergeLabels

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

MergeLabels merges all labels together and returns a new label.

func NewRedisController

func NewRedisController(opts ...k8s.Option) lcm.Controller

NewRedisController is constructor for redis controller.

Types

type RedisConnect

type RedisConnect struct {
	Schema    string
	Endpoints []string
	Port      string
	Password  string
	GroupName string
}

func (*RedisConnect) NewRedisClient

func (c *RedisConnect) NewRedisClient() *rediscli.Client

NewRedisClient returns redis client.

func (*RedisConnect) NewRedisPool

func (c *RedisConnect) NewRedisPool() *rediscli.Client

NewRedisPool returns redis sentinel client.

type RedisController

type RedisController struct {
	DClient         *k8s.DynamicClientWrapper
	Client          client.Client
	Recorder        record.EventRecorder
	Log             logr.Logger
	Scheme          *runtime.Scheme
	RedisConnect    *RedisConnect
	ResourceManager ResourceManager
	ConfigStore     *configstore.Store
}

RedisController implements lcm.Controller interface.

func (*RedisController) Apply

func (rc *RedisController) Apply(ctx context.Context, cluster *goharborv1.HarborCluster, _ ...lcm.Option) (*lcm.CRStatus, error)

Apply creates/updates/scales the resources, like kubernetes apply operation.

func (*RedisController) Delete

Delete...

func (*RedisController) Deploy

func (rc *RedisController) Deploy(ctx context.Context, cluster *goharborv1.HarborCluster) (*lcm.CRStatus, error)

Deploy will deploy Redis sentinel cluster if that does not exist. It does: - check redis does exist - create any new RedisFailovers CRs - create redis password secret It does not: - perform any RedisFailovers downscale (left for downscale phase) - perform any RedisFailovers upscale (left for upscale phase) - perform any pod upgrade (left for rolling upgrade phase).

func (*RedisController) DeploySecret

func (rc *RedisController) DeploySecret(ctx context.Context, cluster *goharborv1.HarborCluster) error

func (*RedisController) GetDeploymentPods

func (rc *RedisController) GetDeploymentPods(ctx context.Context, name, namespace string) (*appsv1.Deployment, *corev1.PodList, error)

GetDeploymentPods returns the Redis Sentinel pod list.

func (*RedisController) GetPodsStatus

func (rc *RedisController) GetPodsStatus(podArray []corev1.Pod) ([]corev1.Pod, []corev1.Pod)

GetPodsStatus returns deleting and current pod list.

func (*RedisController) GetRedisPassword

func (rc *RedisController) GetRedisPassword(ctx context.Context, secretName, namespace string) (string, error)

GetRedisPassword is get redis password.

func (*RedisController) GetRedisSecret

func (rc *RedisController) GetRedisSecret(ctx context.Context, secretName, namespace string) (map[string][]byte, error)

GetRedisSecret returns the Redis Password Secret.

func (*RedisController) GetSentinelServiceURL

func (rc *RedisController) GetSentinelServiceURL(name, namespace string, pods []corev1.Pod) string

GetSentinelServiceURL returns the Redis Sentinel pod ip or service name.

func (*RedisController) GetStatefulSetPods

func (rc *RedisController) GetStatefulSetPods(ctx context.Context, name, namespace string) (*appsv1.StatefulSet, *corev1.PodList, error)

GetStatefulSetPods returns the Redis Server pod list.

func (*RedisController) Readiness

func (rc *RedisController) Readiness(_ context.Context, cluster *goharborv1.HarborCluster) (*lcm.CRStatus, error)

Readiness reconcile will check Redis sentinel cluster if that has available. It does: - create redis connection pool - ping redis server - return redis properties if redis has available.

func (*RedisController) RollingUpgrades

func (rc *RedisController) RollingUpgrades(ctx context.Context, cluster *goharborv1.HarborCluster, actualObj, expectObj runtime.Object) (*lcm.CRStatus, error)

RollingUpgrades reconcile will rolling upgrades Redis sentinel cluster if resource upscale. It does: - check resource - update RedisFailovers CR resource.

func (*RedisController) Update

func (rc *RedisController) Update(ctx context.Context, cluster *goharborv1.HarborCluster, actualObj, expectObj runtime.Object) (*lcm.CRStatus, error)

func (*RedisController) Upgrade

type ResourceGetter

type ResourceGetter interface {
	GetCacheCR(ctx context.Context, harborcluster *goharborv1.HarborCluster) (runtime.Object, error)
	GetCacheCRName() string
	GetResources() corev1.ResourceRequirements
	GetSecretName() string
	GetSecret() *corev1.Secret
	GetServerReplica() int
	GetClusterServerReplica() int
	GetStorageSize() string
}

ResourceGetter gets resources.

type ResourceManager

type ResourceManager interface {
	ResourceGetter
	// With the specified cluster
	WithCluster(cluster *goharborv1.HarborCluster) ResourceManager
}

ResourceManager defines the common interface of resources.

func NewResourceManager

func NewResourceManager(store *configstore.Store, logger logr.Logger, scheme *runtime.Scheme) ResourceManager

NewResourceManager constructs a new cache resource manager.

Jump to

Keyboard shortcuts

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