[FEATURE]: Propagate role label to pods

Open Beginner friendly
#443 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
go, kubernetes

Research direction

Start by locating the operator logic that propagates the existing cluster, node-index, and shard-index labels to pods, then compare it with the ValkeyNode status role shown in the issue. Done means primary and replica pods receive distinct valkey.io/role labels while existing ValkeyCluster resources remain compatible.

Written by the indexing model from the issue text.

Description

enhancement
Pre-flight checks
  • I have searched existing issues and discussions and could not find a duplicate.
Problem / Use case

I'm checking providing access to discover cluster nodes from outside of EKS cluster, but still inside private network. So client connects via LB, discover nodes and connects by IP to required shards.

While this epic is in progress, I'm trying to add Service (LoadBalancer) in front with config like this:

---
apiVersion: v1
kind: Service
metadata:
  name: external-service
spec:
  ports:
    - name: valkey
      port: 6379
      protocol: TCP
      targetPort: 6379
  selector:
    valkey.io/cluster: test-cluster
  type: LoadBalancer

But it adds all pods from the cluster, not only primary. It's not a big issue I would say, but would be useful to be able to limit it.

As I see, this info already exists in ValkeyNode status (see example below), so it should be relatively easy to add it.

Also, it could be useful for other use cases.

NAME               READY   ROLE      POD                         AGE
test-cluster-0-0   true    primary   valkey-test-cluster-0-0-0   40m
test-cluster-0-1   true    replica   valkey-test-cluster-0-1-0   40m
Proposed solution

Operator already propagates Valkey specific labels, like:

  labels:
    valkey.io/cluster: test-cluster
    valkey.io/node-index: "0"
    valkey.io/shard-index: "0"

I think one more could be added, like valkey.io/role: primary (or replica)

Scope of change

Small (small CRD field or controller behaviour tweak)

API / behaviour impact
  • This change is backwards-compatible with existing ValkeyCluster CRs.
  • This change introduces a breaking API change in v1alpha1.
Contribution
  • I would like to implement this feature myself.
  • I would like to help review or test this feature.
Additional context

No response

Dominant language
Go
Stars
359
Forks
58
Avg merge
1d 12h
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from valkey-io/valkey-operator

All issues in valkey-io/valkey-operator

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.