Skip to content

Instantly share code, notes, and snippets.

@hawkw
Created June 21, 2023 15:40
Show Gist options
  • Save hawkw/d093e297c08dc428f2005fdd96b23782 to your computer and use it in GitHub Desktop.
Save hawkw/d093e297c08dc428f2005fdd96b23782 to your computer and use it in GitHub Desktop.
Linkerd edge-23.6.2 HTTPRoute timeouts demo
---
# `podinfo` deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: podinfo
spec:
replicas: 1
minReadySeconds: 3
revisionHistoryLimit: 5
progressDeadlineSeconds: 60
strategy:
rollingUpdate:
maxUnavailable: 0
type: RollingUpdate
selector:
matchLabels:
app: podinfo
template:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9797"
linkerd.io/inject: enabled
labels:
app: podinfo
spec:
containers:
- name: podinfod
image: ghcr.io/stefanprodan/podinfo:6.3.6
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 9898
protocol: TCP
- name: http-metrics
containerPort: 9797
protocol: TCP
- name: grpc
containerPort: 9999
protocol: TCP
command:
- ./podinfo
- --port=9898
- --port-metrics=9797
- --grpc-port=9999
- --grpc-service-name=podinfo
- --level=info
- --random-delay=false
- --random-error=false
env:
- name: PODINFO_UI_COLOR
value: "#34577c"
livenessProbe:
exec:
command:
- podcli
- check
- http
- localhost:9898/healthz
initialDelaySeconds: 5
timeoutSeconds: 5
readinessProbe:
exec:
command:
- podcli
- check
- http
- localhost:9898/readyz
initialDelaySeconds: 5
timeoutSeconds: 5
resources:
limits:
cpu: 2000m
memory: 512Mi
requests:
cpu: 100m
memory: 64Mi
---
# podinfo service
apiVersion: v1
kind: Service
metadata:
name: podinfo
spec:
type: ClusterIP
selector:
app: podinfo
ports:
- name: http
port: 9898
protocol: TCP
targetPort: http
- port: 9999
targetPort: grpc
protocol: TCP
name: grpc
---
# HTTPRoute for podinfo
apiVersion: policy.linkerd.io/v1beta3
kind: HTTPRoute
metadata:
name: podinfo-route
spec:
parentRefs:
- name: podinfo
kind: Service
group: core
port: 9898
rules:
# if the `x-eliza-timeout: long` header is present, set a
# backendRequest timeout of 2 seconds.
- matches:
- headers:
- name: "x-eliza-timeout"
value: "long"
backendRefs:
- name: "podinfo"
port: 9898
timeouts:
backendRequest: 3s
# if no other rules match, set a `request` timeout of 1 second.
- timeouts:
request: 2s
backendRefs:
- name: podinfo
kind: Service
group: core
port: 9898
---
# curl pod we'll use to issue HTTP requests to `podinfo`, using:
#
# $ kubectl exec curl -it -c curl /bin/sh
#
# now you're running commands in the curl pod:
#
# $ curl -v podinfo:9898/delay/1
# $ curl -v podinfo:9898/delay/2
# $ curl -v podinfo:9898/delay/2 -H "x-eliza-timeout: long"
# $ curl -v podinfo:9898/delay/3 -H "x-eliza-timeout: long"
apiVersion: v1
kind: Pod
metadata:
name: curl
annotations:
linkerd.io/inject: enabled
config.linkerd.io/proxy-log-level: info,linkerd=debug
spec:
containers:
- name: curl
image: docker.io/curlimages/curl:latest
command: ["sleep", "infinite"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment