clusterbuilder

package
v0.0.0-...-3430a5a Latest Latest
Warning

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

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

Documentation

Index

Constants

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"

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

	// Volume
	RedisStorageVolumeName          = "redis-data"
	RedisTempVolumeName             = "temp"
	RedisOperatorPasswordVolumeName = "operator-password"
	ConfigVolumeName                = "conf"
	RedisTLSVolumeName              = "redis-tls"
	RedisOptVolumeName              = "redis-opt"
	// Mount path
	StorageVolumeMountPath          = "/data"
	OperatorPasswordVolumeMountPath = "/account"
	ConfigVolumeMountPath           = "/conf"
	TLSVolumeMountPath              = "/tls"
	RedisOptVolumeMountPath         = "/opt"
	RedisTmpVolumeMountPath         = "/tmp"

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

	PrometheusExporterPortNumber    = 9100
	PrometheusExporterTelemetryPath = "/metrics"
)
View Source
const (
	ProbeDelaySeconds                          = 30
	DefaultTerminationGracePeriodSeconds int64 = 300
)
View Source
const (
	PasswordENV = "REDIS_PASSWORD"
)
View Source
const (
	RedisClusterServiceMonitorName = "redis-cluster"
)
View Source
const (
	RedisConfKey = "redis.conf"
)

Variables

View Source
var ForbidToRenameCommands = map[string]struct{}{
	"config":  {},
	"cluster": {},
}
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 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 GenerateClusterRedisUser

func GenerateClusterRedisUser(obj metav1.Object, u *user.User) *redismiddlewarealaudaiov1.RedisUser

func GenerateClusterRedisUserName

func GenerateClusterRedisUserName(instName, name string) string

func GenerateClusterTLSSecretName

func GenerateClusterTLSSecretName(name string) string

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 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 IsStatefulsetChanged

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

IsStatefulsetChanged

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 NewHeadlessSvcForCR

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

NewHeadlessSvcForCR creates a new headless service for the given Cluster.

func NewNodeportSvc

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

func NewPodDisruptionBudgetForCR

func NewPodDisruptionBudgetForCR(cluster *redisv1alpha1.DistributedRedisCluster, index int) *policyv1.PodDisruptionBudget

func NewPodService

func NewPodService(cluster *redisv1alpha1.DistributedRedisCluster, name string, typ corev1.ServiceType,
	labels map[string]string, annotations map[string]string) *corev1.Service

func NewRedisClusterDetailedStatusConfigMap

func NewRedisClusterDetailedStatusConfigMap(inst types.RedisClusterInstance, status *v1alpha1.DistributedRedisClusterDetailedStatus) (*corev1.ConfigMap, error)

NewRedisClusterDetailedStatusConfigMap creates a new ConfigMap for the given Cluster

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 NewServiceWithType

func NewServiceWithType(cluster *redisv1alpha1.DistributedRedisCluster, typ corev1.ServiceType, port int32) *corev1.Service

func NewStatefulSetForCR

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

NewStatefulSetForCR creates a new StatefulSet for the given Cluster.

func ParsePodShardAndIndex

func ParsePodShardAndIndex(name string) (shard int, index int, err error)

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 RedisProxySvcName

func RedisProxySvcName(clusterName string) string

func ShouldUpdateDetailedStatusConfigMap

func ShouldUpdateDetailedStatusConfigMap(cm *corev1.ConfigMap, status *v1alpha1.DistributedRedisClusterDetailedStatus) bool

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
JackTT - Gopher 🇻🇳