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 ip as an option to listeners for VirtualServer #6180

Merged
merged 62 commits into from
Sep 5, 2024
Merged

Conversation

AlexFenlon
Copy link
Contributor

@AlexFenlon AlexFenlon commented Aug 13, 2024

Proposed changes

This PR adds the ability for NIC to listen a custom ipv4 or ipv6 ip address using custom listeners with Virtual Server and global configuration.

Resolves: #6067

Below is the output when IPV4 and IPV6 are in both http and https custom listeners

Virtual Server:

kubectl get virtualservers
NAME   STATE   HOST               IP    PORTS   AGE
cafe   Valid   cafe.example.com                 19s
kubectl describe virtualserver
...
Spec:
  Host:  cafe.example.com
  Listener:
    Http:   ip-listener-1-http
    Https:  ip-listener-2-https
 ...
Events:
  Type     Reason                     Age                    From                      Message
  ----     ------                     ----                   ----                      -------
  Warning  AddedOrUpdatedWithWarning  3m29s (x3 over 3m29s)  nginx-ingress-controller  Configuration for default/cafe was added or updated with warning(s): Listeners defined, but no GlobalConfiguration is deployed
  Normal   AddedOrUpdated             3m29s                  nginx-ingress-controller  Configuration for default/cafe was added or updated

GlobalConfiguration:

kubectl get globalconfiguration
NAME                                  AGE
my-release-nginx-ingress-controller   63s
kubectl describe globalconfiguration
...
Spec:
  Listeners:
    ipv4:      127.0.0.1
    ipv6:      ::1
    Name:      ip-listener-1-http
    Port:      8083
    Protocol:  HTTP
    ipv4:      127.0.0.2
    ipv6:      ::1
    Name:      ip-listener-2-https
    Port:      8443
    Protocol:  HTTP
    Ssl:       true
Events:
  Type    Reason   Age   From                      Message
  ----    ------   ----  ----                      -------
  Normal  Updated  5m2s  nginx-ingress-controller  GlobalConfiguration default/my-release-nginx-ingress-controller was added or updated

nginx.conf snippet:

server {
    listen 127.0.0.1:8083;
    listen [::1]:8083;


    server_name cafe.example.com;

    set $resource_type "virtualserver";
    set $resource_name "cafe";
    set $resource_namespace "default";
    listen 127.0.0.2:8443 ssl;
    listen [::1]:8443 ssl;

I set up a debug container using the below command to check if the pod is listening on the set ports and ips:

kubectl debug -it $POD_NAME --image=busybox:1.28 --target=nginx-ingress
Targeting container "nginx-ingress". If you don't see processes from this container it may be because the container runtime doesn't support this feature.
Defaulting debug container name to debugger-cjnmc.
If you don't see a command prompt, try pressing enter.
/ # netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name 
tcp        0      0 127.0.0.2:8443          0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:8083          0.0.0.0:*               LISTEN      -
tcp        0      0 :::9113                 :::*                    LISTEN      -
tcp        0      0 ::1:8443                :::*                    LISTEN      -
tcp        0      0 :::80                   :::*                    LISTEN      -
tcp        0      0 :::443                  :::*                    LISTEN      -
tcp        0      0 :::8080                 :::*                    LISTEN      -
tcp        0      0 :::8081                 :::*                    LISTEN      -
tcp        0      0 ::1:8083                :::*                    LISTEN      -

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

AlexFenlon and others added 26 commits July 17, 2024 16:07
@github-actions github-actions bot added enhancement Pull requests for new features/feature enhancements documentation Pull requests/issues for documentation go Pull requests that update Go code python Pull requests that update Python code labels Aug 13, 2024
Copy link

github-actions bot commented Sep 5, 2024

Deploy Preview will be available once build job completes!

Name Link
😎 Deploy Preview https://frontdoor-test-docs.nginx.com/previews/nginx-ingress-controller/6180/

@AlexFenlon AlexFenlon changed the title [DRAFT] Add ip as an option to listeners for VirtualServer Add ip as an option to listeners for VirtualServer Sep 5, 2024
@AlexFenlon AlexFenlon marked this pull request as ready for review September 5, 2024 12:50
@AlexFenlon AlexFenlon requested review from a team as code owners September 5, 2024 12:50
pyproject.toml Outdated Show resolved Hide resolved
Signed-off-by: Alex Fenlon <[email protected]>
@github-actions github-actions bot removed the chore Pull requests for routine tasks label Sep 5, 2024
@AlexFenlon AlexFenlon enabled auto-merge (squash) September 5, 2024 15:26
@AlexFenlon AlexFenlon merged commit c1e2906 into main Sep 5, 2024
81 checks passed
@AlexFenlon AlexFenlon deleted the feat/ip-listeners branch September 5, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Pull requests/issues for documentation enhancement Pull requests for new features/feature enhancements go Pull requests that update Go code helm_chart Pull requests that update the Helm Chart python Pull requests that update Python code tests Pull requests that update tests
Projects
Status: Done 🚀
Development

Successfully merging this pull request may close these issues.

Add ip as an option to listeners
4 participants