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-929: Add replicaSet horizons #1293

Merged
merged 18 commits into from
Sep 15, 2023
Merged

K8SPSMDB-929: Add replicaSet horizons #1293

merged 18 commits into from
Sep 15, 2023

Conversation

egegunes
Copy link
Contributor

@egegunes egegunes commented Aug 21, 2023

K8SPSMDB-929 Powered by Pull Request Badge

CHANGE DESCRIPTION

Problem:
If cluster is exposed, mongo clients can't connect to ReplicaSet with ?replicaSet=<rsName>.

Cause:
mongod doesn't know about external addresses.

Solution:
We need to allow users to configure split-horizon DNS. We're adding a new field (horizons) to ReplsetSpec, and users will be able to configure horizons:

  replsets:
  - name: rs0
    expose:
      enabled: true
      exposeType: LoadBalancer
    horizons:
      cluster1-rs0-0:
        external: rs0-0.egedemo.xyz
        external-2: rs0-0.egedemo2.xyz
      cluster1-rs0-1:
        external: rs0-1.egedemo.xyz
        external-2: rs0-1.egedemo2.xyz
      cluster1-rs0-2:
        external: rs0-2.egedemo.xyz
        external-2: rs0-2.egedemo2.xyz

which will turn into the following replica set configuration:

[
        {
                "_id" : 0,
                "host" : "cluster1-rs0-0.cluster1-rs0.psmdb.svc.cluster.local:27017",
                "arbiterOnly" : false,
                "buildIndexes" : true,
                "hidden" : false,
                "priority" : 2,
                "tags" : {
                        "serviceName" : "cluster1",
                        "podName" : "cluster1-rs0-0"
                },
                "horizons" : {
                        "external" : "rs0-0.egedemo.xyz:27017",
                        "external-2" : "rs0-0.egedemo2.xyz:27017"
                },
                "secondaryDelaySecs" : NumberLong(0),
                "votes" : 1
        },
        {
                "_id" : 1,
                "host" : "cluster1-rs0-1.cluster1-rs0.psmdb.svc.cluster.local:27017",
                "arbiterOnly" : false,
                "buildIndexes" : true,
                "hidden" : false,
                "priority" : 2,
                "tags" : {
                        "podName" : "cluster1-rs0-1",
                        "serviceName" : "cluster1"
                },
                "horizons" : {
                        "external" : "rs0-1.egedemo.xyz:27017",
                        "external-2" : "rs0-1.egedemo2.xyz:27017"
                },
                "secondaryDelaySecs" : NumberLong(0),
                "votes" : 1
        },
        {
                "_id" : 2,
                "host" : "cluster1-rs0-2.cluster1-rs0.psmdb.svc.cluster.local:27017",
                "arbiterOnly" : false,
                "buildIndexes" : true,
                "hidden" : false,
                "priority" : 2,
                "tags" : {
                        "podName" : "cluster1-rs0-2",
                        "serviceName" : "cluster1"
                },
                "horizons" : {
                        "external" : "rs0-2.egedemo.xyz:27017",
                        "external-2" : "rs0-2.egedemo2.xyz:27017"
                },
                "secondaryDelaySecs" : NumberLong(0),
                "votes" : 1
        }
]

Limitations:

  • Connecting with horizon domains only supported if the client connects using TLS certificates.
  • Duplicate domain names in horizons are forbidden by MongoDB.
  • Using IP addresses in horizons are forbidden by MongoDB.
  • Horizons needs to be set for all pods or none. You can't have horizons only for some pods.

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?
  • Are the manifests (crd/bundle) regenerated if needed?
  • 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?

@egegunes
Copy link
Contributor Author

@spron-in please review the cr.yaml and let me know if you want to change the interface.

deploy/cr.yaml Outdated Show resolved Hide resolved
@egegunes egegunes force-pushed the K8SPSMDB-929 branch 3 times, most recently from a7c0581 to 636fb1b Compare August 21, 2023 09:35
horizons := make(map[string]string)
for h, domain := range rs.Horizons[pod.Name] {
d := domain
if !strings.HasSuffix(d, ":27017") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use DefaultMongoDBPort.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would but its a int32 and I need to convert it to string and this place will be very messy.

Choose a reason for hiding this comment

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

This "horizons" feature should allow you to chose ports, and not force the exclusive use of port 27017.

@pull-request-size pull-request-size bot added size/XL 500-999 lines and removed size/L 100-499 lines labels Sep 5, 2023
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Show resolved Hide resolved
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Show resolved Hide resolved
@hors hors self-requested a review September 7, 2023 08:37
hors and others added 3 commits September 7, 2023 11:37
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
hors and others added 3 commits September 7, 2023 11:38
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
e2e-tests/split-horizon/run Outdated Show resolved Hide resolved
@pull-request-size pull-request-size bot added size/L 100-499 lines and removed size/XL 500-999 lines labels Sep 8, 2023
@hors hors requested a review from inelpandzic September 8, 2023 10:53
inelpandzic
inelpandzic previously approved these changes Sep 9, 2023
@JNKPercona
Copy link
Collaborator

Test name Status
arbiter passed
balancer passed
custom-replset-name 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
limits passed
liveness passed
mongod-major-upgrade passed
mongod-major-upgrade-sharded passed
monitoring-2-0 passed
multi-cluster-service passed
non-voting passed
one-pod passed
operator-self-healing-chaos passed
pitr passed
pitr-sharded passed
pitr-physical passed
recover-no-primary 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 passed
upgrade-sharded passed
users passed
version-service passed
We run 45 out of 45

commit: f790869
image: perconalab/percona-server-mongodb-operator:PR-1293-f7908692

@hors hors merged commit 4c646de into main Sep 15, 2023
8 checks passed
@hors hors deleted the K8SPSMDB-929 branch September 15, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L 100-499 lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants