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

chore: support parameters api for redis #1317

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 18 additions & 4 deletions addons/redis/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,29 @@ redis-cluster7-scripts-template-{{ .Chart.Version }}
{{/*
Define redis 7.X component config constraint name
*/}}
{{- define "redis7.configConstraint" -}}
redis7-config-cc
{{- define "redis7.paramsDefName" -}}
redis7-config-pd
{{- end -}}

{{/*
Define redis cluster 7.X component config constraint name
*/}}
{{- define "redisCluster7.configConstraint" -}}
redis-cluster7-cc
{{- define "redisCluster7.paramsDefName" -}}
redis-cluster7-pd
{{- end -}}

{{/*
Define redis 7.X component config constraint name
*/}}
{{- define "redis7.pcrName" -}}
redis7-pcr
{{- end -}}

{{/*
Define redis cluster 7.X component config constraint name
*/}}
{{- define "redisCluster7.pcrName" -}}
redis-cluster7-pcr
{{- end -}}

{{/*
Expand Down
3 changes: 0 additions & 3 deletions addons/redis/templates/cmpd-redis-7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ spec:
configs:
- name: redis-replication-config
templateRef: {{ include "redis7.configurationTemplate" . }}
constraintRef: {{ include "redis7.configConstraint" . }}
namespace: {{ .Release.Namespace }}
volumeName: redis-config
reRenderResourceTypes:
- vscale
- name: redis-metrics-config
templateRef: {{ include "redis.metricsConfiguration" . }}
namespace: {{ .Release.Namespace }}
Expand Down
3 changes: 0 additions & 3 deletions addons/redis/templates/cmpd-redis-cluster-7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ spec:
configs:
- name: redis-cluster-config
templateRef: {{ include "redisCluster7.configurationTemplate" . }}
constraintRef: {{ include "redisCluster7.configConstraint" . }}
namespace: {{ .Release.Namespace }}
volumeName: redis-cluster-config
reRenderResourceTypes:
- vscale
- name: redis-metrics-config
templateRef: {{ include "redis.metricsConfiguration" . }}
namespace: {{ .Release.Namespace }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
{{- $cc := .Files.Get "config/redis7-config-effect-scope.yaml" | fromYaml }}
apiVersion: apps.kubeblocks.io/v1beta1
kind: ConfigConstraint
{{- $pd := .Files.Get "config/redis7-config-effect-scope.yaml" | fromYaml }}
apiVersion: parameters.kubeblocks.io/v1alpha1
kind: ParametersDefinition
metadata:
name: {{ include "redisCluster7.configConstraint" . }}
name: {{ include "redisCluster7.paramsDefName" . }}
labels:
{{- include "redis.labels" . | nindent 4 }}
spec:

fileName: redis.conf
# ConfigurationSchema that impose restrictions on engine parameter's rule
parametersSchema:
topLevelKey: RedisParameter
cue: |-
{{- .Files.Get "config/redis-cluster7-config-constraint.cue" | nindent 6 }}

## require db instance restart
{{- if hasKey $cc "staticParameters" }}
{{- if hasKey $pd "staticParameters" }}
staticParameters:
{{- $params := get $cc "staticParameters" }}
{{- $params := get $pd "staticParameters" }}
{{- range $params }}
- {{ . }}
{{- end }}
{{- end}}

## reload parameters
## dynamicParameters
{{- if hasKey $cc "dynamicParameters" }}
{{- if hasKey $pd "dynamicParameters" }}
dynamicParameters:
{{- $params := get $cc "dynamicParameters" }}
{{- $params := get $pd "dynamicParameters" }}
{{- range $params }}
- {{ . }}
{{- end }}
{{- end}}


# redis configuration file format
fileFormatConfig:
format: redis
{{- end}}
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
{{- $cc := .Files.Get "config/redis7-config-effect-scope.yaml" | fromYaml }}
apiVersion: apps.kubeblocks.io/v1beta1
kind: ConfigConstraint
{{- $pd := .Files.Get "config/redis7-config-effect-scope.yaml" | fromYaml }}
apiVersion: parameters.kubeblocks.io/v1alpha1
kind: ParametersDefinition
metadata:
name: {{ include "redis7.configConstraint" . }}
name: {{ include "redis7.paramsDefName" . }}
labels:
{{- include "redis.labels" . | nindent 4 }}
spec:

fileName: redis.conf
# ConfigurationSchema that impose restrictions on engine parameter's rule
parametersSchema:
topLevelKey: RedisParameter
cue: |-
{{- .Files.Get "config/redis7-config-constraint.cue" | nindent 6 }}

## require db instance restart
{{- if hasKey $cc "staticParameters" }}
{{- if hasKey $pd "staticParameters" }}
staticParameters:
{{- $params := get $cc "staticParameters" }}
{{- $params := get $pd "staticParameters" }}
{{- range $params }}
- {{ . }}
{{- end }}
{{- end}}

## reload parameters
## dynamicParameters
{{- if hasKey $cc "dynamicParameters" }}
{{- if hasKey $pd "dynamicParameters" }}
dynamicParameters:
{{- $params := get $cc "dynamicParameters" }}
{{- $params := get $pd "dynamicParameters" }}
{{- range $params }}
- {{ . }}
{{- end }}
{{- end}}


# redis configuration file format
fileFormatConfig:
format: redis
{{- end}}
18 changes: 18 additions & 0 deletions addons/redis/templates/pcr-redis-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: parameters.kubeblocks.io/v1alpha1
kind: ParameterDrivenConfigRender
metadata:
name: {{ include "redisCluster7.pcrName" . }}
labels:
{{- include "redis.labels" . | nindent 4 }}
spec:
componentDef: {{ include "redisCluster7.cmpdName" . }}
parametersDefs:
- {{ include "redisCluster7.paramsDefName" . }}

configs:
- name: redis.conf
templateName: redis-cluster-config
fileFormatConfig:
format: redis
reRenderResourceTypes:
- vscale
17 changes: 17 additions & 0 deletions addons/redis/templates/pcr-redis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: parameters.kubeblocks.io/v1alpha1
kind: ParamConfigRenderer
metadata:
name: {{ include "redis7.pcrName" . }}
labels:
{{- include "redis.labels" . | nindent 4 }}
spec:
componentDef: {{ include "redis7.cmpdName" . }}
parametersDefs:
- {{ include "redis7.paramsDefName" . }}

configs:
- name: redis.conf
fileFormatConfig:
format: redis
reRenderResourceTypes:
- vscale
Loading