Kubernetes

Table of contents

  1. Deploy
    1. Definition
    2. Run
  2. Ingress Controller
  3. Examples

Deploy

Definition

curl -sL https://raw.githubusercontent.com/Ealenn/Echo-Server/master/docs/examples/echo.kube.yaml > echo.kube.yaml

or customize directly this definition

This kube definition:

  • Creates namespace
  • Creates deployment with 5 replicas
  • Creates Ingress with kubernetes.io/ingress.class: nginx annotation

Run

kubectl apply -f ./echo.kube.yaml

Ingress Controller

You can use an Nginx Ingress Controller More information

Examples

Custom responses

Query Header Content Conditions
?echo_code= X-ECHO-CODE HTTP code 200, 404 200 <= CODE <= 599
    404-401 or 200-500-301  
?echo_body= X-ECHO-BODY Body message  
?echo_env_body= X-ECHO-ENV-BODY The key of environment variable Enable environment true
?echo_header= X-ECHO-HEADER Response Header Lang: en-US Enable header true
?echo_time= X-ECHO-TIME Wait time in ms 0 <= TIME <= 60.000
?echo_file= X-ECHO-FILE Path of Directory or File Enable file true

You can change commands and conditions.

Custom HTTP Status Code

➜ curl -I --header 'X-ECHO-CODE: 404' echo.cluster.local
➜ curl -I echo.cluster.local/?echo_code=404

HTTP/1.1 404 Not Found
➜ curl -I --header 'X-ECHO-CODE: 404-300' echo.cluster.local
➜ curl -I echo.cluster.local/?echo_code=404-300

HTTP/1.1 404 Not Found
HTTP/1.1 300 Multiple Choices
for i in {1..10}do
➜    curl -I echo.cluster.local/?echo_code=200-400-500
➜ done

HTTP/1.1 500 Internal Server Error
HTTP/1.1 400 Bad Request
HTTP/1.1 200 OK
HTTP/1.1 500 Internal Server Error
HTTP/1.1 200 OK
HTTP/1.1 500 Internal Server Error

Custom Body

➜ curl --header 'X-ECHO-BODY: amazing' echo.cluster.local
➜ curl echo.cluster.local/?echo_body=amazing

"amazing"

Custom Body with environment variable value

➜ curl --header 'X-ECHO-ENV-BODY: HOSTNAME' echo.cluster.local
➜ curl echo.cluster.local/?echo_env_body=HOSTNAME

"c53a9ed79fa2"
for i in {1..10}do
➜    curl echo.cluster.local/?echo_env_body=HOSTNAME
➜ done

"c53a9ed79fa2"
"f10c3af61e40"
"c53a9ed79fa2"
"f10c3af61e40"
"c53a9ed79fa2"

Custom Headers

➜ curl --header 'X-ECHO-HEADER: One:1' echo.cluster.local
➜ curl echo.cluster.local/?echo_header=One:1

HTTP/1.1 200 OK
One: 1
➜ curl --header 'X-ECHO-HEADER: One:1, Two:2' echo.cluster.local
➜ curl "echo.cluster.local/?echo_header=One:1,%20Two:2"

HTTP/1.1 200 OK
One: 1
Two: 2

Custom response latency

➜ curl --header 'X-ECHO-TIME: 5000' echo.cluster.local
➜ curl "echo.cluster.local/?echo_time=5000"

⏳... 5000 ms

You can change default validations with

ENVIRONMENT CLI Default
CONTROLS__TIMES__MIN –controls:times:min 0
CONTROLS__TIMES__MAX –controls:times:max 60000

(Latency is defined in milliseconds)

File/Folder explorer

➜ curl --header 'X-ECHO-FILE: /' echo.cluster.local
➜ curl "echo.cluster.local/?echo_file=/"

["app", "bin", "etc", "usr", "var"]

Combine custom actions

➜ curl --header 'X-ECHO-CODE: 401' --header 'X-ECHO-BODY: Oups' echo.cluster.local
➜ curl "echo.cluster.local/?echo_body=Oups&echo_code=401"

HTTP/1.1 401 Unauthorized
"Oups"