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, memory string) (resources corev1.ResourceList, err error)
- func GenerateStoragePVC(storageClass, name, size string, labels map[string]string) (*corev1.PersistentVolumeClaim, error)
- func IsEqual(obj1, obj2 interface{}) bool
- func MergeLabels(allLabels ...map[string]string) map[string]string
- func NewRedisController(opts ...k8s.Option) lcm.Controller
- type RedisConnect
- type RedisController
- func (rc *RedisController) Apply(ctx context.Context, cluster *goharborv1.HarborCluster, _ ...lcm.Option) (*lcm.CRStatus, error)
- func (rc *RedisController) Delete(_ context.Context, _ *goharborv1.HarborCluster) (*lcm.CRStatus, error)
- func (rc *RedisController) Deploy(ctx context.Context, cluster *goharborv1.HarborCluster) (*lcm.CRStatus, error)
- func (rc *RedisController) DeploySecret(ctx context.Context, cluster *goharborv1.HarborCluster) error
- func (rc *RedisController) GetDeploymentPods(ctx context.Context, name, namespace string) (*appsv1.Deployment, *corev1.PodList, error)
- func (rc *RedisController) GetPodsStatus(podArray []corev1.Pod) ([]corev1.Pod, []corev1.Pod)
- func (rc *RedisController) GetRedisPassword(ctx context.Context, secretName, namespace string) (string, error)
- func (rc *RedisController) GetRedisSecret(ctx context.Context, secretName, namespace string) (map[string][]byte, error)
- func (rc *RedisController) GetSentinelServiceURL(name, namespace string, pods []corev1.Pod) string
- func (rc *RedisController) GetStatefulSetPods(ctx context.Context, name, namespace string) (*appsv1.StatefulSet, *corev1.PodList, error)
- func (rc *RedisController) Readiness(_ context.Context, cluster *goharborv1.HarborCluster) (*lcm.CRStatus, error)
- func (rc *RedisController) RollingUpgrades(ctx context.Context, cluster *goharborv1.HarborCluster, ...) (*lcm.CRStatus, error)
- func (rc *RedisController) Update(ctx context.Context, cluster *goharborv1.HarborCluster, ...) (*lcm.CRStatus, error)
- func (rc *RedisController) Upgrade(_ context.Context, _ *goharborv1.HarborCluster) (*lcm.CRStatus, error)
- type ResourceGetter
- type ResourceManager
Constants ¶
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" )
const ( RedisSentinelConnPort = 26379 RedisSentinelConnGroup = "mymaster" )
const (
ComponentName = "cluster-redis"
)
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, 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 MergeLabels ¶
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 ¶
func (rc *RedisController) Delete(_ context.Context, _ *goharborv1.HarborCluster) (*lcm.CRStatus, error)
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 ¶
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 ¶
func (rc *RedisController) Upgrade(_ context.Context, _ *goharborv1.HarborCluster) (*lcm.CRStatus, error)
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.