Echo is a web service that simply echoes your request information(host, url, image version etc.)
59
Echo listens on :9090 and echoes the request information, including request host, url, headers, hostname(or k8s pod name) etc.
$ curl -s -H 'Host: echo.example.com' http://192.168.197.179:9090 | jq
{
"headers": {
"Accept": [
"*/*"
],
"User-Agent": [
"curl/7.29.0"
]
},
"host": "echo.example.com",
"hostname": "echo-demo-v1-69dd54bf44-t7gm9",
"realIP": "192.168.145.0",
"scheme": "http",
"url": "/",
"version": "1.0.0"
}
Echo also reads an environment variable named VERSION, which can be used to deploy different versions of k8s Deployment:
$ cat echo-deploy-v2.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: echo-demo-v2
spec:
replicas: 2
selector:
matchLabels:
run: echo-demo-v2
template:
metadata:
labels:
run: echo-demo-v2
spec:
containers:
- image: kidlj/echo:1.0.0
imagePullPolicy: IfNotPresent
name: echo-demo-v2
ports:
- containerPort: 9090
protocol: TCP
env:
- name: VERSION
value: 2.0.0
restartPolicy: Always
Then it will echoes version 2.0.0:
$ curl -s -H 'Host: echo.example.com' http://192.168.197.181:9090 | jq
{
"headers": {
"Accept": [
"*/*"
],
"User-Agent": [
"curl/7.29.0"
]
},
"host": "echo.example.com",
"hostname": "echo-demo-v1-69dd54bf44-n2v6x",
"realIP": "192.168.145.0",
"scheme": "http",
"url": "/",
"version": "2.0.0"
}
Echo also treat 3 request paths differently(/400, /404, /500), to response with 400/404/500 status code respectively. All other paths return 200.
$ curl -s -i http://192.168.197.181:9090/404
HTTP/1.1 404 Not Found
Content-Type: application/json; charset=UTF-8
Date: Wed, 02 Mar 2022 08:24:29 GMT
Content-Length: 205
{"headers":{"Accept":["*/*"],"User-Agent":["curl/7.29.0"]},"host":"192.168.197.181:9090","hostname":"echo-demo-v1-69dd54bf44-n2v6x","realIP":"192.168.145.0","scheme":"http","url":"/404","version":"2.0.0"}
Content type
Image
Digest
Size
6.6 MB
Last updated
over 4 years ago
docker pull kidlj/echo:1.0.0