You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+55-3Lines changed: 55 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,73 @@
2
2
3
3
# nginx-k8s-edge-controller
4
4
5
+
## Welcome to the Nginx Kubernetes Load Balancer project !
6
+
7
+
<br/>
8
+
9
+
This repo contains source code and documents for a new Kubernetes Controller, that provides TCP load balancing external to a k8s cluster. It is a replacement for a Cloud Providers "Service Type Loadbalancer", that is missing from On Premises Kubernetes Clusters.
10
+
11
+
<br/>
12
+
13
+
## Overview
14
+
15
+
- Create a new K8s Controller, that will monitor specified k8s Service Endpoints, and then send API calls to an external NginxPlus server to manage Nginx Upstream server blocks.
16
+
- This is will synchronize the K8s Service Endpoint list, with the Nginx LB server's Upstream block server list.
17
+
- The primary use case is for tracking the NodePort IP:Port definitions for the Nginx Ingress Controller's `nginx-ingress Service`.
18
+
- With the NginxPlus Server located external to the K8s cluster, this new controller LB function would provide an alternative TCP "Load Balancer Service" for On Premises k8s clusters, which do not have access to a Cloud providers "Service Type LoadBalancer".
19
+
- Make the solution a native Kubernetes Component, configured and managed with standard K8s tools.
20
+
21
+
<br/>
22
+
23
+
## Reference Diagram
24
+
25
+
<br/>
26
+
27
+

