Skip to content

Add default system users (#110)#129

Merged
jdheyburn merged 18 commits into
valkey-io:mainfrom
hieu2102:add-system-users
Apr 14, 2026
Merged

Add default system users (#110)#129
jdheyburn merged 18 commits into
valkey-io:mainfrom
hieu2102:add-system-users

Conversation

@hieu2102
Copy link
Copy Markdown
Contributor

@hieu2102 hieu2102 commented Apr 7, 2026

implements #110

  • add defaults system users _operator and _exporter
    • update GetClusterState, GetNodeState functions to connect to Valkey using _operator user
    • fall back to default (unauthenticated on WRONGPASS error)
    • metrics-exporter container will connect using _exporter user (by setting REDIS_USER, REDIS_PASSWORD env variables)
  • add CEL validation to reject users with named started with _
  • add ACL hash annotation to pod template, when the internal ACL secret (internal-<clusterName>-acl) changed, the pods will be recreated automatically

@hieu2102 hieu2102 marked this pull request as draft April 7, 2026 10:08
hieu2102 added 10 commits April 8, 2026 11:01
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
hieu2102 added 3 commits April 8, 2026 14:05
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
@hieu2102 hieu2102 marked this pull request as ready for review April 8, 2026 09:49
Copy link
Copy Markdown
Collaborator

@jdheyburn jdheyburn left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look at this! I've not tested this myself yet, but left some comments.

Comment thread internal/controller/metrics_exporter.go Outdated
Comment thread internal/controller/users.go
Comment thread internal/controller/users.go Outdated
Comment thread internal/controller/users.go Outdated
}

func generatePassword() string {
randstr := rand.Text()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What does this generate for us? i.e. password length, characters, etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added a comment about this in the latest commit

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I checked the generated value. Could we have it to be upper and lower case letters too? Today its just uppercase.

Comment thread internal/controller/valkeycluster_controller.go
Comment thread internal/controller/users.go
hieu2102 added 2 commits April 9, 2026 13:18
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Comment thread internal/controller/users.go
Copy link
Copy Markdown
Collaborator

@jdheyburn jdheyburn left a comment

Choose a reason for hiding this comment

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

Looks good! I've some minor comments, but would also appreciate @utdrmac taking a look since they raised the original ACL feature.

Comment thread internal/controller/users.go Outdated
}

func generatePassword() string {
randstr := rand.Text()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I checked the generated value. Could we have it to be upper and lower case letters too? Today its just uppercase.

Namespace: cluster.Namespace,
Labels: labels(cluster),
},
Data: map[string][]byte{},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we also need to specify the type here like what we did for the ACLs? @utdrmac what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, let me add it

Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Comment thread api/v1alpha1/valkeycluster_types.go Outdated
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Copy link
Copy Markdown
Collaborator

@jdheyburn jdheyburn left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

@jdheyburn jdheyburn merged commit 5b9adec into valkey-io:main Apr 14, 2026
7 checks passed
daanvinken added a commit to daanvinken/valkey-operator that referenced this pull request Apr 15, 2026
getValkeyRole in the ValkeyNode controller connects to Valkey
unauthenticated to check the replication role. This was missed
in valkey-io#129 when the cluster controller was updated to use _operator
credentials. Once the default user is restricted, the role check
fails silently and ValkeyNode status.role is always empty.

Signed-off-by: Daan Vinken <daanvinken@tythus.com>
@daanvinken
Copy link
Copy Markdown
Contributor

I think we missed one here #137

sandeepkunusoth pushed a commit to sandeepkunusoth/valkey-k8s-operator that referenced this pull request Apr 17, 2026
implements valkey-io#110
- add defaults system users `_operator`  and `_exporter`
- update `GetClusterState`, `GetNodeState` functions to connect to
Valkey using `_operator` user
    - fall back to `default` (unauthenticated on WRONGPASS error)
- `metrics-exporter` container will connect using `_exporter` user (by
setting `REDIS_USER`, `REDIS_PASSWORD` env variables)
- add CEL validation to reject users with named started with `_`
- add ACL hash annotation to pod template, when the internal ACL secret
(`internal-<clusterName>-acl`) changed, the pods will be recreated
automatically

---------

Signed-off-by: hieu2102 <hieund2102@gmail.com>
daanvinken added a commit to daanvinken/valkey-operator that referenced this pull request Apr 20, 2026
getValkeyRole in the ValkeyNode controller connects to Valkey
unauthenticated to check the replication role. This was missed
in valkey-io#129 when the cluster controller was updated to use _operator
credentials. Once the default user is restricted, the role check
fails silently and ValkeyNode status.role is always empty.

Signed-off-by: Daan Vinken <daanvinken@tythus.com>
daanvinken added a commit to daanvinken/valkey-operator that referenced this pull request Apr 22, 2026
getValkeyRole in the ValkeyNode controller connects to Valkey
unauthenticated to check the replication role. This was missed
in valkey-io#129 when the cluster controller was updated to use _operator
credentials. Once the default user is restricted, the role check
fails silently and ValkeyNode status.role is always empty.

Signed-off-by: Daan Vinken <daanvinken@tythus.com>
daanvinken added a commit to daanvinken/valkey-operator that referenced this pull request Apr 22, 2026
getValkeyRole in the ValkeyNode controller connects to Valkey
unauthenticated to check the replication role. This was missed
in valkey-io#129 when the cluster controller was updated to use _operator
credentials. Once the default user is restricted, the role check
fails silently and ValkeyNode status.role is always empty.

Signed-off-by: Daan Vinken <daanvinken@tythus.com>
daanvinken added a commit to daanvinken/valkey-operator that referenced this pull request Apr 22, 2026
getValkeyRole in the ValkeyNode controller connects to Valkey
unauthenticated to check the replication role. This was missed
in valkey-io#129 when the cluster controller was updated to use _operator
credentials. Once the default user is restricted, the role check
fails silently and ValkeyNode status.role is always empty.

Signed-off-by: Daan Vinken <daanvinken@tythus.com>
daanvinken added a commit to daanvinken/valkey-operator that referenced this pull request Apr 23, 2026
getValkeyRole in the ValkeyNode controller connects to Valkey
unauthenticated to check the replication role. This was missed
in valkey-io#129 when the cluster controller was updated to use _operator
credentials. Once the default user is restricted, the role check
fails silently and ValkeyNode status.role is always empty.

Signed-off-by: Daan Vinken <daanvinken@tythus.com>
jdheyburn pushed a commit that referenced this pull request Apr 30, 2026
This PR is a follow-up to #129 which added `_operator` system user
authentication to the cluster controller but missed the `getValkeyRole`
code path in the ValkeyNode controller.

### Summary

`getValkeyRole` connects to Valkey unauthenticated to check the
replication role. Once the default user is restricted or disabled via
`spec.users`, the role check fails silently and `ValkeyNode.status.role`
is always empty.

### Implementation

Pass `_operator` credentials to `getValkeyRole`, matching how the
cluster controller authenticates in `GetClusterState`. If the system
password secret doesn't exist yet (fresh cluster before ACLs are set
up), the password is empty and the connection falls back to
unauthenticated.

