-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Remove all IPV6 listeners in ingress resources with -disable-ipv6 command line #3139
Merged
haywoodsh
merged 11 commits into
main
from
fix/remove-all-ingress-ipv6-listeners-when-commandline-argument-used
Oct 14, 2022
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9f3e53e
Remove ipv6 listeners in ingress upstreams when command line argument…
haywoodsh c2e3cb7
Add automated tests
haywoodsh db33331
calculate diff only when test fails and fix linting
haywoodsh 4af8235
fix typo
haywoodsh 66899e0
Remove unnecessary files and variables
haywoodsh a145c2c
fix linting
haywoodsh 7dee8b1
fix linting
haywoodsh 057645e
consolidate ipv6 tests and cosmetic changes
vepatel 44dd339
Merge branch 'main' into fix/remove-all-ingress-ipv6-listeners-when-c…
jjngx 69a6f64
Merge branch 'main' into fix/remove-all-ingress-ipv6-listeners-when-c…
haywoodsh f151b4c
Merge branch 'main' into fix/remove-all-ingress-ipv6-listeners-when-c…
haywoodsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1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8vdER3MXpGY2dWQ0thMzFqQXdjaXowZi9sU1JxM0hTMUdHR21lemhQVlRpcUxmZVpxYwpSMGlLYmhnYk9jVlZrSkozSzB5QXlLd1BUdW14S0haNnpJbVpTMGMwYW0rUlk5WUdxNVQ3WXJ6cHpjZnZwaU9VCmZmZTNSeUZUN2NmQ21mb09oREN0enVrQ2dZQjMwb0xDMVJMRk9ycW40M3ZDUzUxemM1em9ZNDR1QnpzcHd3WU4KVHd2UC9FeFdNZjNWSnJEakJDSCtULzZzeXNlUGJKRUltbHpNK0l3eXRGcEFOZmlJWEV0LzQ4WGY2ME54OGdXTQp1SHl4Wlp4L05LdER3MFY4dlgxUE9ucTJBNWVpS2ErOGpSQVJZS0pMWU5kZkR1d29seHZHNmJaaGtQaS80RXRUCjNZMThzUUtCZ0h0S2JrKzdsTkpWZXN3WEU1Y1VHNkVEVXNEZS8yVWE3ZlhwN0ZjanFCRW9hcDFMU3crNlRYcDAKWmdybUtFOEFSek00NytFSkhVdmlpcS9udXBFMTVnMGtKVzNzeWhwVTl6WkxPN2x0QjBLSWtPOVpSY21Vam84UQpjcExsSE1BcWJMSjhXWUdKQ2toaVd4eWFsNmhZVHlXWTRjVmtDMHh0VGwvaFVFOUllTktvCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg== |
54 changes: 54 additions & 0 deletions
54
tests/data/disable-ipv6-ingress/mergeable/disable-ipv6-ingress.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: disable-ipv6-ingress-master | ||
annotations: | ||
kubernetes.io/ingress.class: "nginx" | ||
nginx.org/mergeable-ingress-type: "master" | ||
spec: | ||
tls: | ||
- hosts: | ||
- disable-ipv6.example.com | ||
secretName: disable-ipv6-secret | ||
rules: | ||
- host: disable-ipv6.example.com | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: disable-ipv6-ingress-backend1-minion | ||
annotations: | ||
kubernetes.io/ingress.class: "nginx" | ||
nginx.org/mergeable-ingress-type: "minion" | ||
spec: | ||
rules: | ||
- host: disable-ipv6.example.com | ||
http: | ||
paths: | ||
- path: /backend1 | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: backend1-svc | ||
port: | ||
number: 80 | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: disable-ipv6-ingress-backend2-minion | ||
annotations: | ||
kubernetes.io/ingress.class: "nginx" | ||
nginx.org/mergeable-ingress-type: "minion" | ||
spec: | ||
rules: | ||
- host: disable-ipv6.example.com | ||
http: | ||
paths: | ||
- path: /backend2 | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: backend2-svc | ||
port: | ||
number: 80 |
29 changes: 29 additions & 0 deletions
29
tests/data/disable-ipv6-ingress/standard/disable-ipv6-ingress.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
annotations: | ||
name: disable-ipv6-ingress | ||
spec: | ||
ingressClassName: nginx | ||
tls: | ||
- hosts: | ||
- disable-ipv6.example.com | ||
secretName: disable-ipv6-secret | ||
rules: | ||
- host: disable-ipv6.example.com | ||
http: | ||
paths: | ||
- path: /backend2 | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: backend2-svc | ||
port: | ||
number: 80 | ||
- path: /backend1 | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: backend1-svc | ||
port: | ||
number: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import pytest | ||
from settings import TEST_DATA | ||
from suite.fixtures import PublicEndpoint | ||
from suite.resources_utils import ( | ||
create_example_app, | ||
create_items_from_yaml, | ||
create_secret_from_yaml, | ||
delete_common_app, | ||
delete_items_from_yaml, | ||
delete_secret, | ||
ensure_connection_to_public_endpoint, | ||
get_first_pod_name, | ||
get_ingress_nginx_template_conf, | ||
get_nginx_template_conf, | ||
wait_before_test, | ||
wait_until_all_pods_are_ready, | ||
) | ||
from suite.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml | ||
|
||
paths = ["backend1", "backend2"] | ||
|
||
|
||
class DisableIPV6Setup: | ||
""" | ||
Encapsulate the Disable IPV6 Example details. | ||
|
||
Attributes: | ||
public_endpoint (PublicEndpoint): | ||
ingress_name (str): | ||
ingress_host (str): | ||
ingress_pod_name (str): | ||
namespace (str): | ||
""" | ||
|
||
def __init__(self, public_endpoint: PublicEndpoint, ingress_name, ingress_host, ingress_pod_name, namespace): | ||
self.public_endpoint = public_endpoint | ||
self.ingress_host = ingress_host | ||
self.ingress_name = ingress_name | ||
self.ingress_pod_name = ingress_pod_name | ||
self.namespace = namespace | ||
|
||
|
||
@pytest.fixture(scope="class", params=["standard", "mergeable"]) | ||
def disable_ipv6_setup( | ||
request, | ||
kube_apis, | ||
ingress_controller_prerequisites, | ||
ingress_controller_endpoint, | ||
ingress_controller, | ||
test_namespace, | ||
) -> DisableIPV6Setup: | ||
print("------------------------- Deploy Disable IPV6 Example -----------------------------------") | ||
secret_name = create_secret_from_yaml( | ||
kube_apis.v1, test_namespace, f"{TEST_DATA}/disable-ipv6-ingress/disable-ipv6-secret.yaml" | ||
) | ||
|
||
create_items_from_yaml( | ||
kube_apis, f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml", test_namespace | ||
) | ||
ingress_name = get_name_from_yaml(f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml") | ||
ingress_host = get_first_ingress_host_from_yaml( | ||
f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml" | ||
) | ||
create_example_app(kube_apis, "simple", test_namespace) | ||
wait_until_all_pods_are_ready(kube_apis.v1, test_namespace) | ||
|
||
ensure_connection_to_public_endpoint( | ||
ingress_controller_endpoint.public_ip, | ||
ingress_controller_endpoint.port, | ||
ingress_controller_endpoint.port_ssl, | ||
) | ||
ic_pod_name = get_first_pod_name(kube_apis.v1, ingress_controller_prerequisites.namespace) | ||
|
||
def fin(): | ||
print("Clean up the Disable IPV6 Application:") | ||
delete_common_app(kube_apis, "simple", test_namespace) | ||
delete_items_from_yaml( | ||
kube_apis, f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml", test_namespace | ||
) | ||
delete_secret(kube_apis.v1, secret_name, test_namespace) | ||
|
||
request.addfinalizer(fin) | ||
|
||
return DisableIPV6Setup(ingress_controller_endpoint, ingress_name, ingress_host, ic_pod_name, test_namespace) | ||
|
||
|
||
@pytest.mark.ingresses | ||
class TestDisableIPV6: | ||
@pytest.mark.parametrize( | ||
"ingress_controller", | ||
[ | ||
pytest.param({"extra_args": ["-disable-ipv6"]}, id="one-additional-cli-args"), | ||
], | ||
indirect=True, | ||
) | ||
def test_ipv6_listeners_not_in_config( | ||
self, | ||
kube_apis, | ||
disable_ipv6_setup: DisableIPV6Setup, | ||
ingress_controller_prerequisites, | ||
): | ||
wait_before_test() | ||
nginx_config = get_nginx_template_conf(kube_apis.v1, ingress_controller_prerequisites.namespace) | ||
upstream_conf = get_ingress_nginx_template_conf( | ||
kube_apis.v1, | ||
disable_ipv6_setup.namespace, | ||
disable_ipv6_setup.ingress_name, | ||
disable_ipv6_setup.ingress_pod_name, | ||
ingress_controller_prerequisites.namespace, | ||
) | ||
assert "listen [::]:" not in nginx_config | ||
assert "listen [::]:" not in upstream_conf |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the
id="one-additional-cli-args"
option do? I haven't seen that beforeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just the test ID of the
parametrize
values in pytest. Since I only have one set of values, I have removed the id and let pytest generate it.