## What this PR does The RedisFailovers rendered by the `redis` and `valkey` apps and by the Harbor system chart set no placement, so the operator applies its default, a preferred pod anti-affinity on `kubernetes.io/hostname` ([generator.go#L795-L816](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L795-L816), the same in spotahome v1.3.0-rc1 that release-1.6 ships). A preference only decides where a pod starts. A sentinel evicted by a drain is recreated while both other nodes already run one, and a rollout of the sentinel Deployment adds each new sentinel before it removes an old one, so either can leave two sentinels on one node, and nothing moves them back. Seen on a three-node cluster running v1.6.4 and on clusters running v1.6.5. A tenant Redis with three replicas had its three Redis pods on three nodes and two of its three sentinels on one node, and Harbor's Redis had two of its three sentinels on one node too. Losing that node leaves one sentinel, below the quorum of two, so no failover can happen while it is down. The operator does not step in either, because it skips its checks while a pod of the instance is Pending or terminating ([checker.go#L101-L111](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/checker.go#L101-L111)), and the pods of a lost node stay terminating, so if the master was on that node the instance has no master until the node is back. This PR gives the sentinels and the data pods a spread with `maxSkew: 1` on `kubernetes.io/hostname`, `whenUnsatisfiable: DoNotSchedule` and `nodeTaintsPolicy: Ignore`, the default #4986 proposes for tenant etcd. The selector is the `app.kubernetes.io/name` and `app.kubernetes.io/component` pair the operator puts on every pod, without `redisfailovers-role`, which the operator switches between `master` and `slave` at runtime. No `affinity` is set, so the operator's anti-affinity stays. When `_cluster.scheduling.globalAppTopologySpreadConstraints` is set it replaces the default, and the selector is added to each of its constraints that has none, as the keycloak chart does for its database constraints. The etcd and postgres charts add it under the last constraint only, and a constraint without a selector counts no pods ([helpers.go#L36-L39](https://github.com/kubernetes/kubernetes/blob/v1.33.12/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/helpers.go#L36-L39)), so with a zone and a node constraint the zone one would spread nothing. A policy that does not parse or has no non-empty `topologySpreadConstraints` list fails the render. The sentinels get a hard constraint because of the quorum. A sentinel that waits Pending while its node is away leaves two sentinels on two nodes, which still form the quorum, while two sentinels on one node turn the loss of that node into a lost quorum. With `Ignore` a cordoned node still counts, so an evicted sentinel waits for its node instead of starting next to another one. The data pods get the same constraint because on a node-local StorageClass a pod that starts next to another one stays there with its volume. An instance with more pods than nodes still starts, because the skew is counted between the nodes that exist ([filtering.go#L338-L356](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/scheduler/framework/plugins/podtopologyspread/filtering.go#L338-L356)). The sentinel constraint also has `matchLabelKeys: [pod-template-hash]`. The operator sets no strategy on the sentinel Deployment ([generator.go#L546-L551](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L546-L551)), so a rollout of three sentinels adds one new pod at a time while the old ones run. Counted together with the old pods, a new sentinel can start on a node that already has another new one, and that pair stays once the old pods are gone. With the key, new pods are counted only against each other ([common.go#L95-L105](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/scheduler/framework/plugins/podtopologyspread/common.go#L95-L105)), and the ReplicaSet removes old pods that share a node with another pod first ([replica_set.go#L863-L878](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/replicaset/replica_set.go#L863-L878), [controller_utils.go#L859-L865](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/controller_utils.go#L859-L865)), so a rollout on three or more nodes ends with one sentinel per node. `matchLabelKeys` is beta and on by default since Kubernetes 1.27 ([kube_features.go#L1502-L1505](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/features/kube_features.go#L1502-L1505)). The RedisFailover CRD on main has both fields, and the redis-operator package replaces the CRD on upgrade. On upgrade the operator writes the StatefulSet and the sentinel Deployment in the same pass ([ensurer.go#L49-L57](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/ensurer.go#L49-L57)). The Deployment controller rolls the sentinels one at a time and removes an old one only after its replacement is ready, so three sentinels stay available. The StatefulSet uses `OnDelete` ([generator.go#L376-L379](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L376-L379)) and the operator replaces its pods itself ([checker.go#L14-L83](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/checker.go#L14-L83)). It waits while any Redis or sentinel pod is Pending or terminating ([check.go#L547-L559](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/check.go#L547-L559)) or a replica is not in sync, so the Redis pods are normally replaced after the sentinel rollout, one outdated replica per pass and the master last. The master's preStop hook asks the sentinels to fail over before the pod stops ([generator.go#L263-L267](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L263-L267)), so an instance with replicas goes through one failover during the upgrade, and a single-pod instance restarts its pod. The charts do not set `disableMasterRollout`. The Cozystack patches to the operator do not change any of this. This has two costs. With `Ignore` a node the pods can never run on, such as a tainted control plane, counts as an empty node, so on such a cluster each usable node takes one pod at most and the rest stay Pending, and for Redis a Pending pod also stops the operator's checks for the instance, including the choice of the first master of a new one. And data pods that already share a node on a node-local volume cannot be separated by a reschedule. The replica the operator recreates there during the rollout cannot be placed, the rollout stops before the master, and the instance runs one replica short, with the operator's checks stopped, until that replica's volume is recreated on another node. On storage that attaches from any node the recreated replica moves to a free node instead. A platform that wants the old behaviour can set `scheduling.globalAppTopologySpreadConstraints` to `ScheduleAnyway`, which the other charts that read it pick up too. #4880 adds a zone spread to the same two blocks of Harbor's RedisFailover and leaves the per-node part to the operator's anti-affinity, so whichever of the two lands second has to merge them. #2665 adds `affinity` values to the redis app, which would replace the operator's anti-affinity and do not touch the spread. The valkey app had no `test` target, so this PR adds the same three lines as #4346. New suites `packages/apps/redis/tests/topology_spread_test.yaml`, `packages/apps/valkey/tests/topology_spread_test.yaml` and `packages/system/harbor/tests/redis_spread_test.yaml` pin both default constraints, that no `affinity` is rendered, that a cluster-wide policy renders in place of the default with the selector added to every constraint that has none, that a selector the policy sets itself is kept, and that a malformed policy fails the render. Against the templates on main every new case fails, 9 for redis, 5 for valkey and 5 for Harbor, and against the first commit the 12 cases the second commit adds fail. Each of 21 mutations fails at least one case. In the default constraints they are `ScheduleAnyway` or no `matchLabelKeys` for the sentinels, `Honor` or `redisfailovers-role` in the selector for the data pods, `maxSkew: 2` in valkey and the Harbor sentinel selector set to `redis`. In the cluster-wide branch they are the policy ignored, `nodeTaintsPolicy` added to it, the selector added to no constraint, a selector the policy sets overwritten, the sentinel selector set to `redis`, the Harbor name without its `-redis` suffix, the policy check dropped or reduced to the empty list, and the parse error left out of the message. ```console $ docker run --rm -v "$PWD":/apps -w /apps/packages/apps/redis helmunittest/helm-unittest:4.2.3-1.1.2 . Test Suites: 6 passed, 6 total Tests: 77 passed, 77 total $ docker run --rm -v "$PWD":/apps -w /apps/packages/apps/valkey helmunittest/helm-unittest:4.2.3-1.1.2 . Test Suites: 1 passed, 1 total Tests: 5 passed, 5 total $ docker run --rm -v "$PWD":/apps -w /apps/packages/system/harbor helmunittest/helm-unittest:4.2.3-1.1.2 . Test Suites: 3 passed, 3 total Tests: 14 passed, 14 total $ hack/check-render-matrix.sh packages/apps/redis packages/apps/valkey packages/apps/harbor check-render-matrix: 3 rendered, 0 skipped ``` On main the redis chart has 68 tests in 5 suites and Harbor 9 in 2. With the render fixtures `helm template` of the three charts differs from main only in the added constraints, apart from the values they generate on every render. I have not rolled this out on a cluster, and the scheduling was not exercised against a running kube-scheduler. The files are the same on release-1.7. release-1.6 ships spotahome v1.3.0-rc1, whose CRD has neither `nodeTaintsPolicy` nor `matchLabelKeys` and is not replaced on upgrade, so its backport is a separate PR without those two fields. ### Screenshots Not a UI change. ### Downstream repositories Templates and tests of `packages/apps/redis`, `packages/apps/valkey` and `packages/system/harbor`, plus a `test` target in the valkey Makefile. No values, schema, default, README or `ApplicationDefinition` change. The website already describes `globalAppTopologySpreadConstraints` as applied to all managed applications and documents no placement workaround for Redis, so no trigger map entry applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(redis, valkey, harbor): spread Redis, Valkey and Harbor Redis data pods and sentinels with DoNotSchedule. The operator rolls existing instances, including one failover when replacing a replicated master. With nodeTaintsPolicy: Ignore, untolerated tainted nodes count as empty domains: if fewer nodes are usable than sentinels, some pods stay Pending. The operator skips its checks while any pod is Pending, so a new instance may never get its first master and an upgrade may stall. Node-local PVCs can also strand recreated replicas beside a peer. Before upgrading, set scheduling.globalAppTopologySpreadConstraints to a topologySpreadConstraints list with maxSkew: 1, topologyKey: kubernetes.io/hostname and whenUnsatisfiable: ScheduleAnyway to opt out. The override also applies to other charts that consume it. For an already stranded instance, apply that override, let the chart and operator reconcile, and verify all pods are Ready and a master is selected. This avoids deleting data. Keeping hard spreading instead requires enough usable nodes and a separate storage-migration plan for any stranded node-local replica. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **New Features** - Added support for configuring topology spread constraints across Redis, Valkey, Sentinel, and Harbor Redis workloads. - By default, pods are spread across hostnames with workload-specific selectors. - Custom constraints apply to Redis and Sentinel pods. Existing selectors are preserved; component-specific selectors are added when none is provided. - **Bug Fixes** - Invalid or empty topology spread configurations now fail validation during rendering. - **Chores** - Added a test command for the Valkey chart. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Managed Valkey Service
Valkey is a highly versatile and blazing-fast in-memory data store and cache that can significantly boost the performance of your applications. It is the BSD-3-Clause licensed, Linux Foundation-governed fork of Redis 7.2 and a drop-in replacement for it. Managed Valkey Service offers a hassle-free solution for deploying and managing Valkey clusters, ensuring that your data is always available and responsive.
Deployment Details
Service runs Valkey on the freshworks-oss redis-operator, which manages Sentinel-based HA and selects the Valkey engine natively via spec.engine: Valkey — so the official valkey/valkey image is used directly, with no Redis-compatibility shim.
- Docs: https://valkey.io/docs/
- Valkey: https://github.com/valkey-io/valkey
- Operator: https://github.com/freshworks-oss/redis-operator
storageClassis annotated as immutable in the chart schema — see storageClass immutability for the contract and which consumers enforce it.
Parameters
Common parameters
| Name | Description | Type | Value |
|---|---|---|---|
replicas |
Number of Valkey replicas. | int |
2 |
resources |
Explicit CPU and memory configuration for each Valkey replica. When omitted, the preset defined in resourcesPreset is applied. |
object |
{} |
resources.cpu |
CPU available to each replica. | quantity |
"" |
resources.memory |
Memory (RAM) available to each replica. | quantity |
"" |
resourcesPreset |
Default sizing preset used when resources is omitted. |
string |
t1.nano |
size |
Persistent Volume Claim size available for application data. | quantity |
1Gi |
storageClass |
StorageClass used to store the data. | string |
"" |
external |
Enable external access from outside the cluster. | bool |
false |
version |
Valkey major version to deploy | string |
v8 |
Application-specific parameters
| Name | Description | Type | Value |
|---|---|---|---|
authEnabled |
Enable password generation. | bool |
true |
schedulingClass |
Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's allowedSchedulingClasses. Setting any other value is refused, and the pods of an application whose class is not, or no longer, in that list get the tenant's class. Empty means inherit from the tenant. |
string |
"" |
Parameter examples and reference
resources and resourcesPreset
resources sets explicit CPU and memory configurations for each replica.
Every resource it leaves unset is taken from the preset defined in resourcesPreset.
resources:
cpu: 4000m
memory: 4Gi
resourcesPreset sets named CPU and memory configurations for each replica.
This setting is ignored if the corresponding resources value is set.
Presets follow a cloud-style <series>.<size> naming convention. Five series cover the full CPU-to-memory ratio range (t1 1:0.5, c1 1:1, s1 1:2, u1 1:4, m1 1:8) and each series ships eight sizes (nano through 4xlarge). The legacy flat names (nano, micro, small, medium, large, xlarge, 2xlarge) remain accepted as deprecated aliases and keep their original sizes, which do not follow one series: nano through small equal the t1 sizes of the same name, while medium equals c1.small rather than c1.medium.
See Resource management for the full size matrix and the legacy-to-instance-type mapping.