Description:
When I add an weighted backend to an HTTPRoute I expect traffic to go to that backend with the correct filters applied
Instead I'm seeing traffic being sent to the wrong backend.
Repro steps:
- I have a simple go server that prints request headers.
Go HTTP Sever
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
target := os.Getenv("TARGET")
if target == "" {
target = "World"
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// Log all request headers
fmt.Println("Request Headers:")
for name, values := range r.Header {
for _, value := range values {
fmt.Printf("%s: %s\n", name, value)
}
}
// Send response
fmt.Fprintf(w, "Hello %s!\n", target)
})
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
log.Printf("Starting server on port %s...\n", port)
if err := http.ListenAndServe(":"+port, nil); err != nil {
log.Fatal(err)
}
}
Next deploy two workloads using this go application
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: second
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: second
template:
metadata:
labels:
app: second
spec:
containers:
- name: helloworld
image: test-image
env:
- name: TARGET
value: "second"
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: second
namespace: default
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
app: second
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: first
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: first
template:
metadata:
labels:
app: first
spec:
containers:
- name: helloworld
image: test-image
env:
- name: TARGET
value: "first"
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: first
namespace: default
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
app: first
Next we configure two routes with equal weights. For each backend we add request headers to correctly identify the split that should occur.
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: sample
namespace: default
labels:
app: sample
spec:
parentRefs:
- name: external-gateway
namespace: default
hostnames:
- "sample.com"
rules:
- backendRefs:
- name: first
port: 80
weight: 10
filters:
- type: RequestHeaderModifier
requestHeaderModifier:
set:
- name: first
value: first
- name: second
port: 80
weight: 10
filters:
- type: RequestHeaderModifier
requestHeaderModifier:
set:
- name: second
value: second
After making requests to sample.com - you'll see the wrong headers end up in the wrong backend
See: First: first in the below logs
second-764d49d88f-bgmtc helloworld Request Headers:
second-764d49d88f-bgmtc helloworld User-Agent: curl/8.7.1
second-764d49d88f-bgmtc helloworld Accept: */*
second-764d49d88f-bgmtc helloworld X-Forwarded-For: 172.18.0.3
second-764d49d88f-bgmtc helloworld X-Forwarded-Proto: http
second-764d49d88f-bgmtc helloworld X-Envoy-External-Address: 172.18.0.3
second-764d49d88f-bgmtc helloworld X-Request-Id: 19f2119b-d88f-4be2-9806-b043528d3f84
second-764d49d88f-bgmtc helloworld First: first
Environment:
Using Envoy Gateway v1.3.0 testing on kind using cloud-provider-kind
Logs:
Description:
When I add an weighted backend to an HTTPRoute I expect traffic to go to that backend with the correct filters applied
Instead I'm seeing traffic being sent to the wrong backend.
Repro steps:
Go HTTP Sever
Next deploy two workloads using this go application
Next we configure two routes with equal weights. For each backend we add request headers to correctly identify the split that should occur.
After making requests to
sample.com- you'll see the wrong headers end up in the wrong backendSee:
First: firstin the below logsEnvironment:
Using Envoy Gateway v1.3.0 testing on kind using
cloud-provider-kindLogs: