cache

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RedisDownScaling     = "RedisDownScaling"
	RedisUpScaling       = "RedisUpScaling"
	RedisRollingUpgrades = "RollingUpgrades"

	MessageRedisCluster = "Redis  %s already created."

	UpdateMessageRedisCluster = "Redis  %s already update."

	MessageRedisDownScaling     = "Redis downscale from %d to %d"
	MessageRedisUpScaling       = "Redis upscale from %d to %d"
	MessageRedisRollingUpgrades = "Redis resource from %s to %s"

	RedisSentinelConnPort  = "26379"
	RedisRedisConnPort     = "6379"
	RedisSentinelConnGroup = "mymaster"
)
View Source
const (
	GetRedisClientError               = "Get redis client error"
	CheckRedisHealthError             = "Check redis health error"
	CreateComponentSecretError        = "Create component secret error"
	GenerateRedisCrError              = "Generate redis cr error"
	SetOwnerReferenceError            = "Set owner reference error"
	CreateRedisSecretError            = "Create redis secret error"
	CreateRedisCrError                = "Create redis cr error"
	CreateRedisServerServiceError     = "Create redis server service error"
	GetRedisCrError                   = "Get redis cr error"
	GetRedisServerPodError            = "Get redis server pod error"
	GetRedisSentinelPodError          = "Get redis sentinel pod error"
	GetRedisPasswordError             = "Get redis password error"
	CheckRedisIsMasterError           = "Check redis isMaster error"
	ManualFailoverRedisError          = "Manual failover redis error"
	UpdateRedisCrError                = "Update redis cr error"
	DefaultUnstructuredConverterError = "Default unstructured converter error"
)
View Source
const (
	RedisSentinelSchema = "sentinel"
	RedisServerSchema   = "redis"
)
View Source
const (
	HarborChartMuseum = "chartMuseum"
	HarborClair       = "clair"
	HarborJobService  = "jobService"
	HarborRegistry    = "registry"
	HarborCore        = "coreURL"
)
View Source
const (
	ReidsType    = "rfr"
	SentinelType = "rfs"

	RoleName          = "harbor-cluster"
	RedisSentinelPort = "26379"
)
View Source
const (
	AppLabel = "goharbor.io/harbor-cluster"
)

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 string, memory string) corev1.ResourceList

GenerateResourceList returns resource list

func GetExternalRedisHost

func GetExternalRedisHost(spec *goharborv1.RedisSpec) ([]string, string)

GetExternalRedisHost returns external redis host list and port

func IsEqual

func IsEqual(actualCR, expectCR redisCli.RedisFailover) bool

isEqual check whether cache cr is equal expect.

func MergeLabels

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

MergeLabels merge new label to existing labels

func Update

func Update(crdClient k8s.DClient, actualCR, expectCR redisCli.RedisFailover) error

Types

type RedisConnect

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

func (*RedisConnect) GenRedisConnURL

func (c *RedisConnect) GenRedisConnURL(component string) string

GenRedisConnURL returns harbor component redis secret

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 RedisReconciler

type RedisReconciler struct {
	HarborCluster *goharborv1.HarborCluster
	CXT           context.Context
	Client        k8s.Client
	Recorder      record.EventRecorder
	Log           logr.Logger
	DClient       k8s.DClient
	Scheme        *runtime.Scheme
	ExpectCR      *unstructured.Unstructured
	ActualCR      *unstructured.Unstructured
	Labels        map[string]string
	RedisConnect  *RedisConnect
}

RedisReconciler implement the Reconciler interface and lcm.Controller interface.

func (*RedisReconciler) Delete

func (redis *RedisReconciler) Delete() (*lcm.CRStatus, error)

func (*RedisReconciler) Deploy

func (redis *RedisReconciler) Deploy() (*lcm.CRStatus, error)

Deploy reconcile 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 (*RedisReconciler) DeployComponentSecret

func (redis *RedisReconciler) DeployComponentSecret(component, url, namespace, secretName string) error

DeployComponentSecret deploy harbor component redis secret

func (*RedisReconciler) DeploySecret

func (redis *RedisReconciler) DeploySecret() error

DeploySecret deploy the Redis Password Secret

func (*RedisReconciler) DeployService

func (redis *RedisReconciler) DeployService() error

DeploySecret deploy the Redis Password Secret

func (*RedisReconciler) GetDeploymentPods

func (redis *RedisReconciler) GetDeploymentPods() (*appsv1.Deployment, *corev1.PodList, error)

GetDeploymentPods returns the Redis Sentinel pod list

func (*RedisReconciler) GetExternalRedisInfo

func (redis *RedisReconciler) GetExternalRedisInfo() (*rediscli.Client, error)

func (*RedisReconciler) GetExternalRedisPassword

func (redis *RedisReconciler) GetExternalRedisPassword(spec *goharborv1.RedisSpec) (string, error)

GetExternalRedisPassword returns external redis password

func (*RedisReconciler) GetHarborClusterName

func (redis *RedisReconciler) GetHarborClusterName() string

GetHarborClusterName returns harbor cluster name

func (*RedisReconciler) GetHarborClusterNamespace

func (redis *RedisReconciler) GetHarborClusterNamespace() string

GetHarborClusterNamespace returns harbor cluster namespace

func (*RedisReconciler) GetInClusterRedisInfo

func (redis *RedisReconciler) GetInClusterRedisInfo() (*rediscli.Client, error)

GetInClusterRedisInfo returns inCluster redis sentinel pool client

func (*RedisReconciler) GetPodsStatus

func (redis *RedisReconciler) GetPodsStatus(podArray []corev1.Pod) ([]corev1.Pod, []corev1.Pod)

GetPodsStatus returns deleting and current pod list

func (*RedisReconciler) GetRedisFailover

func (redis *RedisReconciler) GetRedisFailover() (*redisCli.RedisFailover, error)

GetRedisFailover returns RedisFailover object

func (*RedisReconciler) GetRedisName

func (redis *RedisReconciler) GetRedisName() string

GetRedisName returns the name for redis resources

func (*RedisReconciler) GetRedisPassword

func (redis *RedisReconciler) GetRedisPassword(secretName string) (string, error)

GetRedisPassword is get redis password

func (*RedisReconciler) GetRedisResource

func (redis *RedisReconciler) GetRedisResource() corev1.ResourceList

GetRedisResource returns redis resource

func (*RedisReconciler) GetRedisSecret

func (redis *RedisReconciler) GetRedisSecret(secretName string) (map[string][]byte, error)

GetRedisSecret returns the Redis Password Secret

func (*RedisReconciler) GetRedisSentinelReplica

func (redis *RedisReconciler) GetRedisSentinelReplica() int32

GetRedisSentinelReplica returns redis sentinel replicas

func (*RedisReconciler) GetRedisServerReplica

func (redis *RedisReconciler) GetRedisServerReplica() int32

GetRedisServerReplica returns redis server replicas

func (*RedisReconciler) GetRedisServiceUrl

func (redis *RedisReconciler) GetRedisServiceUrl(pods []corev1.Pod) string

GetRedisServiceUrl returns the Redis server pod ip or service name

func (*RedisReconciler) GetRedisStorageSize

func (redis *RedisReconciler) GetRedisStorageSize() string

GetRedisStorageSize returns redis server storage size

func (*RedisReconciler) GetSentinelServiceUrl

func (redis *RedisReconciler) GetSentinelServiceUrl(pods []corev1.Pod) string

GetServiceUrl returns the Redis Sentinel pod ip or service name

func (*RedisReconciler) GetStatefulSetPods

func (redis *RedisReconciler) GetStatefulSetPods() (*appsv1.StatefulSet, *corev1.PodList, error)

GetStatefulSetPods returns the Redis Server pod list

func (*RedisReconciler) NewLabels

func (redis *RedisReconciler) NewLabels() map[string]string

NewLabels returns new labels

func (*RedisReconciler) Provision

func (redis *RedisReconciler) Provision() (*lcm.CRStatus, error)

func (*RedisReconciler) Readiness

func (redis *RedisReconciler) Readiness() (*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 (*RedisReconciler) Reconcile

func (redis *RedisReconciler) Reconcile() (*lcm.CRStatus, error)

Reconciler implements the reconcile logic of redis service

func (*RedisReconciler) RollingUpgrades

func (redis *RedisReconciler) RollingUpgrades() (*lcm.CRStatus, error)

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

func (*RedisReconciler) Scale

func (redis *RedisReconciler) Scale() (*lcm.CRStatus, error)

func (*RedisReconciler) Update

func (redis *RedisReconciler) Update(spec *goharborv1.HarborCluster) (*lcm.CRStatus, error)

Jump to

Keyboard shortcuts

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