mirror of
https://github.com/stefanprodan/podinfo.git
synced 2026-03-03 10:30:19 +00:00
0ff49e5057f444b60036ffaf7e6a4bdaa0dbc399
`podinfo --h2c` allows upgrading a HTTP/1.1 connection to HTTP/2 Cleartext. This allows `podinfo` to be used in e.g. a H2C load-test like `echo "GET http://localhost:9898/status/200" | vegeta -h2c`, or a H2C connectivity test like done with `curl -v http2 http://localhost:9898/status/200`. I have manually verified this to work by running `curl -v --http2` on macOS and seeing the H2C upgrade happens onl when `-h2c` is provided to `podinfo`. Without `-h2c`: ``` $ curl -v --http2 localhost:9898/status/200 * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 9898 (#0) > GET /status/200 HTTP/1.1 > Host: localhost:9898 > User-Agent: curl/7.54.0 > Accept: */* > Connection: Upgrade, HTTP2-Settings > Upgrade: h2c > HTTP2-Settings: AAMAAABkAARAAAAAAAIAAAAA > < HTTP/1.1 200 OK < Content-Type: application/json; charset=utf-8 < X-Content-Type-Options: nosniff < Date: Mon, 04 Nov 2019 04:58:01 GMT < Content-Length: 19 < { "status": 200 * Connection #0 to host localhost left intact } ``` With `-h2c`: ``` $ curl -v --http2 localhost:9898/status/200 * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 9898 (#0) > GET /status/200 HTTP/1.1 > Host: localhost:9898 > User-Agent: curl/7.54.0 > Accept: */* > Connection: Upgrade, HTTP2-Settings > Upgrade: h2c > HTTP2-Settings: AAMAAABkAARAAAAAAAIAAAAA > < HTTP/1.1 101 Switching Protocols < Connection: Upgrade < Upgrade: h2c * Received 101 * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Connection state changed (MAX_CONCURRENT_STREAMS updated)! < HTTP/2 200 < content-type: application/json; charset=utf-8 < x-content-type-options: nosniff < content-length: 19 < date: Mon, 04 Nov 2019 04:58:28 GMT < { "status": 200 * Connection #0 to host localhost left intact } `
podinfo
Podinfo is a tiny web application made with Go that showcases best practices of running microservices in Kubernetes.
Specifications:
- Health checks (readiness and liveness)
- Graceful shutdown on interrupt signals
- File watcher for secrets and configmaps
- Instrumented with Prometheus
- Tracing with Istio and Jaeger
- Linkerd service profile
- Structured logging with zap
- 12-factor app with viper
- Fault injection (random errors and latency)
- Swagger docs
- Helm and Kustomize installers
- End-to-End testing with Kubernetes Kind and Helm
- Kustomize testing with GitHub Actions and Open Policy Agent
Web API:
GET /prints runtime informationGET /versionprints podinfo version and git commit hashGET /metricsreturn HTTP requests duration and Go runtime metricsGET /healthzused by Kubernetes liveness probeGET /readyzused by Kubernetes readiness probePOST /readyz/enablesignals the Kubernetes LB that this instance is ready to receive trafficPOST /readyz/disablesignals the Kubernetes LB to stop sending requests to this instanceGET /status/{code}returns the status codeGET /paniccrashes the process with exit code 255POST /echoforwards the call to the backend service and echos the posted contentGET /envreturns the environment variables as a JSON arrayGET /headersreturns a JSON with the request HTTP headersGET /delay/{seconds}waits for the specified periodPOST /tokenissues a JWT token valid for one minuteJWT=$(curl -sd 'anon' podinfo:9898/token | jq -r .token)GET /token/validatevalidates the JWT tokencurl -H "Authorization: Bearer $JWT" podinfo:9898/token/validateGET /configsreturns a JSON with configmaps and/or secrets mounted in theconfigvolumePOST /storewrites the posted content to disk at /data/hash and returns the SHA1 hash of the contentGET /store/{hash}returns the content of the file /data/hash if existsGET /ws/echoechos content via websocketspodcli ws ws://localhost:9898/ws/echoGET /chunked/{seconds}usestransfer-encodingtypechunkedto give a partial response and then waits for the specified periodGET /swagger.jsonreturns the API Swagger docs, used for Linkerd service profiling and Gloo routes discovery
gRPC API:
/grpc.health.v1.Health/Checkhealth checking
Web UI:
To access the Swagger UI open <podinfo-host>/swagger/index.html in a browser.
Guides
- Automated canary deployments with Flagger and Istio
- Kubernetes autoscaling with Istio metrics
- Managing Helm releases the GitOps way
- Expose Kubernetes services over HTTPS with Ngrok
Install
Helm:
helm repo add sp https://stefanprodan.github.io/podinfo
helm upgrade --install --wait frontend \
--namespace test \
--set replicaCount=2 \
--set backend=http://backend-podinfo:9898/echo \
sp/podinfo
helm test frontend --cleanup
helm upgrade --install --wait backend \
--namespace test \
--set hpa.enabled=true \
sp/podinfo
Kustomize:
kubectl apply -k github.com/stefanprodan/podinfo//kustomize
Docker:
docker run -dp 9898:9898 stefanprodan/podinfo
Description
Languages
Go
76.8%
CUE
11.6%
HTML
3.7%
Makefile
3.4%
Shell
2.4%
Other
2.1%
