Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] : Add support for multiple versions #592

Merged
merged 29 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7942fac
Add : v1beta2 from the current version
shubham-cmyk Aug 29, 2023
94a8d71
Add : kubebuilder storage tag
shubham-cmyk Aug 29, 2023
d48706f
fix : PROJECT
shubham-cmyk Aug 29, 2023
c1394d5
getRedisReplicationMasterIP according to v1beta2
shubham-cmyk Aug 29, 2023
54cf668
update : crds
shubham-cmyk Aug 29, 2023
be13fb8
fix: /config/samples/
shubham-cmyk Aug 29, 2023
c551570
apis redis rediscluster redisreplication, sentinel
shubham-cmyk Aug 29, 2023
f8ee42f
Add: rbac tags in rbac.go
shubham-cmyk Aug 29, 2023
9016ca1
Add : scaffhold webhook and conversion files
shubham-cmyk Aug 29, 2023
b0b0ddc
Add and Fix : common.go for common fields
shubham-cmyk Aug 29, 2023
4f24a02
Add : redis_conversion.go
shubham-cmyk Aug 29, 2023
1797f3c
fix: minor bugs in redis conversion
shubham-cmyk Aug 29, 2023
8219584
Add : Redis cluster conversion
shubham-cmyk Aug 29, 2023
e27e63a
Fix : bugs for the redis cluster conversion
shubham-cmyk Aug 29, 2023
be1ac58
Add : redisreplication conversion
shubham-cmyk Aug 30, 2023
228a080
fix : redis standlone
shubham-cmyk Aug 30, 2023
0dad079
Add : sentinel conversion
shubham-cmyk Aug 30, 2023
ec25a47
Add : deepcopy
shubham-cmyk Aug 30, 2023
3e4d864
Auto recreate redis replication statefulset when update failed (#586)
drivebyer Aug 20, 2023
b447e67
Add redis replication yaml example (#587)
drivebyer Aug 20, 2023
6852801
[Add] : Write the docs for the restore and backup (#588)
shubham-cmyk Aug 25, 2023
9d7cb24
[Enhancement]- Fix log pollution (#585)
drivebyer Aug 27, 2023
09a3dfb
[Add]- Support redis sentinel pdb (#589)
drivebyer Aug 27, 2023
0c768fa
Fix image path (#591)
wilsonwu Aug 29, 2023
4275fd8
Merge branch 'master' into multi-version
shubham-cmyk Aug 30, 2023
62f2471
Fix: bugs sentinel
shubham-cmyk Aug 30, 2023
1b7ed56
fix : pretty
shubham-cmyk Aug 30, 2023
e63df1a
convert i to index
shubham-cmyk Aug 30, 2023
d558976
remove index
shubham-cmyk Aug 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading