clusterbuilder

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: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RestoreSucceeded = "succeeded"

	RedisConfKey = "redis.conf"
)
View Source
const (
	RedisConfig_MaxMemory               = "maxmemory"
	RedisConfig_MaxMemoryPolicy         = "maxmemory-policy"
	RedisConfig_ClientOutputBufferLimit = "client-output-buffer-limit"
	RedisConfig_Save                    = "save"
	RedisConfig_RenameCommand           = "rename-command"
	RedisConfig_Appendonly              = "appendonly"
	RedisConfig_ReplDisklessSync        = "repl-diskless-sync"
)
View Source
const (
	RedisInstanceServiceAccountName = "redis-instance-account"
	RedisInstanceRoleName           = "redis-instance-role"
	RedisInstanceRoleBindingName    = "redis-instance-rolebinding"
)
View Source
const (
	DefaultScrapInterval = "60s"
	DefaultScrapeTimeout = "10s"
)
View Source
const (
	DefaultRedisServerPort    = 6379
	DefaultRedisServerBusPort = 16379

	GenericKey       = "redis.kun"
	LabelClusterName = GenericKey + "/name"
	StatefulSetLabel = "statefulSet"

	// DNS
	LocalInjectName = "local.inject"

	// Container
	CheckContainerName         = "init"
	RestoreContainerName       = "restore"
	ServerContainerName        = "redis"
	ExporterContainerName      = "exporter"
	ConfigSyncContainerName    = "sidecar"
	RedisDataContainerPortName = "client"

	// Volume
	RedisStorageVolumeName          = "redis-data"
	RedisTempVolumeName             = "temp"
	RedisOperatorPasswordVolumeName = "operator-password"
	ConfigVolumeName                = "conf"
	RedisTLSVolumeName              = "redis-tls"
	RedisBackupVolumeName           = "backup-data"
	RedisRestoreLocalVolumeName     = "redis-local"
	RedisOptVolumeName              = "redis-opt"

	// Mount path
	StorageVolumeMountPath          = "/data"
	OperatorPasswordVolumeMountPath = "/account"
	ConfigVolumeMountPath           = "/conf"
	TLSVolumeMountPath              = "/tls"
	BackupVolumeMountPath           = "/backup"
	RestoreLocalVolumeMountPath     = "/restore"
	RedisOptVolumeMountPath         = "/opt"
	RedisTmpVolumeMountPath         = "/tmp"

	// Env
	OperatorUsername   = "OPERATOR_USERNAME"
	OperatorSecretName = "OPERATOR_SECRET_NAME"

	PrometheusExporterPort          = 9100
	PrometheusExporterTelemetryPath = "/metrics"
)
View Source
const (
	ProbeDelaySeconds                          = 30
	DefaultTerminationGracePeriodSeconds int64 = 300
)
View Source
const (
	LabelRedisArch = "redisarch"
)
View Source
const (
	PasswordENV = "REDIS_PASSWORD"
)
View Source
const (
	RedisClusterServiceMonitorName = "redis-cluster"
)

Variables

