From 245275426afbf9172206c6cde314432efc5a5bc8 Mon Sep 17 00:00:00 2001 From: chrisakker Date: Thu, 27 Jun 2024 17:31:39 -0700 Subject: [PATCH] add single cluster config --- docs/http/http-installation-guide.md | 11 ++- docs/http/split-test.conf | 121 +++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 docs/http/split-test.conf diff --git a/docs/http/http-installation-guide.md b/docs/http/http-installation-guide.md index 8484bfd..a6eae8a 100644 --- a/docs/http/http-installation-guide.md +++ b/docs/http/http-installation-guide.md @@ -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/ + ```
diff --git a/docs/http/split-test.conf b/docs/http/split-test.conf new file mode 100644 index 0000000..09a3dc4 --- /dev/null +++ b/docs/http/split-test.conf @@ -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; + } \ No newline at end of file