Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add master selector #777

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

takara9
Copy link

@takara9 takara9 commented Feb 16, 2024

Description

A Redis client will be able to access the master node of the master-replica without sentinel client.
Redis operator adds label that indicate master node in redis cluster. and creates the service that have selector for master node. the Redis client will be able to access the master node with this the service.

the summary of the change

  • Adding the label to redis-replication-* pods that indicates role "master" or "slave/replica"
  • Adding new service that has new selector for write master role pod.

Related issue

#765
#453

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Tests have been added/modified and all tests pass.
  • Functionality/bugs have been confirmed to be unchanged or fixed.
  • I have performed a self-review of my own code.
  • Documentation has been updated or added where necessary.

Additional Context

new service "redis-replication-master"

maho-2:takara maho$ kubectl get svc -n ot-operators
NAME                                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)     AGE
redis-replication                    ClusterIP   10.98.224.240    <none>        6379/TCP    108m
redis-replication-additional         ClusterIP   10.99.82.148     <none>        6379/TCP    108m
redis-replication-headless           ClusterIP   None             <none>        6379/TCP    108m
redis-replication-master             ClusterIP   10.102.232.255   <none>        6379/TCP    108m  <-- Add
redis-sentinel-sentinel              ClusterIP   10.108.182.137   <none>        26379/TCP   106m
redis-sentinel-sentinel-additional   ClusterIP   10.104.130.132   <none>        26379/TCP   106m
redis-sentinel-sentinel-headless     ClusterIP   None             <none>        26379/TCP   106m
webhook-service                      ClusterIP   10.101.135.9     <none>        443/TCP     109m

selector items

maho-2:takara maho$ kubectl get svc redis-replication-master -n ot-operators -o=jsonpath='{.spec.selector}'|jq -r .
{
  "app": "redis-replication",
  "app.kubernetes.io/component": "middleware",
  "app.kubernetes.io/instance": "redis-replication",
  "app.kubernetes.io/managed-by": "Helm",
  "app.kubernetes.io/name": "redis-replication",
  "app.kubernetes.io/version": "0.15.1",
  "helm.sh/chart": "redis-replication-0.15.11",
  "redis-role": "master",
  "redis_setup_type": "replication",
  "role": "replication"
}

new labels in the redis replication node

maho-2:takara maho$ kubectl get pod -n ot-operators --show-labels redis-replication-0 
NAME                  READY   STATUS    RESTARTS   AGE    LABELS
redis-replication-0   1/1     Running   0          117m   app.kubernetes.io/component=middleware,app.kubernetes.io/instance=redis-replication,app.kubernetes.io/managed-by=Helm,app.kubernetes.io/name=redis-replication,app.kubernetes.io/version=0.15.1,app=redis-replication,apps.kubernetes.io/pod-index=0,controller-revision-hash=redis-replication-5f4b85b78b,helm.sh/chart=redis-replication-0.15.11,redis-role=master,redis_setup_type=replication,role=replication,statefulset.kubernetes.io/pod-name=redis-replication-0
maho-2:takara maho$ kubectl get pod -n ot-operators --show-labels redis-replication-1
NAME                  READY   STATUS    RESTARTS   AGE    LABELS
redis-replication-1   1/1     Running   0          116m   app.kubernetes.io/component=middleware,app.kubernetes.io/instance=redis-replication,app.kubernetes.io/managed-by=Helm,app.kubernetes.io/name=redis-replication,app.kubernetes.io/version=0.15.1,app=redis-replication,apps.kubernetes.io/pod-index=1,controller-revision-hash=redis-replication-5f4b85b78b,helm.sh/chart=redis-replication-0.15.11,redis-role=slave,redis_setup_type=replication,role=replication,statefulset.kubernetes.io/pod-name=redis-replication-1
maho-2:takara maho$ kubectl get pod -n ot-operators --show-labels redis-replication-2
NAME                  READY   STATUS    RESTARTS   AGE    LABELS
redis-replication-2   1/1     Running   0          116m   app.kubernetes.io/component=middleware,app.kubernetes.io/instance=redis-replication,app.kubernetes.io/managed-by=Helm,app.kubernetes.io/name=redis-replication,app.kubernetes.io/version=0.15.1,app=redis-replication,apps.kubernetes.io/pod-index=2,controller-revision-hash=redis-replication-5f4b85b78b,helm.sh/chart=redis-replication-0.15.11,redis-role=slave,redis_setup_type=replication,role=replication,statefulset.kubernetes.io/pod-name=redis-replication-2

@takara9 takara9 closed this Feb 16, 2024
@takara9 takara9 reopened this Feb 16, 2024
@takara9 takara9 marked this pull request as draft February 16, 2024 09:05
Copy link

codecov bot commented Feb 19, 2024

Codecov Report

Attention: Patch coverage is 4.65116% with 41 lines in your changes are missing coverage. Please review.

Project coverage is 32.39%. Comparing base (db14d1b) to head (9075a32).

Files Patch % Lines
k8sutils/redis-replication.go 0.00% 34 Missing ⚠️
controllers/redisreplication_controller.go 0.00% 4 Missing ⚠️
k8sutils/services.go 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #777      +/-   ##
==========================================
- Coverage   32.78%   32.39%   -0.39%     
==========================================
  Files          19       19              
  Lines        3233     3275      +42     
==========================================
+ Hits         1060     1061       +1     
- Misses       2114     2154      +40     
- Partials       59       60       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wkd-woo
Copy link
Contributor

wkd-woo commented Feb 21, 2024

When will this PR be applied? I'm waiting on it.
@iamabhishek-dubey @shubham-cmyk @drivebyer

@wkd-woo
Copy link
Contributor

wkd-woo commented Feb 21, 2024

up

@drivebyer
Copy link
Collaborator

When will this PR be applied? I'm waiting on it. @iamabhishek-dubey @shubham-cmyk @drivebyer

It appears to be in a Draft state at the moment. I am not sure if it is ready for review.

@wkd-woo
Copy link
Contributor

wkd-woo commented Feb 21, 2024

When will this PR be applied? I'm waiting on it. @iamabhishek-dubey @shubham-cmyk @drivebyer

It appears to be in a Draft state at the moment. I am not sure if it is ready for review.

Thank you for your response. I'm watching this project with great interest. very positive :)

@wkd-woo
Copy link
Contributor

wkd-woo commented Feb 23, 2024

Inspired by this PR and developed it to create a new PR. #785

I added read-replica endpoint.

dev-test

update
@takara9 takara9 force-pushed the add-master-selector-2 branch from 086202c to bd64ecd Compare February 26, 2024 04:43
@drivebyer
Copy link
Collaborator

drivebyer commented Feb 26, 2024

Thank you for your contribution. Could you please address the DCO and Semantic PR Validation issues? @takara9

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