Skip to content

Commit 83244b0

Browse files
committed
feat(redis): add affinity configuration
Signed-off-by: kastakhov <[email protected]>
1 parent b9a95a0 commit 83244b0

7 files changed

Lines changed: 90 additions & 14 deletions

File tree

‎api/apps/v1alpha1/redis/types.go‎

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎api/apps/v1alpha1/redis/zz_generated.deepcopy.go‎

Lines changed: 27 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/apps/redis/README.md‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ Service utilizes the freshworks-oss Redis Operator (a maintained fork of the arc
1515

1616
### Common parameters
1717

18-
| Name | Description | Type | Value |
19-
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------- | ---------- | --------- |
20-
| `replicas` | Number of Redis replicas. | `int` | `2` |
21-
| `resources` | Explicit CPU and memory configuration for each Redis replica. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` |
22-
| `resources.cpu` | CPU available to each replica. | `quantity` | `""` |
23-
| `resources.memory` | Memory (RAM) available to each replica. | `quantity` | `""` |
24-
| `resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.nano` |
25-
| `size` | Persistent Volume Claim size available for application data. | `quantity` | `1Gi` |
26-
| `storageClass` | StorageClass used to store the data. | `string` | `""` |
27-
| `external` | Enable external access from outside the cluster. | `bool` | `false` |
28-
| `version` | Redis major version to deploy | `string` | `v8` |
18+
| Name | Description | Type | Value |
19+
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | --------- |
20+
| `replicas` | Number of Redis replicas. | `int` | `2` |
21+
| `resources` | Explicit CPU and memory configuration for each Redis replica. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` |
22+
| `resources.cpu` | CPU available to each replica. | `quantity` | `""` |
23+
| `resources.memory` | Memory (RAM) available to each replica. | `quantity` | `""` |
24+
| `resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.nano` |
25+
| `affinity` | Kubernetes affinity configuration for Redis and Sentinel pods. | `object` | `{}` |
26+
| `affinity.redis` | Kubernetes Affinity for Redis pods. When set, redis-operator uses it verbatim and does not add its default soft podAntiAffinity; include podAntiAffinity unless replica co-location is intended. | `*object` | `{}` |
27+
| `affinity.sentinel` | Kubernetes Affinity for Sentinel pods. When set, redis-operator uses it verbatim and does not add its default soft podAntiAffinity; include podAntiAffinity unless replica co-location is intended. | `*object` | `{}` |
28+
| `size` | Persistent Volume Claim size available for application data. | `quantity` | `1Gi` |
29+
| `storageClass` | StorageClass used to store the data. | `string` | `""` |
30+
| `external` | Enable external access from outside the cluster. | `bool` | `false` |
31+
| `version` | Redis major version to deploy | `string` | `v8` |
2932

3033

3134
### Application-specific parameters

‎packages/apps/redis/templates/redisfailover.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ spec:
3636
image: redis:6.2.6-alpine
3737
replicas: 3
3838
resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 6 }}
39+
{{- with (.Values.affinity).sentinel }}
40+
affinity: {{- toYaml . | nindent 6 }}
41+
{{- end }}
3942
redis:
4043
image: "redis:{{ include "redis.versionMap" $ }}"
4144
resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 6 }}
45+
{{- with (.Values.affinity).redis }}
46+
affinity: {{- toYaml . | nindent 6 }}
47+
{{- end }}
4248
replicas: {{ .Values.replicas }}
4349
{{- with .Values.size }}
4450
storage:

‎packages/apps/redis/values.schema.json‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,25 @@
9494
"2xlarge"
9595
]
9696
},
97+
"affinity": {
98+
"description": "Kubernetes affinity configuration for Redis and Sentinel pods.",
99+
"type": "object",
100+
"default": {},
101+
"properties": {
102+
"redis": {
103+
"description": "Kubernetes Affinity for Redis pods. When set, redis-operator uses it verbatim and does not add its default soft podAntiAffinity; include podAntiAffinity unless replica co-location is intended.",
104+
"type": "object",
105+
"default": {},
106+
"x-kubernetes-preserve-unknown-fields": true
107+
},
108+
"sentinel": {
109+
"description": "Kubernetes Affinity for Sentinel pods. When set, redis-operator uses it verbatim and does not add its default soft podAntiAffinity; include podAntiAffinity unless replica co-location is intended.",
110+
"type": "object",
111+
"default": {},
112+
"x-kubernetes-preserve-unknown-fields": true
113+
}
114+
}
115+
},
97116
"size": {
98117
"description": "Persistent Volume Claim size available for application data.",
99118
"default": "1Gi",

‎packages/apps/redis/values.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ resources: {}
6464
## @param {ResourcesPreset} resourcesPreset="t1.nano" - Default sizing preset used when `resources` is omitted.
6565
resourcesPreset: "t1.nano"
6666

67+
## @typedef {struct} AffinitySpec - Kubernetes affinity configuration.
68+
## @field {*object} [redis] - Kubernetes Affinity for Redis pods. When set, redis-operator uses it verbatim and does not add its default soft podAntiAffinity; include podAntiAffinity unless replica co-location is intended.
69+
## @field {*object} [sentinel] - Kubernetes Affinity for Sentinel pods. When set, redis-operator uses it verbatim and does not add its default soft podAntiAffinity; include podAntiAffinity unless replica co-location is intended.
70+
71+
## @param {AffinitySpec} [affinity] - Kubernetes affinity configuration for Redis and Sentinel pods.
72+
affinity:
73+
redis: {}
74+
sentinel: {}
75+
6776
## @param {quantity} size - Persistent Volume Claim size available for application data.
6877
size: 1Gi
6978

0 commit comments

Comments
 (0)