Skip to content

Akker #41

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

Merged
merged 5 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
http upgrade
  • Loading branch information
chrisakker committed Apr 6, 2023
commit 1da0d3e11fff0e94d5d1086de972530ced137409
129 changes: 129 additions & 0 deletions docs/http/clusters.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# NginxK8sLB HTTP configuration, for L7 load balancing
# Chris Akker, Apr 2023
# HTTP Proxy and load balancing
# 2 k8s Clusters LB with http split clients
# Nginx Kubernetes Loadbalancer
# Upstream servers managed by NKL 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;
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;

}

}

# Cluster1 upstreams

upstream cluster1-https {
zone cluster1-https 256k;
least_time last_byte;
server 10.1.1.10:31317;
server 10.1.1.8:31317;
keepalive 16;
#servers managed by NKL
#state /var/lib/nginx/state/cluster1-https.state;
}

# Cluster2 upstreams

upstream cluster2-https {
zone cluster2-https 256k;
least_time last_byte;
server 10.1.1.11:31390;
server 10.1.1.12:31390;
#servers managed by NKL
#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 $split5 {
5.0% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split10 {
10% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split25 {
25% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split50 {
50% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split75 {
75% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split90 {
90% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split95 {
95% cluster1-https;
* cluster2-https;
}

split_clients $request_id $split99 {
99% cluster1-https;
* cluster2-https;
}

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

map $split_level $upstream {
0 $split0;
1.0 $split1;
5.0 $split5;
10 $split10;
25 $split25;
50 $split50;
75 $split75;
90 $split90;
95 $split95;
99 $split99;
100 $split100;
default $split50;
}
47 changes: 47 additions & 0 deletions docs/http/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;

load_module modules/ngx_http_js_module.so;

worker_rlimit_nofile 2048;

events {
worker_connections 2048;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $upstream_addr - $upstream_status - $remote_user [$time_local] $host - "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;

#added for Prometheus
subrequest_output_buffer_size 32k;

}


# TCP load balancing block
#
stream {
include /etc/nginx/stream/*.conf;
log_format stream '$remote_addr - $server_addr [$time_local] $status $upstream_addr $upstream_bytes_sent';
access_log /var/log/nginx/stream.log stream;
}
18 changes: 18 additions & 0 deletions docs/http/prometheus.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# NginxK8sLB Prometheus configuration, for HTTP scraper page
# Chris Akker, Apr 2023
# https://www.nginx.com/blog/how-to-visualize-nginx-plus-with-prometheus-and-grafana/
#
#### prometheus.conf

js_import /usr/share/nginx-plus-module-prometheus/prometheus.js;

server {
location = /metrics {
js_content prometheus.metrics;
}

location /api {
api;
}

}
14 changes: 14 additions & 0 deletions docs/http/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
global:
scrape_interval: 15s

external_labels:
monitor: 'codelab-monitor'

scrape_configs:
- job_name: 'prometheus'

scrape_interval: 5s

static_configs:
- targets: ['10.1.1.4:80', '10.1.1.5:80']

19 changes: 19 additions & 0 deletions docs/http/zonesync.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# NginxK8sLB Zone Sync configuration, for KVstore split
# Chris Akker, Apr 2023
# Stream Zone Sync block
# 2 Nginx Plus nodes KVstore zone
# Nginx Kubernetes Loadbalancer
# https://docs.nginx.com/nginx/admin-guide/high-availability/zone_sync/
#
#### zonesync.conf

server {
zone_sync;

listen 9001;

# cluster of 2 nodes
zone_sync_server 10.1.1.4:9001;
zone_sync_server 10.1.1.5:9001;

}
Binary file modified docs/media/cafe-dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/media/nkl-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/nkl-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.