Skip to content

Commit 62ef7b2

Browse files
fix: support compute resource group configurations (#209)
* fix: create multiple configmap for different resource groups * update version
1 parent b115903 commit 62ef7b2

File tree

5 files changed

+152
-3
lines changed

5 files changed

+152
-3
lines changed

charts/risingwave/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type: application
1919
# This is the chart version. This version number should be incremented each time you make changes
2020
# to the chart and its templates, including the app version.
2121
# Versions are expected to follow Semantic Versioning (https://semver.org/)
22-
version: 0.2.41
22+
version: 0.2.42
2323

2424
# This is the version number of the application being deployed. This version number should be
2525
# incremented each time you make changes to the application. Versions are not expected to

charts/risingwave/templates/_helpers.tpl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,16 @@ Process:
698698
(include "risingwave.renderConfig" (dict "config" .Values.computeComponent.configuration) | trim) }}
699699
{{- end }}
700700
701+
{{- define "risingwave.computeConfigForResourceGroup"}}
702+
{{- /* Renders compute configuration for a specific resource group.
703+
Falls back to global configuration if resource group doesn't have custom config.
704+
Parameters: .group (resource group object), .root (root context) */}}
705+
{{- $group := .group }}
706+
{{- $root := .root }}
707+
{{ default (include "risingwave.renderConfig" (dict "config" $root.Values.configuration) | trim)
708+
(include "risingwave.renderConfig" (dict "config" $group.configuration) | trim) }}
709+
{{- end }}
710+
701711
{{- define "risingwave.configHashAnnotation" }}
702712
{{- if not .Values.existingConfigMap }}
703713
risingwave.risingwavelabs.com/config-hash: {{ include "risingwave.config" . | sha1sum }}
@@ -723,7 +733,18 @@ risingwave.risingwavelabs.com/compactor-config-hash: {{ include "risingwave.comp
723733
{{- end }}
724734
725735
{{- define "risingwave.computeConfigHashAnnotation" }}
726-
{{- if and (not .Values.existingConfigMap) (not .Values.computeComponent.configuration) }}
736+
{{- if and (not .Values.existingConfigMap) .Values.computeComponent.configuration }}
727737
risingwave.risingwavelabs.com/compute-config-hash: {{ include "risingwave.computeConfig" . | sha1sum }}
728738
{{- end }}
729739
{{- end }}
740+
741+
{{- define "risingwave.computeConfigHashAnnotationForResourceGroup" }}
742+
{{- /* Creates config hash annotation for compute resource groups with custom configurations.
743+
Only creates annotation when resource group has custom configuration.
744+
Parameters: .group (resource group object), .root (root context) */}}
745+
{{- $group := .group }}
746+
{{- $root := .root }}
747+
{{- if and (not $root.Values.existingConfigMap) $group.configuration }}
748+
risingwave.risingwavelabs.com/compute-config-hash: {{ include "risingwave.computeConfigForResourceGroup" (dict "group" $group "root" $root) | sha1sum }}
749+
{{- end }}
750+
{{- end }}

charts/risingwave/templates/compute-sts.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ spec:
100100
{{- if $comp.podAnnotations }}
101101
{{- toYaml $comp.podAnnotations | nindent 8 }}
102102
{{- end }}
103+
{{- if $group.configuration }}
104+
{{- include "risingwave.computeConfigHashAnnotationForResourceGroup" (dict "group" $group "root" $ctx) | nindent 8 }}
105+
{{- else }}
103106
{{- include "risingwave.computeConfigHashAnnotation" $ctx | nindent 8 }}
107+
{{- end }}
104108
{{- if $ctx.Values.compactMode.enabled }}
105109
{{- include "risingwave.frontendConfigHashAnnotation" $ctx | nindent 8 }}
106110
{{- end }}
@@ -114,7 +118,11 @@ spec:
114118
volumes:
115119
- name: config
116120
configMap:
117-
name: {{ include "risingwave.configurationConfigMapName" $ctx }}
121+
name: {{- if $group.configuration }}
122+
{{ include "risingwave.configurationConfigMapName" $ctx }}-compute-{{ $group.name }}
123+
{{- else }}
124+
{{ include "risingwave.configurationConfigMapName" $ctx }}
125+
{{- end }}
118126
{{- if and $ctx.Values.compactMode.enabled $ctx.Values.tls.existingSecretName }}
119127
- name: certs
120128
secret:

charts/risingwave/templates/configmap.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ SPDX-License-Identifier: APACHE-2.0
44
*/}}
55

