Skip to content

Commit

Permalink
[Feature] : Add Replication Mode to the Redis Operator (#417)
Browse files Browse the repository at this point in the history
* add Api Support

* api + controller

* subsentinel

* add Finalizers

* fix naming convention

* fix name convention

* create master slave replication

* remove extra CRD

* add redis replication to reconcile loop

* fix naming

* fix error and logs

* add example

* add TLS to redis replication

* remove additional field

* examples
  • Loading branch information
shubham-cmyk authored Feb 6, 2023
1 parent 77b4275 commit cd4661e
Show file tree
Hide file tree
Showing 25 changed files with 4,795 additions and 3 deletions.
60 changes: 60 additions & 0 deletions api/v1beta1/redisreplication_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package v1beta1

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

type RedisReplicationSpec struct {
Size *int32 `json:"clusterSize"`
KubernetesConfig KubernetesConfig `json:"kubernetesConfig"`
RedisExporter *RedisExporter `json:"redisExporter,omitempty"`
RedisConfig *RedisConfig `json:"redisConfig,omitempty"`
Storage *Storage `json:"storage,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"`
// +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 *RedisReplicationSpec) GetReplicationCounts(t string) int32 {
replica := cr.Size
return *replica
}

// RedisStatus defines the observed state of Redis
type RedisReplicationStatus struct {
}

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

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

Spec RedisReplicationSpec `json:"spec"`
Status RedisReplicationStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&RedisReplication{}, &RedisReplicationList{})
}
169 changes: 169 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 cd4661e

Please sign in to comment.