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

K8SPSMDB-1140: Allow users to override hostnames in replset config #1640

Merged
merged 17 commits into from
Sep 24, 2024

Conversation

egegunes
Copy link
Contributor

@egegunes egegunes commented Sep 5, 2024

K8SPSMDB-1140 Powered by Pull Request Badge

CHANGE DESCRIPTION

Problem:
There's no way to specify hostnames in replset config. Some of our users want to override hostnames to support their multi-cluster topologies.

Solution:

This PR introduces a new field called replsetOverrides to directly influence replset configuration:

replsets:
- name: rs0
   replsetOverrides:
     cluster1-rs0-0:
       host: rs0-0.egedemo.xyz:27017
     cluster1-rs0-1:
       host: rs0-1.egedemo.xyz:27017
     cluster1-rs0-2:
       host: rs0-2.egedemo.xyz:27017

Once you override hostnames, operator will start changing hosts in replset configuration one by one (secondaries first, primary last).

While doing this, I also wanted to allow users to add custom tags to replset members. replsetOverrides field also allow specifying tags:

replsets:
- name: rs0
   replsetOverrides:
     cluster1-rs0-0:
       host: rs0-0.egedemo.xyz:27017
       tags:
         key: value
     cluster1-rs0-1:
       host: rs0-1.egedemo.xyz:27017
       tags:
         key: value
     cluster1-rs0-2:
       host: rs0-2.egedemo.xyz:27017
       tags:
         key: value

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported MongoDB version?
  • Does the change support oldest and newest supported Kubernetes version?

@pull-request-size pull-request-size bot added size/XL 500-999 lines size/XXL 1000+ lines and removed size/XL 500-999 lines labels Sep 5, 2024
kubectl_bin apply -f ${test_dir}/conf/external-services.yml

echo "patching PSMDB cluster with replsetOverrides: ${cluster}"
sed "s/NAMESPACE/${namespace}/g" ${test_dir}/conf/${cluster}-overridden.yml > ${tmp_dir}/${cluster}-overridden.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

[shfmt] reported by reviewdog 🐶

Suggested change
sed "s/NAMESPACE/${namespace}/g" ${test_dir}/conf/${cluster}-overridden.yml > ${tmp_dir}/${cluster}-overridden.yml
sed "s/NAMESPACE/${namespace}/g" ${test_dir}/conf/${cluster}-overridden.yml >${tmp_dir}/${cluster}-overridden.yml

kubectl_bin apply -f ${test_dir}/conf/external-services.yml

echo "creating PSMDB cluster: ${cluster}"
sed "s/NAMESPACE/${namespace}/g" ${test_dir}/conf/${cluster}-overridden.yml > ${tmp_dir}/${cluster}-overridden.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

[shfmt] reported by reviewdog 🐶

Suggested change
sed "s/NAMESPACE/${namespace}/g" ${test_dir}/conf/${cluster}-overridden.yml > ${tmp_dir}/${cluster}-overridden.yml
sed "s/NAMESPACE/${namespace}/g" ${test_dir}/conf/${cluster}-overridden.yml >${tmp_dir}/${cluster}-overridden.yml

@@ -6304,6 +6312,21 @@ spec:
format: int32
type: integer
type: object
replsetOverrides:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add it as an example into cr.yaml

Copy link
Contributor Author

Choose a reason for hiding this comment

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

inelpandzic
inelpandzic previously approved these changes Sep 20, 2024
@hors hors self-requested a review September 20, 2024 09:16
pooknull
pooknull previously approved these changes Sep 20, 2024
@egegunes egegunes dismissed stale reviews from pooknull and inelpandzic via 90bcfc5 September 20, 2024 18:16
@JNKPercona
Copy link
Collaborator

Test name Status
arbiter passed
balancer passed
custom-replset-name passed
custom-tls passed
cross-site-sharded passed
data-at-rest-encryption passed
data-sharded passed
demand-backup passed
demand-backup-eks-credentials passed
demand-backup-physical passed
demand-backup-physical-sharded passed
demand-backup-sharded passed
expose-sharded passed
ignore-labels-annotations passed
init-deploy passed
finalizer passed
ldap passed
ldap-tls passed
limits passed
liveness passed
mongod-major-upgrade passed
mongod-major-upgrade-sharded passed
monitoring-2-0 failure
multi-cluster-service passed
non-voting passed
one-pod passed
operator-self-healing-chaos passed
pitr passed
pitr-sharded passed
pitr-physical passed
pvc-resize passed
recover-no-primary passed
replset-overrides passed
rs-shard-migration passed
scaling passed
scheduled-backup passed
security-context passed
self-healing-chaos passed
service-per-pod passed
serviceless-external-nodes passed
smart-update passed
split-horizon passed
storage passed
tls-issue-cert-manager passed
upgrade passed
upgrade-consistency passed
upgrade-consistency-sharded-tls passed
upgrade-sharded passed
users passed
version-service passed
We run 50 out of 50

commit: d4f82a7
image: perconalab/percona-server-mongodb-operator:PR-1640-d4f82a71

@hors hors merged commit 6f25a61 into main Sep 24, 2024
16 of 17 checks passed
@hors hors deleted the K8SPSMDB-1140 branch September 24, 2024 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XXL 1000+ lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants