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 nodePort declaration to chart/values.schema.json #26945

Merged
merged 8 commits into from
Nov 14, 2022

Conversation

joseph-max-coalfire
Copy link
Contributor

closes: #26812
Adding a nodePort declaration to the chart/values.schema.json file to allow users to explicitly define exactly which port the nodePort setting should use when deploying with the Helm chart.

This is important for users who have external load balancers and firewalls/security groups that have predefined traffic ports for Airflow. (e.g. a load balancer is expecting the airflow-webserver to listen on port 31000, and it's set up via Terraform, so I'd rather be able to specify a known port in Terraform beforehand rather than have to grab a new port every time I build Airflow)

Tested locally on minikube with the following values.yaml override.

webserver:
    service:
      type: NodePort
      ports:
        - name: airflow-ui
          port: 80
          targetPort: airflow-ui
          nodePort: 31000

Cluster comes up successfully with airflow-webserver service listening on expected nodePort. Output of the deployed airflow-webserver service object's YAML below:

Name:                     airflow-webserver
Namespace:                default
Labels:                   app.kubernetes.io/managed-by=Helm
                          chart=airflow-1.7.0-dev
                          component=webserver
                          heritage=Helm
                          release=airflow
                          tier=airflow
Annotations:              meta.helm.sh/release-name: airflow
                          meta.helm.sh/release-namespace: default
Selector:                 component=webserver,release=airflow,tier=airflow
Type:                     NodePort
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.104.151.191
IPs:                      10.104.151.191
Port:                     airflow-ui  80/TCP
TargetPort:               airflow-ui/TCP
NodePort:                 airflow-ui  31000/TCP
Endpoints:                <none>
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

Also tested without specifying a nodePort option (defaulting to ClusterIP) to ensure new schema doesn't break backwards compatibility.

@boring-cyborg
Copy link

boring-cyborg bot commented Oct 7, 2022

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@dstandish
Copy link
Contributor

Do you think you could add a test for this?

@joseph-max-coalfire
Copy link
Contributor Author

joseph-max-coalfire commented Oct 9, 2022

Do you think you could add a test for this?

@dstandish just added one and tested locally. Let me know if it needs more coverage

)
]
)
def test_nodeport_service(self, ports, expected_ports):
Copy link
Contributor

@dstandish dstandish Oct 10, 2022

Choose a reason for hiding this comment

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

looks like your params aren't consistent with those provided in expand
but let's see what the tests tell us
i'd also add an entry (in expand) for when no nodePort is provided

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks like your params aren't consistent with those provided in expand

@dstandish Not sure I follow-- I used the test_ports_overrides param structure as a reference, and it looks like CI checks are passing

i'd also add an entry (in expand) for when no nodePort is provided

Added (lines 730-733) and tested locally with success. We'll see if the remote CI checks pass as well

Copy link
Contributor

Choose a reason for hiding this comment

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

all good.

one thing though.

looking here, it looks like name is not a valid attr for nodeport. probably best to remov that.

@joseph-max-coalfire joseph-max-coalfire force-pushed the add-nodeport-to-helm-schema branch 5 times, most recently from b031585 to 52d3aa9 Compare October 12, 2022 20:19
@joseph-max-coalfire joseph-max-coalfire requested review from dstandish and removed request for jedcunningham October 12, 2022 22:03
@joseph-max-coalfire joseph-max-coalfire force-pushed the add-nodeport-to-helm-schema branch 2 times, most recently from 44a5a0b to 24e04a7 Compare October 17, 2022 16:49
@joseph-max-coalfire
Copy link
Contributor Author

@dstandish would you be able to re-review this this week? No worries if not, just checking. It also looks like I somehow set you as the only reviewer, so if there's someone else who can review it as well, let me know

@joseph-max-coalfire joseph-max-coalfire force-pushed the add-nodeport-to-helm-schema branch 2 times, most recently from 047ca0c to 75a38eb Compare October 18, 2022 13:03
@joseph-max-coalfire
Copy link
Contributor Author

^ added a trailing comma that was causing the Black CI check to fail. Tests can be re-run when possible

@joseph-max-coalfire joseph-max-coalfire force-pushed the add-nodeport-to-helm-schema branch 6 times, most recently from 23162de to ee252ad Compare October 24, 2022 15:06
@potiuk potiuk force-pushed the add-nodeport-to-helm-schema branch from ee252ad to 41feda7 Compare October 31, 2022 01:47
@potiuk
Copy link
Member

potiuk commented Nov 7, 2022

I run the workflow. @dstandish ?

Copy link
Contributor

@dstandish dstandish left a comment

Choose a reason for hiding this comment

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

small things

)
]
)
def test_nodeport_service(self, ports, expected_ports):
Copy link
Contributor

Choose a reason for hiding this comment

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

all good.

one thing though.

looking here, it looks like name is not a valid attr for nodeport. probably best to remov that.

tests/charts/test_webserver.py Outdated Show resolved Hide resolved
tests/charts/test_webserver.py Outdated Show resolved Hide resolved
Co-authored-by: Daniel Standish <15932138+dstandish@users.noreply.github.com>
Co-authored-by: Daniel Standish <15932138+dstandish@users.noreply.github.com>
@joseph-max-coalfire
Copy link
Contributor Author

Thanks @dstandish and @potiuk!

@dstandish I've reviewed and committed your recommended changes

@potiuk potiuk merged commit cc571e8 into apache:main Nov 14, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Nov 14, 2022

Awesome work, congrats on your first merged pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:helm-chart Airflow Helm Chart
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add NodePort Option to the values schema
3 participants