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-1032: Added possibility to specify nodeport for mongos expose #1392

Merged
merged 20 commits into from
Apr 2, 2024

Conversation

MikeDevresse
Copy link
Contributor

@MikeDevresse MikeDevresse commented Dec 6, 2023

K8SPSMDB-1032 Powered by Pull Request Badge

Added the possibility to specify nodeport for the mongos router. See #1381.

Problem:
In some infrastructure we want to specify the nodeport to maintain consistency between environments and create routing rules. In the actual state it is not possible.

Cause:
The configuration does not allow that

Solution:
Read nodeport from the expose structure and bind this to the service nodeport if the service is not per pod and the exposeType is NodePort.

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?

@CLAassistant
Copy link

CLAassistant commented Dec 6, 2023

CLA assistant check
All committers have signed the CLA.

@MikeDevresse MikeDevresse changed the title Draft: Added possibility to specify nodeport for mongos expose Added possibility to specify nodeport for mongos expose Dec 15, 2023
@hors hors added the community label Jan 11, 2024
@egegunes
Copy link
Contributor

@MikeDevresse please add this new field to deploy/cr.yaml as a commented example, we want to include this in next release

@egegunes egegunes changed the title Added possibility to specify nodeport for mongos expose K8SPSMDB-1032: Added possibility to specify nodeport for mongos expose Jan 12, 2024
@egegunes egegunes added this to the v1.16.0 milestone Jan 12, 2024
@egegunes
Copy link
Contributor

@MikeDevresse ping

Copy link
Collaborator

@hors hors left a comment

Choose a reason for hiding this comment

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

please fix

?   	github.com/percona/percona-server-mongodb-operator/clientcmd	[no test files]
# github.com/percona/percona-server-mongodb-operator/pkg/psmdb
Error: pkg/psmdb/mongos.go:441:8: i declared and not used

@egegunes
Copy link
Contributor

@MikeDevresse any updates?

@MikeDevresse
Copy link
Contributor Author

Hi sorry, checking this out asap

@pull-request-size pull-request-size bot added size/L 100-499 lines and removed size/XS 0-9 lines labels Feb 1, 2024
@pull-request-size pull-request-size bot added size/M 30-99 lines and removed size/L 100-499 lines labels Feb 1, 2024
@pull-request-size pull-request-size bot added size/L 100-499 lines and removed size/M 30-99 lines labels Feb 1, 2024
@pull-request-size pull-request-size bot added size/M 30-99 lines and removed size/S 10-29 lines labels Feb 6, 2024
@hors
Copy link
Collaborator

hors commented Feb 7, 2024

Hi @MikeDevresse did you test it? I am trying to do it, but it does not work for me :( Maybe it is due to GKE.

@MikeDevresse
Copy link
Contributor Author

mhh not working ... trying to find out why, I may update the PR soon then

@MikeDevresse
Copy link
Contributor Author

MikeDevresse commented Feb 8, 2024

Still not working, if anyone has an idea feel free to suggest, it seems that the configuration is not saved, is there a way to debug this maybe ?

Edit : I tried making a test and running it, but it seems complicated even with minikube to run a local image, and I dont have the permissions to publish to perconalab so it's hard to test because it means that each time I have to wait for the CI to be completed, if anyone has a workarround to that feel free to share, would love to test this locally before commiting

@egegunes
Copy link
Contributor

egegunes commented Feb 9, 2024

@MikeDevresse I'll check it next week and try to assist you.

@egegunes egegunes self-assigned this Mar 1, 2024
@egegunes
Copy link
Contributor

egegunes commented Mar 1, 2024

@MikeDevresse sorry for the delay, I'll check it next week.

@egegunes
Copy link
Contributor

egegunes commented Mar 9, 2024

@MikeDevresse I tried on GKE and your code works. The example port number you put in deploy/cr.yaml causes the following error:

reconcile mongos: create or update mongos service: create or update mongos service: Service "cluster1-mongos" is invalid: spec.ports[0].nodePort: Invalid value: 37017: provided port is not in the valid range. The range of valid ports is 30000-32767

I changed the port number to 32017:

       expose:
         exposeType: NodePort
         nodePort: 32017

and then allowed traffic to this port:

$ gcloud compute firewall-rules create test-node-port --allow tcp:32017

and was able to connect to the database:

$ mongo -u databaseAdmin -p <pass> <node-external-ip>:32017/admin
Percona Server for MongoDB shell version v5.0.22-19
connecting to: mongodb://<node-external-ip>:32017/admin?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("b7e35f2d-ab51-4b52-9e7e-95d325a13477") }
Percona Server for MongoDB server version: v6.0.13-10
WARNING: shell and server versions do not match
================
Warning: the "mongo" shell has been superseded by "mongosh",
which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
an upcoming release.
For installation instructions, see
https://docs.mongodb.com/mongodb-shell/install/
================
---
The server generated these startup warnings when booting:
        2024-03-09T10:35:18.027+00:00: While invalid X509 certificates may be used to connect to this server, they will not be considered permissible for authentication
---
mongos>

deploy/cr.yaml Outdated
@@ -492,6 +492,7 @@ spec:
# service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
# serviceLabels:
# rack: rack-22
# nodePort: 37017
Copy link
Contributor

Choose a reason for hiding this comment

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

please change this example to a port number between 30000-32767

@egegunes
Copy link
Contributor

@MikeDevresse tests are most likely failing because of a new version of PBM. We're fixing it in another PR. I'll ping you once it gets merged so you can rebase.

@egegunes
Copy link
Contributor

The PR which will fix PBM issues: #1485

@egegunes
Copy link
Contributor

@inelpandzic please review

@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
ldap passed
ldap-tls 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-tls passed
upgrade-sharded passed
users passed
version-service passed
We run 47 out of 47

commit: cf23e6e
image: perconalab/percona-server-mongodb-operator:PR-1392-cf23e6e2

@hors hors merged commit 90de960 into percona:main Apr 2, 2024
11 checks passed
@hors
Copy link
Collaborator

hors commented Apr 2, 2024

@MikeDevresse thank you for contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants