Skip to content

Commit

Permalink
feat(cloud-control): add aws implementation for redis cluster (#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
dushanpantic authored Feb 20, 2025
1 parent fe8d371 commit 651cb8a
Show file tree
Hide file tree
Showing 56 changed files with 3,176 additions and 53 deletions.
54 changes: 54 additions & 0 deletions api/cloud-control/v1beta1/rediscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,49 @@ type RedisClusterAzure struct {
}

type RedisClusterAws struct {
// +kubebuilder:validation:Required
CacheNodeType string `json:"cacheNodeType"`

// +optional
// +kubebuilder:default="7.0"
// +kubebuilder:validation:Enum="7.1";"7.0";"6.x"
// +kubebuilder:validation:XValidation:rule=(self != "7.0" || oldSelf == "7.0" || oldSelf == "6.x"), message="engineVersion cannot be downgraded."
// +kubebuilder:validation:XValidation:rule=(self != "7.1" || oldSelf == "7.1" || oldSelf == "7.0" || oldSelf == "6.x"), message="engineVersion cannot be downgraded."
// +kubebuilder:validation:XValidation:rule=(self != "6.x" || oldSelf == "6.x"), message="engineVersion cannot be downgraded."
EngineVersion string `json:"engineVersion"`

// +optional
// +kubebuilder:default=false
AutoMinorVersionUpgrade bool `json:"autoMinorVersionUpgrade"`

// +optional
// +kubebuilder:default=false
AuthEnabled bool `json:"authEnabled"`

// Specifies the weekly time range during which maintenance on the cluster is
// performed. It is specified as a range in the format ddd:hh24:mi-ddd:hh24:mi (24H
// Clock UTC). The minimum maintenance window is a 60 minute period.
//
// Valid values for ddd are: sun mon tue wed thu fri sat
//
// Example: sun:23:00-mon:01:30
// +optional
PreferredMaintenanceWindow *string `json:"preferredMaintenanceWindow,omitempty"`

// +optional
Parameters map[string]string `json:"parameters,omitempty"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=500
// +kubebuilder:validation:XValidation:rule=(self == oldSelf), message="ShardCount is immutable."
ShardCount int32 `json:"shardCount"`

// +kubebuilder:default=0
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=5
// +kubebuilder:validation:XValidation:rule=(self == oldSelf), message="ReplicasPerShard is immutable."
ReplicasPerShard int32 `json:"replicasPerShard"`
}

// +kubebuilder:validation:MinProperties=1
Expand Down Expand Up @@ -62,6 +105,15 @@ type RedisClusterSpec struct {

// RedisClusterStatus defines the observed state of RedisCluster
type RedisClusterStatus struct {
// +optional
Id string `json:"id,omitempty"`

// +optional
DiscoveryEndpoint string `json:"discoveryEndpoint,omitempty"`

// +optional
AuthString string `json:"authString,omitempty"`

State StatusState `json:"state,omitempty"`

// List of status conditions to indicate the status of a RedisInstance.
Expand All @@ -73,6 +125,8 @@ type RedisClusterStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Scope",type="string",JSONPath=".spec.scope.name"
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"

// RedisCluster is the Schema for the redisclusters API
type RedisCluster struct {
Expand Down
14 changes: 13 additions & 1 deletion api/cloud-control/v1beta1/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ func main() {
}
if err = cloudcontrolcontroller.SetupRedisClusterReconciler(
mgr,
awsclient.NewElastiCacheClientProvider(),
env,
); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "RedisCluster")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ spec:
singular: rediscluster
scope: Namespaced
versions:
- name: v1beta1
- additionalPrinterColumns:
- jsonPath: .spec.scope.name
name: Scope
type: string
- jsonPath: .status.state
name: State
type: string
name: v1beta1
schema:
openAPIV3Schema:
description: RedisCluster is the Schema for the redisclusters API
Expand Down Expand Up @@ -44,6 +51,65 @@ spec:
minProperties: 1
properties:
aws:
properties:
authEnabled:
default: false
type: boolean
autoMinorVersionUpgrade:
default: false
type: boolean
cacheNodeType:
type: string
engineVersion:
default: "7.0"
enum:
- "7.1"
- "7.0"
- 6.x
type: string
x-kubernetes-validations:
- message: engineVersion cannot be downgraded.
rule: (self != "7.0" || oldSelf == "7.0" || oldSelf == "6.x")
- message: engineVersion cannot be downgraded.
rule: (self != "7.1" || oldSelf == "7.1" || oldSelf == "7.0"
|| oldSelf == "6.x")
- message: engineVersion cannot be downgraded.
rule: (self != "6.x" || oldSelf == "6.x")
parameters:
additionalProperties:
type: string
type: object
preferredMaintenanceWindow:
description: |-
Specifies the weekly time range during which maintenance on the cluster is
performed. It is specified as a range in the format ddd:hh24:mi-ddd:hh24:mi (24H
Clock UTC). The minimum maintenance window is a 60 minute period.
Valid values for ddd are: sun mon tue wed thu fri sat
Example: sun:23:00-mon:01:30
type: string
replicasPerShard:
default: 0
format: int32
maximum: 5
minimum: 0
type: integer
x-kubernetes-validations:
- message: ReplicasPerShard is immutable.
rule: (self == oldSelf)
shardCount:
format: int32
maximum: 500
minimum: 1
type: integer
x-kubernetes-validations:
- message: ShardCount is immutable.
rule: (self == oldSelf)
required:
- cacheNodeType
- replicasPerShard
- shardCount
type: object
azure:
type: object
Expand Down Expand Up @@ -92,6 +158,8 @@ spec:
status:
description: RedisClusterStatus defines the observed state of RedisCluster
properties:
authString:
type: string
conditions:
description: List of status conditions to indicate the status of a
RedisInstance.
Expand Down Expand Up @@ -153,6 +221,10 @@ spec:
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
discoveryEndpoint:
type: string
id:
type: string
state:
type: string
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ spec:
singular: rediscluster
scope: Namespaced
versions:
- name: v1beta1
- additionalPrinterColumns:
- jsonPath: .spec.scope.name
name: Scope
type: string
- jsonPath: .status.state
name: State
type: string
name: v1beta1
schema:
openAPIV3Schema:
description: RedisCluster is the Schema for the redisclusters API
Expand Down Expand Up @@ -44,6 +51,65 @@ spec:
minProperties: 1
properties:
aws:
properties:
authEnabled:
default: false
type: boolean
autoMinorVersionUpgrade:
default: false
type: boolean
cacheNodeType:
type: string
engineVersion:
default: "7.0"
enum:
- "7.1"
- "7.0"
- 6.x
type: string
x-kubernetes-validations:
- message: engineVersion cannot be downgraded.
rule: (self != "7.0" || oldSelf == "7.0" || oldSelf == "6.x")
- message: engineVersion cannot be downgraded.
rule: (self != "7.1" || oldSelf == "7.1" || oldSelf == "7.0"
|| oldSelf == "6.x")
- message: engineVersion cannot be downgraded.
rule: (self != "6.x" || oldSelf == "6.x")
parameters:
additionalProperties:
type: string
type: object
preferredMaintenanceWindow:
description: |-
Specifies the weekly time range during which maintenance on the cluster is
performed. It is specified as a range in the format ddd:hh24:mi-ddd:hh24:mi (24H
Clock UTC). The minimum maintenance window is a 60 minute period.
Valid values for ddd are: sun mon tue wed thu fri sat
Example: sun:23:00-mon:01:30
type: string
replicasPerShard:
default: 0
format: int32
maximum: 5
minimum: 0
type: integer
x-kubernetes-validations:
- message: ReplicasPerShard is immutable.
rule: (self == oldSelf)
shardCount:
format: int32
maximum: 500
minimum: 1
type: integer
x-kubernetes-validations:
- message: ShardCount is immutable.
rule: (self == oldSelf)
required:
- cacheNodeType
- replicasPerShard
- shardCount
type: object
azure:
type: object
Expand Down Expand Up @@ -92,6 +158,8 @@ spec:
status:
description: RedisClusterStatus defines the observed state of RedisCluster
properties:
authString:
type: string
conditions:
description: List of status conditions to indicate the status of a
RedisInstance.
Expand Down Expand Up @@ -153,6 +221,10 @@ spec:
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
discoveryEndpoint:
type: string
id:
type: string
state:
type: string
type: object
Expand Down
20 changes: 19 additions & 1 deletion config/samples/cloud-control_v1beta1_rediscluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,22 @@ metadata:
app.kubernetes.io/managed-by: kustomize
name: rediscluster-sample
spec:
# TODO(user): Add fields here
instance:
aws:
authEnabled: false
autoMinorVersionUpgrade: true
cacheNodeType: cache.r7g.large
engineVersion: 7.0
parameters:
activedefrag: 'yes'
maxmemory-policy: volatile-lru
preferredMaintenanceWindow: sun:23:00-mon:01:30
replicasPerShard: 1
shardCount: 3
ipRange:
name: 3ac2a428-c267-4c10-b814-c77c0deff977
remoteRef:
name: awsredisinstance-sample123
namespace: skr-aws
scope:
name: dule-aws
Loading

0 comments on commit 651cb8a

Please sign in to comment.