Documentation
¶
Index ¶
- Constants
- func BuildRedisClient(host []string, port, password string, index int) *rediscli.Client
- func BuildRedisPool(redisSentinelIP []string, ...) *rediscli.Client
- func GenHostInfo(endpoint []string, port string) []string
- func GenerateResourceList(cpu string, memory string) corev1.ResourceList
- func GetExternalRedisHost(spec *goharborv1.RedisSpec) ([]string, string)
- func IsEqual(actualCR, expectCR redisCli.RedisFailover) bool
- func MergeLabels(allLabels ...map[string]string) map[string]string
- func Update(crdClient k8s.DClient, actualCR, expectCR redisCli.RedisFailover) error
- type RedisConnect
- type RedisReconciler
- func (redis *RedisReconciler) Delete() (*lcm.CRStatus, error)
- func (redis *RedisReconciler) Deploy() (*lcm.CRStatus, error)
- func (redis *RedisReconciler) DeployComponentSecret(component, url, namespace, secretName string) error
- func (redis *RedisReconciler) DeploySecret() error
- func (redis *RedisReconciler) DeployService() error
- func (redis *RedisReconciler) GetDeploymentPods() (*appsv1.Deployment, *corev1.PodList, error)
- func (redis *RedisReconciler) GetExternalRedisInfo() (*rediscli.Client, error)
- func (redis *RedisReconciler) GetExternalRedisPassword(spec *goharborv1.RedisSpec) (string, error)
- func (redis *RedisReconciler) GetHarborClusterName() string
- func (redis *RedisReconciler) GetHarborClusterNamespace() string
- func (redis *RedisReconciler) GetInClusterRedisInfo() (*rediscli.Client, error)
- func (redis *RedisReconciler) GetPodsStatus(podArray []corev1.Pod) ([]corev1.Pod, []corev1.Pod)
- func (redis *RedisReconciler) GetRedisFailover() (*redisCli.RedisFailover, error)
- func (redis *RedisReconciler) GetRedisName() string
- func (redis *RedisReconciler) GetRedisPassword(secretName string) (string, error)
- func (redis *RedisReconciler) GetRedisResource() corev1.ResourceList
- func (redis *RedisReconciler) GetRedisSecret(secretName string) (map[string][]byte, error)
- func (redis *RedisReconciler) GetRedisSentinelReplica() int32
- func (redis *RedisReconciler) GetRedisServerReplica() int32
- func (redis *RedisReconciler) GetRedisServiceUrl(pods []corev1.Pod) string
- func (redis *RedisReconciler) GetRedisStorageSize() string
- func (redis *RedisReconciler) GetSentinelServiceUrl(pods []corev1.Pod) string
- func (redis *RedisReconciler) GetStatefulSetPods() (*appsv1.StatefulSet, *corev1.PodList, error)
- func (redis *RedisReconciler) NewLabels() map[string]string
- func (redis *RedisReconciler) Provision() (*lcm.CRStatus, error)
- func (redis *RedisReconciler) Readiness() (*lcm.CRStatus, error)
- func (redis *RedisReconciler) Reconcile() (*lcm.CRStatus, error)
- func (redis *RedisReconciler) RollingUpgrades() (*lcm.CRStatus, error)
- func (redis *RedisReconciler) Scale() (*lcm.CRStatus, error)
- func (redis *RedisReconciler) Update(spec *goharborv1.HarborCluster) (*lcm.CRStatus, error)
Constants ¶
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" )
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" )
const ( RedisSentinelSchema = "sentinel" RedisServerSchema = "redis" )
const ( HarborChartMuseum = "chartMuseum" HarborClair = "clair" HarborJobService = "jobService" HarborRegistry = "registry" HarborCore = "coreURL" )
const ( ReidsType = "rfr" SentinelType = "rfs" RoleName = "harbor-cluster" RedisSentinelPort = "26379" )
const (
AppLabel = "goharbor.io/harbor-cluster"
)
Variables ¶
This section is empty.
Functions ¶
func BuildRedisClient ¶
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 ¶
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 ¶
MergeLabels merge new label to existing labels
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) 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 ¶
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) Update ¶
func (redis *RedisReconciler) Update(spec *goharborv1.HarborCluster) (*lcm.CRStatus, error)