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
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
18a87fb
add ip listener input to virtual server (not working)
AlexFenlon Jul 17, 2024
acb8a3b
Initial tests for validating IP field in listeners
jjngx Jul 18, 2024
386600a
Refactor listener validator for IP
AlexFenlon Jul 23, 2024
c20235c
Remove accidental code and update CRDs
AlexFenlon Jul 23, 2024
181f676
Merge remote-tracking branch 'refs/remotes/origin/main' into poc/ip-l…
AlexFenlon Jul 23, 2024
d53fdfd
Add tests and fix port conflict
AlexFenlon Jul 24, 2024
9187223
Merge remote-tracking branch 'refs/remotes/origin/main' into poc/ip-l…
AlexFenlon Jul 24, 2024
d044ea4
Add back vs support (not passing into template helper)
AlexFenlon Jul 25, 2024
3f458c7
Fix vs implementation - fully working
AlexFenlon Jul 25, 2024
54988c8
Merge remote-tracking branch 'refs/remotes/origin/main' into poc/ip-l…
AlexFenlon Jul 25, 2024
e08d957
Fix ipv6 nginx break
AlexFenlon Jul 25, 2024
92c5444
Remove debug and fix crd
AlexFenlon Jul 25, 2024
1bfe8cb
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/ip-…
AlexFenlon Jul 29, 2024
7d2f46c
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/ip-…
AlexFenlon Jul 30, 2024
d03fd3e
Update warning message and tests
AlexFenlon Jul 30, 2024
a96025b
Change ip to ipv4 and ipv6 -- fully working
AlexFenlon Aug 2, 2024
b6098e2
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/ip-…
AlexFenlon Aug 2, 2024
369ad28
Refactor
AlexFenlon Aug 2, 2024
159612b
Update and Add new go and snap tests
AlexFenlon Aug 7, 2024
e362c5f
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/ip-…
AlexFenlon Aug 7, 2024
41bc404
Update examples - incomplete
AlexFenlon Aug 7, 2024
f0b1b9f
Update examples - incomplete
AlexFenlon Aug 7, 2024
e175a6a
Update examples readme
AlexFenlon Aug 7, 2024
b0e6c80
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/ip-…
AlexFenlon Aug 7, 2024
1a50ba6
Fix values.yaml globalconfig ipv4ip ipv6ip
AlexFenlon Aug 8, 2024
afebad6
pytests - unfinished
AlexFenlon Aug 13, 2024
c7e5a4d
Merge branch 'main' into feat/ip-listeners
AlexFenlon Aug 13, 2024
4c2abdc
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/ip-…
AlexFenlon Aug 13, 2024
3edd97d
Merge remote-tracking branch 'origin/feat/ip-listeners' into feat/ip-…
AlexFenlon Aug 13, 2024
429cd0b
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/ip-…
AlexFenlon Aug 13, 2024
7628851
fix crds
AlexFenlon Aug 13, 2024
180a7d6
update pytests - 1 working
AlexFenlon Aug 13, 2024
9d5b8b0
update pytests
AlexFenlon Aug 14, 2024
07735b2
fix crds
AlexFenlon Aug 14, 2024
60ed214
fix crds - last
AlexFenlon Aug 15, 2024
ab420ee
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/ip-…
AlexFenlon Aug 15, 2024
c8eabfd
update pytests, comment out and remove unused test cases yamls
AlexFenlon Aug 15, 2024
7c8262e
update pytests
AlexFenlon Aug 15, 2024
244ba3b
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/ip-…
AlexFenlon Aug 15, 2024
0b63dce
fix example
AlexFenlon Aug 16, 2024
5b200ab
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/ip-…
AlexFenlon Aug 16, 2024
b359f0d
fix example
AlexFenlon Aug 16, 2024
d7f03ec
restore old custom listener pytest
AlexFenlon Sep 3, 2024
fc5c956
add new ip listener pytest
AlexFenlon Sep 4, 2024
56cc854
Merge branch 'main' into feat/ip-listeners
AlexFenlon Sep 4, 2024
063335d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 4, 2024
037a7e6
remove transportserver and fix merge mistakes
AlexFenlon Sep 4, 2024
fc91b51
Update example and add doc
AlexFenlon Sep 5, 2024
7f7416e
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/ip-…
AlexFenlon Sep 5, 2024
4e81c84
Update crds and user facing listener names
AlexFenlon Sep 5, 2024
28e5f89
Update example
AlexFenlon Sep 5, 2024
5b514b6
Merge branch 'main' into feat/ip-listeners
AlexFenlon Sep 5, 2024
f7a6372
address comments
AlexFenlon Sep 5, 2024
cc471bc
remove unused file
AlexFenlon Sep 5, 2024
49d4dfc
Update pyproject.toml
AlexFenlon Sep 5, 2024
c04d236
rerun pipeline
AlexFenlon Sep 5, 2024
3ed7211
Merge remote-tracking branch 'origin/feat/ip-listeners' into feat/ip-…
AlexFenlon Sep 5, 2024
b3fec89
rerun pipeline
AlexFenlon Sep 5, 2024
a41b39e
rerun pipeline - fix
AlexFenlon Sep 5, 2024
d87db54
rerun pipeline
AlexFenlon Sep 5, 2024
9c3c571
rerun pipeline - fix
AlexFenlon Sep 5, 2024
ef79024
rerun pipeline
AlexFenlon Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ if .Values.controller.globalConfiguration.create }}
apiVersion: k8s.nginx.org/v1alpha1
apiVersion: k8s.nginx.org/v1
kind: GlobalConfiguration
metadata:
name: {{ include "nginx-ingress.controller.fullname" . }}
Expand Down
16 changes: 16 additions & 0 deletions charts/nginx-ingress/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,22 @@
"examples": [
"dns-tcp"
]
},
"ipv4ip": {
"type": "string",
"default": "",
"title": "The ipv4 ip",
"examples": [
"127.0.0.1"
]
},
"ipv6ip": {
"type": "string",
"default": "",
"title": "The ipv6 ip",
"examples": [
"::1"
]
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/k8s.nginx.org_globalconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ spec:
items:
description: Listener defines a listener.
properties:
ipv4ip:
type: string
ipv6ip:
type: string
name:
type: string
port:
Expand Down
4 changes: 4 additions & 0 deletions deploy/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ spec:
items:
description: Listener defines a listener.
properties:
ipv4ip:
type: string
ipv6ip:
type: string
name:
type: string
port:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: k8s.nginx.org/v1
kind: GlobalConfiguration
metadata:
name: nginx-configuration
namespace: nginx-ingress
spec:
listeners:
- name: dns-udp
port: 5353
protocol: UDP
- name: dns-tcp
port: 5353
protocol: TCP
AlexFenlon marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
# Custom IPv4 and IPv6 IP Listeners
j1m-ryan marked this conversation as resolved.
Show resolved Hide resolved

In this example, we will configure a VirtualServer resource with a custom IPv4 or IPv6 IP using HTTP/HTTPS listeners.
This will allow IPv4 and/or IPv6 IPs using HTTP and/or HTTPS based requests to be made on non-default ports using separate IPs.

## Prerequisites

1. Follow the [installation](https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/)
instructions to deploy the Ingress Controller with custom resources enabled.
2. Ensure the Ingress Controller is configured with the `-global-configuration` argument:

```console
args:
- -global-configuration=$(POD_NAMESPACE)/nginx-configuration
```

3. If you have a NodePort or Loadbalancer service deployed, ensure they are updated to include the custom listener ports.
Example YAML for a LoadBalancer:

```yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-ingress
namespace: nginx-ingress
spec:
type: LoadBalancer
ports:
- port: 8083
targetPort: 8083
protocol: TCP
name: ip-listener-1-http
- port: 8443
targetPort: 8443
protocol: TCP
name: ip-listener-2-https
selector:
app: nginx-ingress
```

## Step 1 - Deploy the GlobalConfiguration resource

Similar to how listeners are configured in our [custom-listeners](../../custom-listeners) examples,
here we deploy a GlobalConfiguration resource with the listeners we want to use in our VirtualServer.

```yaml
apiVersion: k8s.nginx.org/v1
kind: GlobalConfiguration
metadata:
name: nginx-configuration
namespace: nginx-ingress
spec:
listeners:
- name: ip-listener-1-http
port: 8083
protocol: HTTP
ipv4ip: 127.0.0.1
j1m-ryan marked this conversation as resolved.
Show resolved Hide resolved
- name: ip-listener-2-https
port: 8443
protocol: HTTP
ipv4ip: 127.0.0.2
ipv6ip: ::1
ssl: true
```

```console
kubectl create -f global-configuration.yaml
```

## Step 2 - Deploy the Cafe Application

Create the coffee and the tea deployments and services:

```console
kubectl create -f cafe.yaml
```

## Step 3 - Deploy the VirtualServer with custom listeners

The VirtualServer in this example is set to use the listeners defined in the GlobalConfiguration resource
that was deployed in Step 1. Below is the yaml of this example VirtualServer:

```yaml
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: cafe
spec:
listener:
http: ip-listener-1-http
https: ip-listener-2-https
host: cafe.example.com
tls:
secret: cafe-secret
upstreams:
- name: tea
service: tea-svc
port: 80
- name: coffee
service: coffee-svc
port: 80
routes:
- path: /tea
action:
pass: tea
- path: /coffee
action:
pass: coffee
```

1. Create the secret with the TLS certificate and key:

```console
kubectl create -f cafe-secret.yaml
```

2. Create the VirtualServer resource:

```console
kubectl create -f cafe-virtual-server.yaml
```

## Step 4 - Test the Configuration

1. Check that the configuration has been successfully applied by inspecting the events of the VirtualServer and the GlobalConfiguration:

```console
kubectl describe virtualserver cafe
```

Below you will see the events as well as the new `Listeners` field

```console
. . .
Spec:
Host: cafe.example.com
Listener:
Http: ip-listener-1-http
Https: ip-listener-2-https
. . .
Routes:
. . .
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal AddedOrUpdated 2s nginx-ingress-controller Configuration for default/cafe was added or updated
```

```console
kubectl describe globalconfiguration nginx-configuration -n nginx-ingress
```

```console
. . .
Spec:
Listeners:
ipv4ip: 127.0.0.1
Name: ip-listener-1-http
Port: 8083
Protocol: HTTP
ipv4ip: 127.0.0.2
ipv6ip: ::1
Name: ip-listener-2-https
Port: 8443
Protocol: HTTP
Ssl: true
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Updated 14s nginx-ingress-controller GlobalConfiguration nginx-ingress/nginx-configuration was added or updated
```

2. Since the deployed VirtualServer is using ports `8083` and `8443` in this example. you can see that the specific ips and ports
are set and listening by using the below commands:

Access the NGINX Pod:

```console
kubectl get pods -n nginx-ingress
```

```text
NAME READY STATUS RESTARTS AGE
nginx-ingress-65cd79bb8f-crst4 1/1 Running 0 97s
```

```console
kubectl debug -it nginx-ingress-65cd79bb8f-crst4 --image=busybox:1.28 --target=nginx-ingress
```

```console
/ # netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
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 0.0.0.0:443 0.0.0.0:* LISTEN -
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 :::8081 :::* LISTEN -
tcp 0 0 :::8080 :::* LISTEN -
tcp 0 0 :::8083 :::* LISTEN -
tcp 0 0 ::1:8443 :::* LISTEN -
tcp 0 0 :::443 :::* LISTEN -
tcp 0 0 :::80 :::* LISTEN -
tcp 0 0 :::9113 :::* LISTEN -
```

We can see here that the two IPv4s (`127.0.0.1:8083` and `127.0.0.2:8443`) and the one IPv6 (`::1:8443`) that are set and listening.

3. Examine the NGINX config using the following command:

```console
kubectl exec -it nginx-ingress-65cd79bb8f-crst4 -n nginx-ingress -- cat /etc/nginx/conf.d/vs_default_cafe.conf
```

```console
...
server {
listen 127.0.0.1:8083;
listen [::]: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;
...
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: cafe-secret
type: kubernetes.io/tls
data:
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURMakNDQWhZQ0NRREFPRjl0THNhWFdqQU5CZ2txaGtpRzl3MEJBUXNGQURCYU1Rc3dDUVlEVlFRR0V3SlYKVXpFTE1Ba0dBMVVFQ0F3Q1EwRXhJVEFmQmdOVkJBb01HRWx1ZEdWeWJtVjBJRmRwWkdkcGRITWdVSFI1SUV4MApaREViTUJrR0ExVUVBd3dTWTJGbVpTNWxlR0Z0Y0d4bExtTnZiU0FnTUI0WERURTRNRGt4TWpFMk1UVXpOVm9YCkRUSXpNRGt4TVRFMk1UVXpOVm93V0RFTE1Ba0dBMVVFQmhNQ1ZWTXhDekFKQmdOVkJBZ01Ba05CTVNFd0h3WUQKVlFRS0RCaEpiblJsY201bGRDQlhhV1JuYVhSeklGQjBlU0JNZEdReEdUQVhCZ05WQkFNTUVHTmhabVV1WlhoaApiWEJzWlM1amIyMHdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCRHdBd2dnRUtBb0lCQVFDcDZLbjdzeTgxCnAwanVKL2N5ayt2Q0FtbHNmanRGTTJtdVpOSzBLdGVjcUcyZmpXUWI1NXhRMVlGQTJYT1N3SEFZdlNkd0kyaloKcnVXOHFYWENMMnJiNENaQ0Z4d3BWRUNyY3hkam0zdGVWaVJYVnNZSW1tSkhQUFN5UWdwaW9iczl4N0RsTGM2SQpCQTBaalVPeWwwUHFHOVNKZXhNVjczV0lJYTVyRFZTRjJyNGtTa2JBajREY2o3TFhlRmxWWEgySTVYd1hDcHRDCm42N0pDZzQyZitrOHdnemNSVnA4WFprWldaVmp3cTlSVUtEWG1GQjJZeU4xWEVXZFow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VEU4RnZGQ3haWWRidUI4NENtWmlodnhicFJBb0dBSWJqcWFNWVBUWXVrbENkYTVTNzkKWVNGSjFKelplMUtqYS8vdER3MXpGY2dWQ0thMzFqQXdjaXowZi9sU1JxM0hTMUdHR21lemhQVlRpcUxmZVpxYwpSMGlLYmhnYk9jVlZrSkozSzB5QXlLd1BUdW14S0haNnpJbVpTMGMwYW0rUlk5WUdxNVQ3WXJ6cHpjZnZwaU9VCmZmZTNSeUZUN2NmQ21mb09oREN0enVrQ2dZQjMwb0xDMVJMRk9ycW40M3ZDUzUxemM1em9ZNDR1QnpzcHd3WU4KVHd2UC9FeFdNZjNWSnJEakJDSCtULzZzeXNlUGJKRUltbHpNK0l3eXRGcEFOZmlJWEV0LzQ4WGY2ME54OGdXTQp1SHl4Wlp4L05LdER3MFY4dlgxUE9ucTJBNWVpS2ErOGpSQVJZS0pMWU5kZkR1d29seHZHNmJaaGtQaS80RXRUCjNZMThzUUtCZ0h0S2JrKzdsTkpWZXN3WEU1Y1VHNkVEVXNEZS8yVWE3ZlhwN0ZjanFCRW9hcDFMU3crNlRYcDAKWmdybUtFOEFSek00NytFSkhVdmlpcS9udXBFMTVnMGtKVzNzeWhwVTl6WkxPN2x0QjBLSWtPOVpSY21Vam84UQpjcExsSE1BcWJMSjhXWUdKQ2toaVd4eWFsNmhZVHlXWTRjVmtDMHh0VGwvaFVFOUllTktvCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: cafe
spec:
listener:
http: ip-listener-1-http
https: ip-listener-2-https
host: cafe.example.com
tls:
secret: cafe-secret
upstreams:
- name: tea
service: tea-svc
port: 80
- name: coffee
service: coffee-svc
port: 80
routes:
- path: /tea
action:
pass: tea
- path: /coffee
action:
pass: coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: coffee
spec:
replicas: 2
selector:
matchLabels:
app: coffee
template:
metadata:
labels:
app: coffee
spec:
containers:
- name: coffee
image: nginxdemos/nginx-hello:plain-text
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: coffee-svc
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
name: ip
selector:
app: coffee
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tea
spec:
replicas: 1
selector:
matchLabels:
app: tea
template:
metadata:
labels:
app: tea
spec:
containers:
- name: tea
image: nginxdemos/nginx-hello:plain-text
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: tea-svc
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
name: http
selector:
app: tea
Loading