Skip to content

Commit 2452754

Browse files
committed
add single cluster config
1 parent 2e9256f commit 2452754

File tree

2 files changed

+130
-2
lines changed

2 files changed

+130
-2
lines changed

docs/http/http-installation-guide.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,22 @@ This can be any standard Linux OS system, based on the Linux Distro and Technica
207207

208208
>NOTE: This Solution will only work with NGINX Plus, as NGINX OpenSource does not have the API that is used in this Solution. Installation on unsupported Linux Distros is not recommended.
209209

210+
1. If you need a license for NGINX Plus, a 30-day Trial license is available here:
211+
212+
https://www.nginx.com/free-trial-request/
213+
210214
1. Install the NGINX Javascript module (njs). This is required for exporting Prometheus Metrics from NGINX Plus.
211215

212216
```bash
213217
yum install nginx-plus-module-njs
218+
214219
```
215220

216-
1. If you need a license for NGINX Plus, a 30-day Trial license is available here:
221+
1. Install Nginx Javascript for Prometheus
222+
```bash
223+
yum install nginx-plus-module-prometheus
217224
218-
https://www.nginx.com/free-trial-request/
225+
```
219226

220227
<br/>
221228

docs/http/split-test.conf

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# NGINX Loadbalancer for K8s HTTP configuration, for L7 load balancing
2+
# Chris Akker, Apr 2023
3+
# HTTP Proxy and load balancing
4+
# MultiCluster Load Balancing with http split clients 0-100%
5+
# Upstream servers managed by NLK Controller
6+
# Nginx Key Value store for Split ratios
7+
#
8+
#### clusters.conf
9+
10+
# Define Key Value store, backup state file, timeout, and enable sync
11+
12+
keyval_zone zone=split:1m state=/var/lib/nginx/state/split.keyval timeout=30d sync;
13+
keyval $host $split_level zone=split;
14+
15+
# Main Nginx Server Block for cafe.example.com, with TLS
16+
17+
server {
18+
listen 443 ssl;
19+
status_zone https://cafe.example.com;
20+
server_name cafe.example.com;
21+
22+
ssl_certificate /etc/ssl/nginx/default.crt; # self-signed for example only
23+
ssl_certificate_key /etc/ssl/nginx/default.key;
24+
25+
location / {
26+
status_zone /;
27+
28+
proxy_set_header Host $host;
29+
proxy_http_version 1.1;
30+
proxy_set_header "Connection" "";
31+
proxy_pass https://$upstream;
32+
33+
}
34+
35+
location @health_check_cluster1_cafe {
36+
37+
health_check interval=10 match=cafe;
38+
proxy_connect_timeout 2s;
39+
proxy_read_timeout 3s;
40+
proxy_set_header Host cafe.example.com;
41+
proxy_pass https://cluster1-https;
42+
}
43+
44+
location @health_check_cluster2_cafe {
45+
46+
health_check interval=10 match=cafe;
47+
proxy_connect_timeout 2s;
48+
proxy_read_timeout 3s;
49+
proxy_set_header Host cafe.example.com;
50+
proxy_pass https://cluster2-https;
51+
}
52+
}
53+
54+
match cafe {
55+
status 200-399;
56+
}
57+
58+
# Cluster1 upstreams
59+
60+
upstream cluster1-https {
61+
zone cluster1-https 256k;
62+
least_time last_byte;
63+
keepalive 16;
64+
#servers managed by NLK Controller
65+
state /var/lib/nginx/state/cluster1-https.state;
66+
}
67+
68+
# Cluster2 upstreams
69+
70+
upstream cluster2-https {
71+
zone cluster2-https 256k;
72+
least_time last_byte;
73+
#servers managed by NLK Controller
74+
state /var/lib/nginx/state/cluster2-https.state;
75+
}
76+
77+
# HTTP Split Clients Configuration for Cluster1/Cluster2 ratios
78+
79+
split_clients $request_id $split0 {
80+
* cluster2-https;
81+
}
82+
83+
split_clients $request_id $split1 {
84+
1.0% cluster1-https;
85+
* cluster2-https;
86+
}
87+
88+
split_clients $request_id $split1000 {
89+
0.1% cluster1-https;
90+
* cluster2-https;
91+
}
92+
93+
split_clients $request_id $split10000 {
94+
0.01% cluster1-https;
95+
* cluster2-https;
96+
}
97+
98+
split_clients $request_id $split100000 {
99+
0.001% cluster1-https;
100+
* cluster2-https;
101+
}
102+
103+
split_clients $request_id $split1000000 {
104+
0.0001% cluster1-https;
105+
* cluster2-https;
106+
}
107+
108+
split_clients $request_id $split100 {
109+
* cluster1-https;
110+
}
111+
112+
map $split_level $upstream {
113+
0 $split0;
114+
1.0 $split1;
115+
0.1 $split1000;
116+
0.01 $split10000;
117+
0.001 $split100000;
118+
0.0001 $split1000000;
119+
100 $split100;
120+
default $split50;
121+
}

0 commit comments

Comments
 (0)