Skip to content

Commit

Permalink
[Feature] Add Redis Sentinel Support (#408)
Browse files Browse the repository at this point in the history
* commit

* sentinel Major Changes

* example addition

* example addition

* add Env Variable

* add Env variable

* add Env Variable in sentinel

* fix Issue from the int env Variable

* name correction

* add field for replication

* fix : comments, api
add : getMaster IP

* add : Dynamic Client , fix : getMasterIP function

* change Example

* fix : bug

* fixed : requirement

* change : image name
  • Loading branch information
shubham-cmyk authored Feb 13, 2023
1 parent 34ad273 commit e86884e
Show file tree
Hide file tree
Showing 13 changed files with 2,291 additions and 5 deletions.
78 changes: 78 additions & 0 deletions api/v1beta1/redissentinel_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package v1beta1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type RedisSentinelSpec struct {
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Default=3
// +kubebuilder:validation:Not=2
Size *int32 `json:"clusterSize"`
KubernetesConfig KubernetesConfig `json:"kubernetesConfig"`
RedisSentinelConfig *RedisSentinelConfig `json:"redisSentinelConfig,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
PriorityClassName string `json:"priorityClassName,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
TLS *TLSConfig `json:"TLS,omitempty"`
PodDisruptionBudget *RedisPodDisruptionBudget `json:"pdb,omitempty"`
// +kubebuilder:default:={initialDelaySeconds: 1, timeoutSeconds: 1, periodSeconds: 10, successThreshold: 1, failureThreshold:3}
ReadinessProbe *Probe `json:"readinessProbe,omitempty" protobuf:"bytes,11,opt,name=readinessProbe"`
// +kubebuilder:default:={initialDelaySeconds: 1, timeoutSeconds: 1, periodSeconds: 10, successThreshold: 1, failureThreshold:3}
LivenessProbe *Probe `json:"livenessProbe,omitempty" protobuf:"bytes,11,opt,name=livenessProbe"`
Sidecars *[]Sidecar `json:"sidecars,omitempty"`
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
}

func (cr *RedisSentinelSpec) GetSentinelCounts(t string) int32 {
replica := cr.Size
return *replica
}

type RedisSentinelConfig struct {
AdditionalSentinelConfig *string `json:"additionalSentinelConfig,omitempty"`
RedisReplicationName string `json:"redisReplicationName"`
// +kubebuilder:default:=myMaster
MasterGroupName string `json:"masterGroupName,omitempty"`
// +kubebuilder:default:="6379"
RedisPort string `json:"redisPort,omitempty"`
// +kubebuilder:default:="2"
Quorum string `json:"quorum,omitempty"`
// +kubebuilder:default:="1"
ParallelSyncs string `json:"parallelSyncs,omitempty"`
// +kubebuilder:default:="180000"
FailoverTimeout string `json:"failoverTimeout,omitempty"`
// +kubebuilder:default:="30000"
DownAfterMilliseconds string `json:"downAfterMilliseconds,omitempty"`
}

type RedisSentinelStatus struct {
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// Redis is the Schema for the redis API
type RedisSentinel struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec RedisSentinelSpec `json:"spec"`
Status RedisSentinelStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// RedisList contains a list of Redis
type RedisSentinelList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []RedisSentinel `json:"items"`
}

func init() {
SchemeBuilder.Register(&RedisSentinel{}, &RedisSentinelList{})
}
184 changes: 184 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e86884e

Please sign in to comment.