28
+
29
+
<br/>
30
+
31
+
## Sample Screenshots of Runtime
32
+
33
+
### Configuration with 2 Nginx LB Servers defined (HA):
Copy file name to clipboardExpand all lines: docs/NginxKubernetesLoadbalancer.md
+28-18Lines changed: 28 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@
15
15
- This is will synchronize the K8s Service Endpoint list, with the Nginx LB server's Upstream block server list.
16
16
- The primary use case is for tracking the NodePort IP:Port definitions for the Nginx Ingress Controller's `nginx-ingress Service`.
17
17
- With the NginxPlus Server located external to the K8s cluster, this new controller LB function would provide an alternative TCP "Load Balancer Service" for On Premises k8s clusters, which do not have access to a Cloud providers "Service Type LoadBalancer".
18
+
- Make the solution a native Kubernetes Component, configured and managed with standard K8s tools.
18
19
19
20
<br/>
20
21
@@ -34,7 +35,7 @@ This is often called "NLB", a term used in AWS for Network Load Balancer, but fu
34
35
35
36
>**This Solution uses NGINX to provide an alternative to #3, the TCP loadbalancing from PublicIP to k8s NodePort.**
36
37
37
-
Note: This solution is not for Cloud-based K8s clusters, only On Premises K8s clusters.
38
+
Note: This solution is not for Cloud-based K8s clusters, it is only for On Premises K8s clusters.
38
39
39
40
<br/>
40
41
@@ -62,8 +63,12 @@ Alternatives:
62
63
63
64
However, most of these alternatives are proprietary, open source / unsupported, competitive, or have other customer concerns.
64
65
66
+
<br/>
67
+
65
68
>**`NGINX PLUS is a viable alternative for most customers.`**
66
69
70
+
<br/>
71
+
67
72
Why not Nginx OpenSource? Nginx Open Source does not have the API endpoint and service for managing Upstream Server block configurations.
68
73
69
74
<br/>
@@ -81,6 +86,7 @@ Why not Nginx OpenSource? Nginx Open Source does not have the API endpoint and
81
86
- Plus API - the standard Nginx Plus API service that is running on the Nginx LB Server
82
87
- Nginx Plus Go Client - software that communicates with the Nginx LB Server
83
88
- Upstream - the IP:Port list of servers that Nginx will Load Balance traffic to at Layer 4 TCP using the stream configuration
89
+
- Fan-out support - the ability to run 2 or more Nginx LB servers external to the cluster for High Availability
84
90
85
91
<br/>
86
92
@@ -89,50 +95,54 @@ Why not Nginx OpenSource? Nginx Open Source does not have the API endpoint and
89
95
<br/>
90
96
91
97
Preface - Define access parameters for NKL Controller to communicate with NginxPlus instance:
92
-
- IP address:portor FQDN of the target Nginx LB Server
98
+
- IP address:port of the target Nginx LB Server(s)
93
99
- Optional auth: SSL certificate/key
94
100
- Optional auth: IP allow list
95
101
- Optional auth: HTTP Auth userid/password
96
102
- Optional auth: JWT Token
97
103
98
104
1. Initialization:
105
+
99
106
- Define the name of the target Upstream Server Block
100
107
- "nginx-lb-http" or "nginx-lb-https" should be the default server block names, returns error if these do not exist
101
108
- Using the Nginx Plus Go Client library, make an API query to NginxPlus LB server for current Upstream list
102
109
- API query to K8s apiserver for list of Ingress Controller Endpoints
103
110
- Reconcile the two lists, making changes to Nginx Upstreams to match the Ingress Endpoints ( add / delete Upstreams as needed to converge the two lists )
104
111
105
-
2. Runtime:
106
-
- Periodic check - API query for the list of Servers in the Upstream block, using the NginxPlus API ( query interval TBD )
107
-
- IP:port definition
108
-
- other possible metadata: status, connections, response_time, etc
109
-
- Keep a copy of this list in memory, if state is required
112
+
2. Configuration Requirements:
113
+
114
+
- List of Nginx LB server IP:Ports, comma separated
115
+
- List of K8s worker nodes
116
+
- List of Nginx LB server upstream block names, current defaults are "nginx-lb-http" and "nginx-lb-https" - `nginxlb.conf` for examples
117
+
- Nodeport Definition file, port names MUST match the upstream block names in the correct format, prefixed with `nkl-`, as in `nkl-nginx-lb-http` and `nkl-nginx-lb-https`
118
+
119
+
3. Runtime:
110
120
111
-
3. Register the LB Controller with the K8s watcher Service, subscribe to Notifications for changes to the nginx-ingress Service Endpoints.
121
+
- Register the LB Controller with the K8s watcher Service, subscribe to Notifications for changes to the nginx-ingress Service Endpoints.
112
122
- Using the Nginx Plus Go Client libraries, modify Upstream server entries, based on K8s NodePort Service endpoint "Notification" changes
113
123
- Add new Endpoint to Upstream Server list on k8s Notify
114
-
- Remove deleted Endpoints to Upstream list, using the Nginx Plus "Drain" function, leaving existing TCP connections to close gracefully on K8s Notify delete.
115
-
- Create and Set Drain_wait timer on Draining Upstream servers
116
-
- Remove Draining Upstream servers after Drain_wait timer expires
117
-
- Log changes to debug, nginx error.log, or custom access.log as appropriate
124
+
- Remove deleted Endpoints to Upstream list on k8s Notify
125
+
- Log changes to debug, nginx error.log, custom access.log and controller log as appropriate
118
126
119
-
4. Query the K8s api server, for the list of Endpoints for the "nginx-ingress" Service object. This is the list of NodePorts where the Nginx Ingress Controller is listening.
120
-
- Keep a copy of this list in memory, if state is desired
127
+
4. Main program
121
128
122
-
5. Main program
123
129
- Compare the list of Upstream servers from the Nginx API call, with the list nginx-ingress Service Endpoints from the K8s API call
124
130
- Calculate the difference in the list, and create new Nginx API calls to update the Upstream list, adding or removing the changes needed to mirror the nginx-ingress Service Endpoints list
131
+
- Periodic check - API query for the list of Servers in the Upstream block, using the NginxPlus API ( query interval TBD )
132
+
- IP:port definition
133
+
- other possible metadata collection: status, connections, response_time, etc
134
+
- Register the LB Controller for liveness probes, so K8s has and endpoint to query for up/down status.
125
135
- Log these changes
126
136
127
-
6. Optional: Make Nginx API calls to update the entire Upstream list, regardless of what the existing list contains. *Nginx will allow for the addition of duplicate server to the upstream block using the API, so at some point a process to "clean up and verify" the upstream list should be considered. It is possible that the Nginx-Plus-Go_Client already does this function.*
## PM/PD Suggestion - to build this new Controller, use the existing Nginx Ingress Controller framework/code, to create this new k8s LB Controller, leveraging the Enterprise class, supportable code Nginx already has on hand. Or perhaps, add this Loadbalancer solution as a new Feature to the exising Ingress Controller ( NIC, after all, is already watching the nginx-ingress namespace and services ).
141
+
## PM/PD Suggestion - to build this new Controller, use the existing Nginx Ingress Controller framework/code, to create this new k8s LB Controller, leveraging the Enterprise class, supportable code Nginx already has on hand. Or perhaps, add this Loadbalancer solution as a new Feature to the exising Ingress Controller ( NIC, after all, it is already watching the nginx-ingress namespace and services ).
132
142
133
143
<br/>
134
144
135
-
## Example Nginx Plus API requests for Upstream block changes
145
+
###Example Nginx Plus API requests for Upstream block changes
0 commit comments