feat: add ExternalAccess API and announce human-readable node names - #277
feat: add ExternalAccess API and announce human-readable node names#277scrothers wants to merge 1 commit into
Conversation
### Summary Introduce an optional `externalAccess` block on ValkeyCluster as the foundation for exposing a cluster to clients outside Kubernetes. When the field is omitted the cluster is internal-only and renders identically to before. As the first capability under this flag, enabling external access announces a human-readable node name so cluster events reference the ValkeyNode name instead of only the opaque node ID. ### Implementation - Added `ExternalAccessSpec` (currently `enabled`) to `ValkeyClusterSpec` and mirrored the field onto `ValkeyNodeSpec`, copied verbatim in `buildClusterValkeyNode` alongside the other propagated spec fields. - When external access is enabled, `buildContainersDef` appends `--cluster-announce-human-nodename <node name>` to the server command, reusing the existing CLI-arg seam that already sets `--cluster-announce-ip`. Node-to-node traffic is unaffected. - `cluster-announce-human-nodename` is a Valkey 9.0+ directive, which matches the operator's documented baseline. ### Limitations This change only adds the API and the human-nodename announce. Per-shard Services, external hostnames, and client endpoint selection are added in follow-up changes. ### Testing - Unit tests assert the human nodename is announced when enabled and that a nil or disabled `externalAccess` leaves the rendered command unchanged. - `make test` and `make lint` pass locally. Signed-off-by: Steven Crothers <steven@scrothers.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces an initial externalAccess API surface on ValkeyCluster (propagated to ValkeyNode) as the first step in the broader “external cluster access” effort. In this first slice, the only wired behavior is improving cluster observability by announcing a human-readable node name when external access is enabled.
Changes:
- Add optional
spec.externalAccess.enabledtoValkeyClusterSpecand mirror/propagate it ontoValkeyNodeSpec. - When
externalAccess.enabledis true, append--cluster-announce-human-nodename <valkeyNodeName>to the server command. - Add unit tests, docs, CRD schema updates, and a sample manifest for the new API.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/controller/valkeynode_resources.go | Append --cluster-announce-human-nodename to the server command when ExternalAccess.Enabled is set. |
| internal/controller/valkeynode_resources_test.go | Add tests covering enabled vs disabled/nil ExternalAccess command rendering. |
| internal/controller/valkeycluster_controller.go | Propagate cluster.Spec.ExternalAccess into the constructed ValkeyNode spec. |
| api/v1alpha1/valkeycluster_types.go | Define ExternalAccessSpec and add it to ValkeyClusterSpec. |
| api/v1alpha1/valkeynode_types.go | Mirror ExternalAccess onto ValkeyNodeSpec. |
| api/v1alpha1/zz_generated.deepcopy.go | Generated deepcopy updates for the new API fields/types. |
| config/crd/bases/valkey.io_valkeyclusters.yaml | Generated CRD schema update for ValkeyCluster.externalAccess. |
| config/crd/bases/valkey.io_valkeynodes.yaml | Generated CRD schema update for ValkeyNode.externalAccess. |
| docs/valkeycluster.md | Document the new externalAccess block and current behavior. |
| config/samples/v1alpha1_valkeycluster-external-access.yaml | Add a sample ValkeyCluster manifest enabling external access. |
| config/samples/kustomization.yaml | Include the new sample in the samples kustomization. |
Files not reviewed (1)
- api/v1alpha1/zz_generated.deepcopy.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| `externalAccess` configures reachability of the cluster from outside Kubernetes. When omitted, the cluster is internal-only and behaves identically to a cluster without this field. Requires Valkey 9.0+. | ||
|
|
||
| Enabling external access announces a human-readable node name (the ValkeyNode name, e.g. `cluster-sample-1-2`) so cluster events such as failures reference it alongside the node ID. Node-to-node traffic (gossip and replication) always stays on internal pod IPs. |
| // ExternalAccessSpec defines how a ValkeyCluster is exposed to clients outside the | ||
| // Kubernetes cluster. Node-to-node traffic always stays on internal pod IPs; only | ||
| // the client-facing endpoint is affected. |
|
Part of the external cluster access effort (umbrella #276). This is the first of four stacked PRs; the rest build on it.
Summary
This adds an optional
externalAccessblock to ValkeyCluster. It will hold the configuration for reaching a cluster from outside Kubernetes. The field is nil by default, so a cluster that doesn't opt in renders exactly as it does today.To keep this PR small and easy to review on its own, the only behaviour it wires up is announcing a human-readable node name. With external access enabled, each node gets
--cluster-announce-human-nodenameset to its ValkeyNode name (for examplecluster-sample-1-2). Cluster events like failures then show that name next to the opaque node ID instead of just the ID. It's a small quality-of-life win, and a natural place to introduce the new API.Features / Behaviour Changes
spec.externalAccess.enabledon ValkeyCluster.Implementation
ExternalAccessSpecto the ValkeyCluster API and mirrored the field onto ValkeyNode. It's copied throughbuildClusterValkeyNodelike the other propagated spec fields.buildContainersDefappends--cluster-announce-human-nodenameto the server command when external access is enabled. This uses the same argument seam that already sets--cluster-announce-ip.cluster-announce-human-nodenameis a Valkey 9.0+ directive, which matches the operator's documented baseline.Limitations
This only lands the API and the node-name announce. The networking pieces (per-shard Services, hostnames, client redirects) come in the follow-up PRs in this stack.
Testing
externalAccessleaves the server command unchanged.make testandmake lintpass locally.docs/valkeycluster.mdfor the user-facing description.Checklist
make testandmake lintinstead)