Skip to content

Commit

Permalink
[Feature] : Add support for multiple versions (OT-CONTAINER-KIT#592)
Browse files Browse the repository at this point in the history
* Add : v1beta2 from the current version

Signed-off-by: Shubham Gupta <[email protected]>

* Add : kubebuilder storage tag

Signed-off-by: Shubham Gupta <[email protected]>

* fix : PROJECT

Signed-off-by: Shubham Gupta <[email protected]>

* getRedisReplicationMasterIP according to v1beta2

Signed-off-by: Shubham Gupta <[email protected]>

* update : crds

Signed-off-by: Shubham Gupta <[email protected]>

* fix: /config/samples/

Signed-off-by: Shubham Gupta <[email protected]>

* apis redis rediscluster redisreplication, sentinel

Signed-off-by: Shubham Gupta <[email protected]>

* Add: rbac tags in rbac.go

Signed-off-by: Shubham Gupta <[email protected]>

* Add : scaffhold webhook and conversion files

Signed-off-by: Shubham Gupta <[email protected]>

* Add and Fix : common.go for common fields

Signed-off-by: Shubham Gupta <[email protected]>

* Add : redis_conversion.go

Signed-off-by: Shubham Gupta <[email protected]>

* fix: minor bugs in redis conversion

Signed-off-by: Shubham Gupta <[email protected]>

* Add : Redis cluster conversion

Signed-off-by: Shubham Gupta <[email protected]>

* Fix : bugs for the redis cluster conversion

Signed-off-by: Shubham Gupta <[email protected]>

* Add : redisreplication conversion

Signed-off-by: Shubham Gupta <[email protected]>

* fix : redis standlone

Signed-off-by: Shubham Gupta <[email protected]>

* Add : sentinel conversion

Signed-off-by: Shubham Gupta <[email protected]>

* Add : deepcopy

Signed-off-by: Shubham Gupta <[email protected]>

* Auto recreate redis replication statefulset when update failed (OT-CONTAINER-KIT#586)

Signed-off-by: drivebyer <[email protected]>

* Add redis replication yaml example (OT-CONTAINER-KIT#587)

Signed-off-by: drivebyer <[email protected]>

* [Add] : Write the docs for the restore and backup (OT-CONTAINER-KIT#588)

* Write the docs for the restore and backup

Signed-off-by: Shubham Gupta <[email protected]>

* add Prerequisites

Signed-off-by: Shubham Gupta <[email protected]>

* typo

Signed-off-by: Shubham Gupta <[email protected]>

---------

Signed-off-by: Shubham Gupta <[email protected]>

* [Enhancement]- Fix log pollution (OT-CONTAINER-KIT#585)

* Add param to set operator log verbosity

Signed-off-by: drivebyer <[email protected]>

* Level down some logger

Signed-off-by: drivebyer <[email protected]>

* Remove unnecessary flag, `opts.BindFlags(flag.CommandLine)` already add flag `zap-log-level`

Signed-off-by: drivebyer <[email protected]>

* Level up every info, not logger

Signed-off-by: drivebyer <[email protected]>

---------

Signed-off-by: drivebyer <[email protected]>
Signed-off-by: drivebyer <[email protected]>

* [Add]- Support redis sentinel pdb (OT-CONTAINER-KIT#589)

* Support redis sentinel pdb

Signed-off-by: drivebyer <[email protected]>

* Adjust example minAvailable

Signed-off-by: drivebyer <[email protected]>

---------

Signed-off-by: drivebyer <[email protected]>

* Fix image path (OT-CONTAINER-KIT#591)

Signed-off-by: Wilson Wu <[email protected]>

* Fix: bugs sentinel

Signed-off-by: Shubham Gupta <[email protected]>

* fix : pretty

Signed-off-by: Shubham Gupta <[email protected]>

* convert i to index

Signed-off-by: Shubham Gupta <[email protected]>

* remove index

Signed-off-by: Shubham Gupta <[email protected]>

---------

Signed-off-by: Shubham Gupta <[email protected]>
Signed-off-by: drivebyer <[email protected]>
Signed-off-by: drivebyer <[email protected]>
Signed-off-by: Wilson Wu <[email protected]>
Co-authored-by: Yang Wu <[email protected]>
Co-authored-by: Yang Wu <[email protected]>
Co-authored-by: Wilson Wu <[email protected]>
  • Loading branch information
4 people authored Aug 30, 2023
1 parent 6b03437 commit 4e48108
Show file tree
Hide file tree
Showing 71 changed files with 16,929 additions and 833 deletions.
66 changes: 65 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: redis.opstreelabs.in
layout:
- go.kubebuilder.io/v3
Expand All @@ -13,15 +17,75 @@ resources:
domain: redis.opstreelabs.in
group: redis
kind: Redis
path: redis-operator/api/v1beta2
version: v1beta2
webhooks:
conversion: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: redis.opstreelabs.in
group: redis
kind: RedisCluster
path: redis-operator/api/v1beta2
version: v1beta2
webhooks:
conversion: true
webhookVersion: v1
- api:
crdVersion: v1
controller: true
domain: redis.opstreelabs.in
group: redis
kind: RedisReplication
path: redis-operator/api/v1beta2
version: v1beta2
webhooks:
conversion: true
webhookVersion: v1
- api:
crdVersion: v1
controller: true
domain: redis.opstreelabs.in
group: redis
kind: RedisSentinel
path: redis-operator/api/v1beta2
version: v1beta2
webhooks:
conversion: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
domain: redis.opstreelabs.in
group: redis
kind: Redis
path: redis-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: redis.opstreelabs.in
group: redis
kind: RedisCluster
path: redis-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: redis.opstreelabs.in
group: redis
kind: RedisReplication
path: redis-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: redis.opstreelabs.in
group: redis
kind: RedisSentinel
path: redis-operator/api/v1beta1
version: v1beta1
version: "3"
159 changes: 159 additions & 0 deletions api/common_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
package api

import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
)

// KubernetesConfig will be the JSON struct for Basic Redis Config
// +k8s:deepcopy-gen=true
type KubernetesConfig struct {
Image string `json:"image"`
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
ExistingPasswordSecret *ExistingPasswordSecret `json:"redisSecret,omitempty"`
ImagePullSecrets *[]corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
UpdateStrategy appsv1.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty"`
Service *ServiceConfig `json:"service,omitempty"`
}

// ServiceConfig define the type of service to be created and its annotations
// +k8s:deepcopy-gen=true
type ServiceConfig struct {
// +kubebuilder:validation:Enum=LoadBalancer;NodePort;ClusterIP
ServiceType string `json:"serviceType,omitempty"`
ServiceAnnotations map[string]string `json:"annotations,omitempty"`
}

// ExistingPasswordSecret is the struct to access the existing secret
// +k8s:deepcopy-gen=true
type ExistingPasswordSecret struct {
Name *string `json:"name,omitempty"`
Key *string `json:"key,omitempty"`
}

// RedisExporter interface will have the information for redis exporter related stuff
// +k8s:deepcopy-gen=true
type RedisExporter struct {
Enabled bool `json:"enabled,omitempty"`
Image string `json:"image"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
EnvVars *[]corev1.EnvVar `json:"env,omitempty"`
}

// RedisConfig defines the external configuration of Redis
// +k8s:deepcopy-gen=true
type RedisConfig struct {
AdditionalRedisConfig *string `json:"additionalRedisConfig,omitempty"`
}

// Storage is the inteface to add pvc and pv support in redis
// +k8s:deepcopy-gen=true
type Storage struct {
VolumeClaimTemplate corev1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"`
VolumeMount AdditionalVolume `json:"volumeMount,omitempty"`
}

// Additional Volume is provided by user that is mounted on the pods
// +k8s:deepcopy-gen=true
type AdditionalVolume struct {
Volume []corev1.Volume `json:"volume,omitempty"`
MountPath []corev1.VolumeMount `json:"mountPath,omitempty"`
}

// TLS Configuration for redis instances
// +k8s:deepcopy-gen=true
type TLSConfig struct {
CaKeyFile string `json:"ca,omitempty"`
CertKeyFile string `json:"cert,omitempty"`
KeyFile string `json:"key,omitempty"`
// Reference to secret which contains the certificates
Secret corev1.SecretVolumeSource `json:"secret"`
}

// Probe is a interface for ReadinessProbe and LivenessProbe
// +k8s:deepcopy-gen=true
type Probe struct {
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=1
InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty" protobuf:"varint,2,opt,name=initialDelaySeconds"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=1
TimeoutSeconds int32 `json:"timeoutSeconds,omitempty" protobuf:"varint,3,opt,name=timeoutSeconds"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=10
PeriodSeconds int32 `json:"periodSeconds,omitempty" protobuf:"varint,4,opt,name=periodSeconds"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=1
SuccessThreshold int32 `json:"successThreshold,omitempty" protobuf:"varint,5,opt,name=successThreshold"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=3
FailureThreshold int32 `json:"failureThreshold,omitempty" protobuf:"varint,6,opt,name=failureThreshold"`
}

// Sidecar for each Redis pods
// +k8s:deepcopy-gen=true
type Sidecar struct {
Name string `json:"name"`
Image string `json:"image"`
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
EnvVars *[]corev1.EnvVar `json:"env,omitempty"`
}

// RedisLeader interface will have the redis leader configuration
// +k8s:deepcopy-gen=true
type RedisLeader struct {
Replicas *int32 `json:"replicas,omitempty"`
RedisConfig *RedisConfig `json:"redisConfig,omitempty"`
Affinity *corev1.Affinity `json:"affinity,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"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

// RedisFollower interface will have the redis follower configuration
// +k8s:deepcopy-gen=true
type RedisFollower struct {
Replicas *int32 `json:"replicas,omitempty"`
RedisConfig *RedisConfig `json:"redisConfig,omitempty"`
Affinity *corev1.Affinity `json:"affinity,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"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

// RedisPodDisruptionBudget configure a PodDisruptionBudget on the resource (leader/follower)
// +k8s:deepcopy-gen=true
type RedisPodDisruptionBudget struct {
Enabled bool `json:"enabled,omitempty"`
MinAvailable *int32 `json:"minAvailable,omitempty"`
MaxUnavailable *int32 `json:"maxUnavailable,omitempty"`
}

// +k8s:deepcopy-gen=true
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"`
}
81 changes: 8 additions & 73 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,12 @@ limitations under the License.
package v1beta1

import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
common "github.com/OT-CONTAINER-KIT/redis-operator/api"
)

// KubernetesConfig will be the JSON struct for Basic Redis Config
type KubernetesConfig struct {
Image string `json:"image"`
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
ExistingPasswordSecret *ExistingPasswordSecret `json:"redisSecret,omitempty"`
ImagePullSecrets *[]corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
UpdateStrategy appsv1.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty"`
Service *ServiceConfig `json:"service,omitempty"`
common.KubernetesConfig `json:",inline"`
}

// ServiceConfig define the type of service to be created and its annotations
Expand All @@ -41,7 +34,7 @@ type ServiceConfig struct {

// RedisConfig defines the external configuration of Redis
type RedisConfig struct {
AdditionalRedisConfig *string `json:"additionalRedisConfig,omitempty"`
common.RedisConfig `json:",inline"`
}

// ExistingPasswordSecret is the struct to access the existing secret
Expand All @@ -52,83 +45,25 @@ type ExistingPasswordSecret struct {

// Storage is the inteface to add pvc and pv support in redis
type Storage struct {
VolumeClaimTemplate corev1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"`
VolumeMount AdditionalVolume `json:"volumeMount,omitempty"`
}

// Node-conf needs to be added only in redis cluster
type ClusterStorage struct {
VolumeClaimTemplate corev1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"`
NodeConfVolumeClaimTemplate corev1.PersistentVolumeClaim `json:"nodeConfVolumeClaimTemplate,omitempty"`
VolumeMount AdditionalVolume `json:"volumeMount,omitempty"`
}

// Additional Volume is provided by user that is mounted on the pods
type AdditionalVolume struct {
Volume []corev1.Volume `json:"volume,omitempty"`
MountPath []corev1.VolumeMount `json:"mountPath,omitempty"`
CommonAttributes common.Storage `json:",inline"`
}

// RedisExporter interface will have the information for redis exporter related stuff
type RedisExporter struct {
Enabled bool `json:"enabled,omitempty"`
Image string `json:"image"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
EnvVars *[]corev1.EnvVar `json:"env,omitempty"`
common.RedisExporter `json:",inline"`
}

// TLS Configuration for redis instances
type TLSConfig struct {
CaKeyFile string `json:"ca,omitempty"`
CertKeyFile string `json:"cert,omitempty"`
KeyFile string `json:"key,omitempty"`
// Reference to secret which contains the certificates
Secret corev1.SecretVolumeSource `json:"secret"`
}

type ACLConfig struct {
Secret *corev1.SecretVolumeSource `json:"secret,omitempty"`
common.TLSConfig `json:",inline"`
}

// Probe is a interface for ReadinessProbe and LivenessProbe
type Probe struct {
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=1
InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty" protobuf:"varint,2,opt,name=initialDelaySeconds"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=1
TimeoutSeconds int32 `json:"timeoutSeconds,omitempty" protobuf:"varint,3,opt,name=timeoutSeconds"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=10
PeriodSeconds int32 `json:"periodSeconds,omitempty" protobuf:"varint,4,opt,name=periodSeconds"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=1
SuccessThreshold int32 `json:"successThreshold,omitempty" protobuf:"varint,5,opt,name=successThreshold"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=3
FailureThreshold int32 `json:"failureThreshold,omitempty" protobuf:"varint,6,opt,name=failureThreshold"`
common.Probe `json:",inline"`
}

// Sidecar for each Redis pods
type Sidecar struct {
Name string `json:"name"`
Image string `json:"image"`
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
EnvVars *[]corev1.EnvVar `json:"env,omitempty"`
Volumes *[]corev1.VolumeMount `json:"mountPath,omitempty"`
Command []string `json:"command,omitempty" protobuf:"bytes,3,rep,name=command"`
Ports *[]corev1.ContainerPort `json:"ports,omitempty" patchStrategy:"merge" patchMergeKey:"containerPort" protobuf:"bytes,6,rep,name=ports"`
}

// InitContainer for each Redis pods
type InitContainer struct {
Enabled *bool `json:"enabled,omitempty"`
Image string `json:"image"`
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
EnvVars *[]corev1.EnvVar `json:"env,omitempty"`
Command []string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
common.Sidecar `json:",inline"`
}
Loading

0 comments on commit 4e48108

Please sign in to comment.