util

package
v0.0.0-...-0227cab Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseName                      = "rf"
	SentinelName                  = "s"
	SentinelRoleName              = "sentinel"
	SentinelConfigFileName        = "sentinel.conf"
	RedisConfigFileName           = "redis.conf"
	RedisName                     = "r"
	RedisShutdownName             = "r-s"
	RedisReadinessName            = "r-readiness"
	RedisRoleName                 = "redis"
	RedisMasterName               = "mymaster"
	AppLabel                      = "redis-failover"
	HostnameTopologyKey           = "kubernetes.io/hostname"
	RedisBackupServiceAccountName = "redis-backup"
	RedisBackupRoleName           = "redis-backup"
	RedisBackupRoleBindingName    = "redis-backup"
)
View Source
const (
	RedisConfigFileNameBackup = "redis.conf.bk"
	RedisInitScript           = "init.sh"
	SentinelEntrypoint        = "entrypoint.sh"
	RedisBackupVolumeName     = "backup-data"
	S3SecretVolumeName        = "s3-secret"
)
View Source
const (
	ExporterPort                  = 9121
	SentinelExporterPort          = 9355
	SentinelPort                  = "26379"
	ExporterPortName              = "http-metrics"
	RedisPort                     = 6379
	RedisPortString               = "6379"
	RedisPortName                 = "redis"
	ExporterContainerName         = "redis-exporter"
	SentinelExporterContainerName = "sentinel-exporter"
	RestoreContainerName          = "restore"
	ExporterDefaultRequestCPU     = "25m"
	ExporterDefaultLimitCPU       = "50m"
	ExporterDefaultRequestMemory  = "50Mi"
	ExporterDefaultLimitMemory    = "100Mi"
)

variables refering to the redis exporter port

View Source
const (
	LabelInstanceName     = "app.kubernetes.io/name"
	LabelPartOf           = "app.kubernetes.io/part-of"
	LabelRedisConfig      = "redis.middleware.alauda.io/config"
	LabelRedisConfigValue = "true"
	LabelRedisRole        = "redis.middleware.alauda.io/role"
)

label

View Source
const (
	Master = "master"
	Slave  = "slave"
)

Redis role

View Source
const (
	LabelRedisArch = "redisarch"
)

Redis arch

Variables

This section is empty.

Functions

func BuildOwnerReferences

func BuildOwnerReferences(obj client.Object) (refs []metav1.OwnerReference)

func BuildOwnerReferencesWithParents

func BuildOwnerReferencesWithParents(obj client.Object) (refs []metav1.OwnerReference)

func CheckRule

func CheckRule(aclRules string) error

func CheckUserRuleUpdate

func CheckUserRuleUpdate(ruleSource string) error

func CompareStrings

func CompareStrings(a, b string) int

CompareStrings 比较两个字符串,返回 -1, 0, 1

func ConvertMemoryUnit

func ConvertMemoryUnit(p string) (string, error)

ConvertMemoryUnit

func ExtractLastNumber

func ExtractLastNumber(s string) int

ExtractLastNumber 提取字符串中最后一个"-"之后的数字

func GenerateClusterACLConfigMapName

func GenerateClusterACLConfigMapName(name string) string

func GenerateName

func GenerateName(typeName, metaName string) string

func GenerateRedisPasswordOptions

func GenerateRedisPasswordOptions() string

func GenerateRedisRandPassword

func GenerateRedisRandPassword() string

func GenerateRedisRebuildAnnotation

func GenerateRedisRebuildAnnotation() map[string]string

func GenerateRedisTLSOptions

func GenerateRedisTLSOptions() string

func GetClaimName

func GetClaimName(backupDestination string) string

split storage name, example: pvc/redisfailover-persistent-keep-data-rfr-redis-sentinel-demo-0

func GetContainerByName

func GetContainerByName(pod *corev1.PodSpec, name string) *corev1.Container

GetContainerByName

func GetCronJobName

func GetCronJobName(redisName, scheduleName string) string

func GetEnvSentinelHost

func GetEnvSentinelHost(name string) string

func GetEnvSentinelPort

func GetEnvSentinelPort(name string) string

func GetRedisName

func GetRedisName(rf *v1.RedisFailover) string

func GetRedisNameExporter

func GetRedisNameExporter(rf *v1.RedisFailover) string

func GetRedisNodePortSvc

func GetRedisNodePortSvc(rf *v1.RedisFailover) string

func GetRedisROServiceName

func GetRedisROServiceName(rfName string) string

func GetRedisRWServiceName

func GetRedisRWServiceName(rfName string) string

func GetRedisSSLSecretName

func GetRedisSSLSecretName(rfName string) string

GetRedisSSLSecretName return the name of redis ssl secret

func GetRedisSecretName

func GetRedisSecretName(rf *v1.RedisFailover) string

func GetRedisShutdownConfigMapName

func GetRedisShutdownConfigMapName(rf *v1.RedisFailover) string

func GetRedisShutdownName

func GetRedisShutdownName(rf *v1.RedisFailover) string

func GetSentinelHeadlessSvc

func GetSentinelHeadlessSvc(rf *v1.RedisFailover) string

func GetSentinelName

func GetSentinelName(rf *v1.RedisFailover) string

func GetSentinelReadinessConfigmap

func GetSentinelReadinessConfigmap(rf *v1.RedisFailover) string

func GetVolumeByName

func GetVolumeByName(vols []corev1.Volume, name string) *corev1.Volume

GetVolumes

func GetVolumeClaimTemplatesByName

func GetVolumeClaimTemplatesByName(vols []corev1.PersistentVolumeClaim, name string) *corev1.PersistentVolumeClaim

GetVolumeClaimTemplatesByName

func MapKeys

func MapKeys(m map[string]string) (ret []string)

func MergeMap

func MergeMap(maps ...map[string]string) map[string]string

MergeLabels merges all the label maps received as argument into a single new label map.

func ParsePortSequence

func ParsePortSequence(portSequence string) ([]int32, error)

func RedisInstancePersistence

func RedisInstancePersistence(ctx context.Context, mgrCli client.Client, namespace string, logger logr.Logger) error

func RetryOnTimeout

func RetryOnTimeout(f func() error, step int) error

func UnifyValueUnit

func UnifyValueUnit(v string) string

UnifyValueUnit value convert, not care the config itself

Types

type AuthConfig

type AuthConfig struct {
	Password  string
	TLSConfig *tls.Config
}

type Object

type Object interface {
	GetObjectKind() schema.ObjectKind
	metav1.Object
}

Jump to

Keyboard shortcuts

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