66
{{- if empty .Values.existingConfigMap }}
7+
{{- $resourceGroups := .Values.computeComponent.resourceGroups | default list }}
8+
{{- $hasGroups := gt (len $resourceGroups) 0 }}
9+
10+
{{/* Main ConfigMap for all components except compute resource groups with custom configs */}}
711
apiVersion: v1
812
kind: ConfigMap
913
metadata:
@@ -22,4 +26,28 @@ data:
2226
risingwave.compute.toml : |{{ include "risingwave.computeConfig" . | nindent 4 }}
2327
risingwave.compactor.toml : |{{ include "risingwave.compactorConfig" . | nindent 4 }}
2428
risingwave.iceberg_compactor.toml : |{{ include "risingwave.icebergCompactorConfig" . | nindent 4 }}
29+
30+
{{/* Additional ConfigMaps for compute resource groups with custom configurations */}}
31+
{{- if $hasGroups }}
32+
{{- range $group := $resourceGroups }}
33+
{{- if $group.configuration }}
34+
---
35+
apiVersion: v1
36+
kind: ConfigMap
37+
metadata:
38+
name: {{ include "risingwave.configurationConfigMapName" $ }}-compute-{{ $group.name }}
39+
labels:
40+
{{- include "risingwave.labels" $ | nindent 4 }}
41+
{{- "risingwave.risingwavelabs.com/component: compute" | nindent 4 }}
42+
{{- printf "risingwave.risingwavelabs.com/resource-group: %s" $group.name | nindent 4 }}
43+
{{- $annotations := (include "risingwave.annotations" $ ) | trim }}
44+
{{- if $annotations }}
45+
annotations:
46+
{{ nindent 4 $annotations }}
47+
{{- end }}
48+
data:
49+
risingwave.compute.toml : |{{ include "risingwave.computeConfigForResourceGroup" (dict "group" $group "root" $) | nindent 4 }}
50+
{{- end }}
51+
{{- end }}
52+
{{- end }}
2553
{{- end }}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
suite: Test compute resource groups ConfigMaps
2+
templates:
3+
- configmap.yaml
4+
chart:
5+
appVersion: 1.0.0
6+
version: 0.0.1
7+
tests:
8+
- it: creates separate ConfigMaps for resource groups with custom configurations
9+
set:
10+
computeComponent:
11+
replicas: 2
12+
resourceGroups:
13+
- name: group-a
14+
replicas: 3
15+
configuration:
16+
streaming:
17+
parallelism: 4
18+
- name: group-b
19+
replicas: 1
20+
configuration:
21+
streaming:
22+
parallelism: 2
23+
asserts:
24+
- hasDocuments:
25+
count: 3 # 1 main ConfigMap + 2 additional ConfigMaps for resource groups
26+
# Main ConfigMap
27+
- documentIndex: 0
28+
isKind:
29+
of: ConfigMap
30+
- documentIndex: 0
31+
equal:
32+
path: metadata.name
33+
value: RELEASE-NAME-risingwave-configuration
34+
# Resource group ConfigMaps - test names first
35+
- documentIndex: 1
36+
isKind:
37+
of: ConfigMap
38+
- documentIndex: 1
39+
equal:
40+
path: metadata.name
41+
value: RELEASE-NAME-risingwave-configuration-compute-group-a
42+
- documentIndex: 1
43+
equal:
44+
path: 'metadata.labels["risingwave.risingwavelabs.com/resource-group"]'
45+
value: group-a
46+
- documentIndex: 2
47+
isKind:
48+
of: ConfigMap
49+
- documentIndex: 2
50+
equal:
51+
path: metadata.name
52+
value: RELEASE-NAME-risingwave-configuration-compute-group-b
53+
- documentIndex: 2
54+
equal:
55+
path: 'metadata.labels["risingwave.risingwavelabs.com/resource-group"]'
56+
value: group-b
57+
58+
- it: does not create additional ConfigMaps when resource groups have no custom configurations
59+
set:
60+
computeComponent:
61+
replicas: 2
62+
resourceGroups:
63+
- name: group-a
64+
replicas: 3
65+
- name: group-b
66+
replicas: 1
67+
asserts:
68+
- hasDocuments:
69+
count: 1 # Only main ConfigMap, no additional ConfigMaps for resource groups without custom configs
70+
- documentIndex: 0
71+
isKind:
72+
of: ConfigMap
73+
- documentIndex: 0
74+
equal:
75+
path: metadata.name
76+
value: RELEASE-NAME-risingwave-configuration
77+
78+
- it: handles empty resource groups list
79+
set:
80+
computeComponent:
81+
replicas: 2
82+
resourceGroups: []
83+
asserts:
84+
- hasDocuments:
85+
count: 1 # Only main ConfigMap
86+
- documentIndex: 0
87+
isKind:
88+
of: ConfigMap
89+
- documentIndex: 0
90+
equal:
91+
path: metadata.name
92+
value: RELEASE-NAME-risingwave-configuration

0 commit comments

Comments
 (0)