Skip to content

Commit

Permalink
add single cluster config
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisakker committed Jun 28, 2024
1 parent 2e9256f commit 2452754
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 2 deletions.
11 changes: 9 additions & 2 deletions docs/http/http-installation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,22 @@ This can be any standard Linux OS system, based on the Linux Distro and Technica

>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.

1. If you need a license for NGINX Plus, a 30-day Trial license is available here:

https://www.nginx.com/free-trial-request/

1. Install the NGINX Javascript module (njs). This is required for exporting Prometheus Metrics from NGINX Plus.

```bash
yum install nginx-plus-module-njs
```

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

<br/>

Expand Down
121 changes: 121 additions & 0 deletions docs/http/split-test.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# NGINX Loadbalancer for K8s HTTP configuration, for L7 load balancing
# Chris Akker, Apr 2023
# HTTP Proxy and load balancing
# MultiCluster Load Balancing with http split clients 0-100%
# Upstream servers managed by NLK Controller
# Nginx Key Value store for Split ratios
#
#### clusters.conf

# Define Key Value store, backup state file, timeout, and enable sync

keyval_zone zone=split:1m state=/var/lib/nginx/state/split.keyval timeout=30d sync;
keyval $host $split_level zone=split;

# Main Nginx Server Block for cafe.example.com, with TLS

server {
listen 443 ssl;
status_zone https://cafe.example.com;
server_name cafe.example.com;

ssl_certificate /etc/ssl/nginx/default.crt; # self-signed for example only
ssl_certificate_key /etc/ssl/nginx/default.key;

location / {
status_zone /;

proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header "Connection" "";
proxy_pass https://$upstream;

}

location @health_check_cluster1_cafe {

health_check interval=10 match=cafe;
proxy_connect_timeout 2s;
proxy_read_timeout 3s;
proxy_set_header Host cafe.example.com;
proxy_pass https://cluster1-https;
}

location @health_check_cluster2_cafe {

health_check interval=10 match=cafe;
proxy_connect_timeout 2s;
proxy_read_timeout 3s;
proxy_set_header Host cafe.example.com;
proxy_pass https://cluster2-https;
}
}

match cafe {
status 200-399;
}

# Cluster1 upstreams

upstream cluster1-https {
zone cluster1-https 256k;
least_time last_byte;
keepalive 16;
#servers managed by NLK Controller
state /var/lib/nginx/state/cluster1-https.state;
}

# Cluster2 upstreams

upstream cluster2-https {
zone cluster2-https 256k;
least_time last_byte;
#servers managed by NLK Controller
state /var/lib/nginx/state/cluster2-https.state;
}

# HTTP Split Clients Configuration for Cluster1/Cluster2 ratios

split_clients $request_id $split0 {
* cluster2-https;
}

split_clients $request_id $split1 {
1.0% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split1000 {
0.1% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split10000 {
0.01% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split100000 {
0.001% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split1000000 {
0.0001% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split100 {
* cluster1-https;
}

map $split_level $upstream {
0 $split0;
1.0 $split1;
0.1 $split1000;
0.01 $split10000;
0.001 $split100000;
0.0001 $split1000000;
100 $split100;
default $split50;
}

0 comments on commit 2452754

Please sign in to comment.