This project was inspired by the Netflix's article Migrating Critical Traffic At Scale with No Downtime.
Kube Replay watches Kubernetes logs to fetch the GET HTTP requests made at the specified container in realtime and replays it at a given HTTP target.
Notes:
-
The log pattern should be specified so the match uses named captures
PATH
,VERB
andCODE
so the Log Watcher matches the log line correcly. Ex:- The Common Log Format regex (default)
/(\S+)\s+(\S+)\s+(\S+)\s+(\[.*?\])\s+"(?<VERB>\S+)\s+(?<PATH>\S+)\s+(\S+)"\s+(?<CODE>\S+)\s+(?<SIZE>\S+)/
- Matching log line
10.0.0.1 user-identifier user [20/Jul/2023:14:08:36 +0000] "GET /my-path HTTP/1.0" 200 123456
-
Kube Replay will use the current Kubernetes context (TODO: allow user to pass custom context)
- Verify Kubernetes Cluster connection
- Add timeout to requests
- Optionally write output to file
- Allow to show only the failed requests at the STDOUT
- Standardize regexp pattern to have match named groups
- Show memory usage and requests heap size
- STDIN commands to exit program instead of using Keyboard Interrupt (ctrl + shift + c)
gem install kube-replay
- Returns help
kube-replay --help
- Runs Kube Replay command using config file
kube-replay --config_file/-f demo_conf.yaml
- Runs Kube Replay command specifying the configuration
kube-replay --namespace live --pod live-packager-even-zfhgw --container unified-origin --log_regex_pattern /(\S+)\s+(\S+)\s+(\S+)\s+(\[.*?\])\s+"(\S+)\s+(\S+)\s+(\S+)"\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ --target_url http://live-packager-1.video.dev.globoi.com
alternatively,
kube-replay -n live -p live-packager-even-zfhgw -c unified-origin -r /(\S+)\s+(\S+)\s+(\S+)\s+(\[.*?\])\s+"(\S+)\s+(\S+)\s+(\S+)"\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ -t http://live-packager-1.video.dev.globoi.com
rbenv install 3.1.3
bundle install