View Source
var ForbidToRenameCommands = map[string]struct{}{
	"config":  {},
	"cluster": {},
}
View Source
var MustQuoteRedisConfig = map[string]struct{}{
	"tls-protocols": {},
}
View Source
var MustUpperRedisConfig = map[string]struct{}{
	"tls-ciphers":      {},
	"tls-ciphersuites": {},
	"tls-protocols":    {},
}
View Source
var RedisConfigRestartPolicy = map[string]RedisConfigSettingRule{

	"include":          Forbid,
	"loadmodule":       Forbid,
	"bind":             Forbid,
	"protected-mode":   Forbid,
	"port":             Forbid,
	"tls-port":         Forbid,
	"tls-cert-file":    Forbid,
	"tls-key-file":     Forbid,
	"tls-ca-cert-file": Forbid,
	"tls-ca-cert-dir":  Forbid,
	"unixsocket":       Forbid,
	"unixsocketperm":   Forbid,
	"daemonize":        Forbid,
	"supervised":       Forbid,
	"pidfile":          Forbid,
	"logfile":          Forbid,
	"syslog-enabled":   Forbid,
	"syslog-ident":     Forbid,
	"syslog-facility":  Forbid,
	"always-show-logo": Forbid,
	"dbfilename":       Forbid,
	"appendfilename":   Forbid,
	"dir":              Forbid,
	"slaveof":          Forbid,
	"replicaof":        Forbid,
	"gopher-enabled":   Forbid,

	"aclfile":               Forbid,
	"requirepass":           Forbid,
	"masterauth":            Forbid,
	"masteruser":            Forbid,
	"slave-announce-ip":     Forbid,
	"replica-announce-ip":   Forbid,
	"slave-announce-port":   Forbid,
	"replica-announce-port": Forbid,
	"cluster-enabled":       Forbid,
	"cluster-config-file":   Forbid,

	"tcp-backlog":         RequireRestart,
	"databases":           RequireRestart,
	"rename-command":      RequireRestart,
	"rdbchecksum":         RequireRestart,
	"io-threads":          RequireRestart,
	"io-threads-do-reads": RequireRestart,
}

Functions

func ClusterHeadlessSvcName

func ClusterHeadlessSvcName(name string, i int) string

func ClusterNodeSvcName

func ClusterNodeSvcName(clusterName string, shard, repl int) string

func ClusterStatefulSetName

func ClusterStatefulSetName(clusterName string, i int) string

func ClusterStatefulSetSvcName

func ClusterStatefulSetSvcName(clusterName string, index string) string

func GenerateCertName

func GenerateCertName(name string) string

GenerateCertName

func GenerateClusterACLConfigMapName

func GenerateClusterACLConfigMapName(name string) string

func GenerateClusterACLOperatorSecretName

func GenerateClusterACLOperatorSecretName(name string) string

func GenerateClusterDefaultRedisUserName

func GenerateClusterDefaultRedisUserName(name string) string

func GenerateClusterOperatorsRedisUser

func GenerateClusterOperatorsRedisUser(rc types.RedisClusterInstance, passwordsecret string) redismiddlewarealaudaiov1.RedisUser

func GenerateClusterOperatorsRedisUserName

func GenerateClusterOperatorsRedisUserName(name string) string

func GenerateClusterTLSSecretName

func GenerateClusterTLSSecretName(name string) string

func GenerateCronJobName

func GenerateCronJobName(redisName, scheduleName string) string

func GetClaimName

func GetClaimName(backupDestination string) string

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

func GetClusterLabels

func GetClusterLabels(name string, extra map[string]string) map[string]string

GetClusterStaticLabels this labels are const, take care of modify this.

func GetClusterPassword

func GetClusterPassword(client client.Client, cluster *redisv1alpha1.DistributedRedisCluster) (string, error)

GetClusterPassword return current redis cluster's password.

func GetClusterStatefulsetLabels

func GetClusterStatefulsetLabels(name string, index int) map[string]string

GetClusterStatefulsetLabels this labels are const, take care of update this

func GetClusterStatefulsetSelectorLabels

func GetClusterStatefulsetSelectorLabels(name string, index int) map[string]string

GetClusterStatefulsetSelectorLabels this labels are const, take care of update this

func GetOldRedisClusterPassword

func GetOldRedisClusterPassword(client client.Client, sts *appsv1.StatefulSet) (string, error)

GetOldRedisClusterPassword return old redis cluster's password.

func GetPodOwnerReferences

func GetPodOwnerReferences() metav1.OwnerReference

func GetRedisSSLSecretName

func GetRedisSSLSecretName(name string) string

func GetServiceDNSName

func GetServiceDNSName(serviceName, namespace string) string

GetServiceDNSName

func IsCronJobChanged

func IsCronJobChanged(newJob, oldJob *batchv1.CronJob, logger logr.Logger) bool

func IsPasswordChanged

func IsPasswordChanged(cluster *redisv1alpha1.DistributedRedisCluster, sts *appsv1.StatefulSet) bool