### Limitations

None.

### Testing

Existing E2E tests cover this path (role is populated in ValkeyNode
status). No behavioral change when the default user is open.

### Checklist
Before submitting the PR make sure the following are checked:

- [x] This Pull Request is related to one issue.
- [x] Commit message explains what changed and why
- [NA] Tests are added or updated.
- [NA] Documentation files are updated.
- [x] I have run pre-commit locally (`pre-commit run --all-files` or
hooks on commit)

Signed-off-by: Daan Vinken <daanvinken@tythus.com>
sandeepkunusoth pushed a commit to sandeepkunusoth/valkey-k8s-operator that referenced this pull request May 5, 2026
…#137)

This PR is a follow-up to valkey-io#129 which added `_operator` system user
authentication to the cluster controller but missed the `getValkeyRole`
code path in the ValkeyNode controller.

### Summary

`getValkeyRole` connects to Valkey unauthenticated to check the
replication role. Once the default user is restricted or disabled via
`spec.users`, the role check fails silently and `ValkeyNode.status.role`
is always empty.

### Implementation

Pass `_operator` credentials to `getValkeyRole`, matching how the
cluster controller authenticates in `GetClusterState`. If the system
password secret doesn't exist yet (fresh cluster before ACLs are set
up), the password is empty and the connection falls back to
unauthenticated.

### Limitations

None.

### Testing

Existing E2E tests cover this path (role is populated in ValkeyNode
status). No behavioral change when the default user is open.

### Checklist
Before submitting the PR make sure the following are checked:

- [x] This Pull Request is related to one issue.
- [x] Commit message explains what changed and why
- [NA] Tests are added or updated.
- [NA] Documentation files are updated.
- [x] I have run pre-commit locally (`pre-commit run --all-files` or
hooks on commit)

Signed-off-by: Daan Vinken <daanvinken@tythus.com>
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.

3 participants