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 option to define a pre-known nodeport range for service ports #123

Merged
merged 2 commits into from
Jun 12, 2024

Conversation

dfangl
Copy link
Member

@dfangl dfangl commented Jun 12, 2024

Motivation

Currently, we have no option to predefine or predict the node port values for service ports within the helm chart, they are randomly assigned.
However, if you need to access a service port from outside the cluster, you need to know the port mapping between the node port and the service port, which is currently only queryable through the k8s API.

To make this easier, I introduced an option to predefine a node port start range for node ports.

For example, if the service port range starts at 4510, and the node port range starts at 31510, the port mappings would look like this:

    - name: "external-service-port-4510"
      port: 4510
      targetPort: "ext-svc-4510"
      nodePort: 31510
    - name: "external-service-port-4511"
      port: 4511
      targetPort: "ext-svc-4511"
      nodePort: 31511

If the new variable service.externalServicePorts.nodePortStart is not set, the helm chart will assign random ports just like it does currently:

    - name: "external-service-port-4510"
      port: 4510
      targetPort: "ext-svc-4510"
    - name: "external-service-port-4511"
      port: 4511

This variable is not set by default, so the default behavior does not change.

Changes

  • Add option to define a nodePortStart to make node port ranges predictable when starting LocalStack using the helm chart

@dfangl dfangl self-assigned this Jun 12, 2024
Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for the contribution! A deterministic mapping of external service ports to node ports totally makes sense!
I tested your changes locally, and they are working just fine!
I'll move forward, merge this PR, and directly create a release! 🚀

@alexrashed alexrashed merged commit 7d788b2 into main Jun 12, 2024
2 checks passed
@alexrashed alexrashed deleted the nodeport-range branch June 12, 2024 08:28
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.

2 participants