IsPasswordChanged determine whether the password is changed.

func IsPodTemplasteChanged

func IsPodTemplasteChanged(newTplSpec, oldTplSpec *v1.PodTemplateSpec, logger logr.Logger) bool

func IsRedisClusterStatefulsetChanged

func IsRedisClusterStatefulsetChanged(newSts, sts *appv1.StatefulSet, logger logr.Logger) bool

IsRedisClusterStatefulsetChanged

func NewCertificate

NewCertificate

func NewClusterRole

func NewClusterRole(obj client.Object) *rbacv1.ClusterRole

func NewClusterRoleBinding

func NewClusterRoleBinding(obj client.Object) *rbacv1.ClusterRoleBinding

func NewConfigMapForCR

func NewConfigMapForCR(cluster types.RedisClusterInstance) (*corev1.ConfigMap, error)

NewConfigMapForCR creates a new ConfigMap for the given Cluster

func NewConfigMapForRestore

func NewConfigMapForRestore(cluster *redisv1alpha1.DistributedRedisCluster, labels map[string]string) *corev1.ConfigMap

func NewHeadlessSvcForCR

func NewHeadlessSvcForCR(cluster *redisv1alpha1.DistributedRedisCluster, index int) *corev1.Service

NewHeadlessSvcForCR creates a new headless service for the given Cluster.

func NewNodePortServiceForCR

func NewNodePortServiceForCR(cluster *redisv1alpha1.DistributedRedisCluster) *corev1.Service

func NewNodeportSvc

func NewNodeportSvc(cluster *redisv1alpha1.DistributedRedisCluster, name string, labels map[string]string, port int32) *corev1.Service

func NewPodDisruptionBudgetForCR

func NewPodDisruptionBudgetForCR(cluster *redisv1alpha1.DistributedRedisCluster, name string, labels map[string]string) *policyv1.PodDisruptionBudget

func NewRedisClusterBackupCronJobFromCR

func NewRedisClusterBackupCronJobFromCR(schedule v1alpha1.Schedule, cluster *v1alpha1.DistributedRedisCluster) *batchv1.CronJob

func NewRole

func NewRole(obj client.Object) *rbacv1.Role

NewRole

func NewRoleBinding

func NewRoleBinding(obj client.Object) *rbacv1.RoleBinding

NewRoleBinding

func NewServiceAccount

func NewServiceAccount(obj client.Object) *corev1.ServiceAccount

NewServiceAccount

func NewServiceForCR

func NewServiceForCR(cluster *redisv1alpha1.DistributedRedisCluster) *corev1.Service

func NewStatefulSetForCR

func NewStatefulSetForCR(c types.RedisClusterInstance, restoring bool, isAllACLSupported bool, backup *redisbackupv1.RedisClusterBackup, index int) (*appsv1.StatefulSet, error)

NewStatefulSetForCR creates a new StatefulSet for the given Cluster.

func ParseRenameConfigs

func ParseRenameConfigs(val string) (ret map[string]string, err error)

func RedisConfigMapName

func RedisConfigMapName(clusterName string) string

func RedisNodePortSvcName

func RedisNodePortSvcName(clusterName string) string

func RestoreConfigMapName

func RestoreConfigMapName(clusterName string) string

Types

type RedisConfig

type RedisConfig map[string]RedisConfigValues

RedisConfig

func LoadRedisConfig

func LoadRedisConfig(data string) (RedisConfig, error)

LoadRedisConfig

func (RedisConfig) Diff

func (o RedisConfig) Diff(n RedisConfig) (added, changed, deleted map[string]RedisConfigValues)

Diff return diff two n RedisConfig

type RedisConfigSettingRule

type RedisConfigSettingRule string
const (
	OK             RedisConfigSettingRule = "OK"
	RequireRestart RedisConfigSettingRule = "Restart"
	Forbid         RedisConfigSettingRule = "Forbid"
)

type RedisConfigValues

type RedisConfigValues []string

func (*RedisConfigValues) String

func (v *RedisConfigValues) String() string

Jump to

Keyboard shortcuts

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