Skip to content

feat: add ExternalAccess API and announce human-readable node names - #277

Open
scrothers wants to merge 1 commit into
valkey-io:mainfrom
scrothers:external-clusters/human-nodename
Open

feat: add ExternalAccess API and announce human-readable node names#277
scrothers wants to merge 1 commit into
valkey-io:mainfrom
scrothers:external-clusters/human-nodename

Conversation

@scrothers

@scrothers scrothers commented Jun 25, 2026

Copy link
Copy Markdown

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 externalAccess block 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-nodename set to its ValkeyNode name (for example cluster-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

  • New optional spec.externalAccess.enabled on ValkeyCluster.
  • When enabled, nodes announce a human-readable node name. Node-to-node traffic is untouched.

Implementation

  • Added ExternalAccessSpec to the ValkeyCluster API and mirrored the field onto ValkeyNode. It's copied through buildClusterValkeyNode like the other propagated spec fields.
  • buildContainersDef appends --cluster-announce-human-nodename to the server command when external access is enabled. This uses the same argument seam that already sets --cluster-announce-ip.
  • cluster-announce-human-nodename is 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

  • Unit tests confirm the node name is announced when enabled, and that a nil or disabled externalAccess leaves the server command unchanged.
  • make test and make lint pass locally.
  • See docs/valkeycluster.md for the user-facing description.

Checklist

  • This Pull Request is related to one issue.
  • Commit message explains what changed and why
  • Tests are added or updated.
  • Documentation files are updated.
  • I have run pre-commit locally (ran make test and make lint instead)

### 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>
Copilot AI review requested due to automatic review settings June 25, 2026 17:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.enabled to ValkeyClusterSpec and mirror/propagate it onto ValkeyNodeSpec.
  • When externalAccess.enabled is 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.

Comment thread docs/valkeycluster.md
Comment on lines +74 to +76
`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.
Comment on lines +154 to +156
// 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.
@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds the first external access API hook for Valkey clusters. The main changes are:

  • Adds optional spec.externalAccess.enabled to ValkeyCluster.
  • Propagates external access settings onto generated ValkeyNode resources.
  • Appends --cluster-announce-human-nodename when external access is enabled.
  • Updates CRDs, docs, samples, generated deepcopy code, and unit tests.

Confidence Score: 5/5

The change appears safe to merge based on the reviewed API, CRD, controller propagation, command generation, docs, samples, and tests.

The implementation is narrowly scoped, preserves default behavior when external access is unset or disabled, and includes targeted coverage for the new command argument behavior.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex attempted the base external-access test command, but the run failed with exit code 127 due to a missing Go tool.
  • T-Rex re-ran the head external-access test command, which also failed with exit code 127 because Go was not available.
  • T-Rex added external-access command tests before-test.go and after-test.go to validate the command arrays and propagation when Go would be present.
  • T-Rex inspected the baseline CRDs and confirmed they did not contain spec.properties.externalAccess and that the external-access sample was not included.
  • T-Rex inspected the updated CRDs and confirmed externalAccess.enabled type boolean is present, externalAccess is optional, there is no default for enabled, and samples/docs reference externalAccess behavior.
  • T-Rex re-ran the validation commands after the CRD changes and both commands exited with code 0 while capturing command details, working directory, captions, commits, verbose checks, and exit codes.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "feat: add ExternalAccess API and announc..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants