speedscale / pixie-to-curl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pixie-to-curl

A simple go tool that exports HTTP traffic from Pixie and converts into re-usable curl scripts. In other words, it uses the power of eBPF to record real traffic that you can run as tests. Check out Omid Azizi and Matthew LeRay's KubeCon EU talk for more (link to be posted after KubeCon).

Note that if the real request returns a 200 then a --fail will be added so that curl returns an error if the test request does not do the same.

Before you begin

  1. Install pixie into your Kubernetes cluster
  2. Retrieve your cluster ID
  3. Generate an api token and save it
  4. Deploy your service and view it in the Pixie UI
  5. Optional: Tune the time range you want in export/pixie.go
  6. Now you can run the script

Usage

Usage:
	pixie-to-curl api_token cluster_id destination_filter base_url

api_token - your unique API key generated in the Pixie UI or CLI
cluster_id - UID of the cluster you want to record from
destination_filter - name of the pod receiving traffic (usually the service you want to test)
base_url - prefix for each HTTP curl command (it isn't usually the same between environments)

Example

pixie-to-curl px-api-<UID> 123456-1234-1234-1234-12312331 default/podtato-head-entry http://192.168.64.4:31000

curl -X 'GET' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9' -H 'Cache-Control: max-age=0' -H 'Connection: keep-alive' -H 'Host: 192.168.64.4:31000' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36' 'http://192.168.64.4:31000/' --fail
curl -X 'GET' -H 'Accept: text/css,*/*;q=0.1' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9' -H 'Connection: keep-alive' -H 'Host: 192.168.64.4:31000' -H 'Referer: http://192.168.64.4:31000/' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36' 'http://192.168.64.4:31000/assets/css/styles.css' --fail
curl -X 'GET' -H 'Accept: text/css,*/*;q=0.1' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9' -H 'Connection: keep-alive' -H 'Host: 192.168.64.4:31000' -H 'Referer: http://192.168.64.4:31000/' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36' 'http://192.168.64.4:31000/assets/css/custom.css' --fail
curl -X 'GET' -H 'Accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9' -H 'Connection: keep-alive' -H 'Host: 192.168.64.4:31000' -H 'Referer: http://192.168.64.4:31000/' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36' 'http://192.168.64.4:31000/assets/images/body/body.svg' --fail
curl -X 'GET' -H 'Accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9' -H 'Connection: keep-alive' -H 'Host: 192.168.64.4:31000' -H 'Referer: http://192.168.64.4:31000/' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36' 'http://192.168.64.4:31000/parts/left-arm/left-arm.svg' --fail

...

About

License:Apache License 2.0


Languages

Language:Go 100.0%