-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e test for load balancing (#3868)
* update api doc and e2e test env for lb Signed-off-by: shawnh2 <shawnhxh@outlook.com> * add e2e test for round robin lb Signed-off-by: shawnh2 <shawnhxh@outlook.com> * fix gen-check Signed-off-by: shawnh2 <shawnhxh@outlook.com> * add e2e test for source ip consistent hash lb Signed-off-by: shawnh2 <shawnhxh@outlook.com> * add e2e test for header consistent hash lb Signed-off-by: shawnh2 <shawnhxh@outlook.com> * add e2e test for cookie consistent hash lb Signed-off-by: shawnh2 <shawnhxh@outlook.com> * add deployment only for lb test case Signed-off-by: shawnh2 <shawnhxh@outlook.com> * rename deployment for different test setup Signed-off-by: shawnh2 <shawnhxh@outlook.com> * wait deployment to have available replicas Signed-off-by: shawnh2 <shawnhxh@outlook.com> --------- Signed-off-by: shawnh2 <shawnhxh@outlook.com> Co-authored-by: zirain <zirain2009@gmail.com>
- Loading branch information
Showing
9 changed files
with
522 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
test/e2e/testdata/load_balancing_consistent_hash_header.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: lb-backend-3 | ||
namespace: gateway-conformance-infra | ||
spec: | ||
selector: | ||
app: lb-backend-3 | ||
ports: | ||
- protocol: TCP | ||
port: 8080 | ||
targetPort: 3000 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: lb-backend-3 | ||
namespace: gateway-conformance-infra | ||
labels: | ||
app: lb-backend-3 | ||
spec: | ||
replicas: 4 | ||
selector: | ||
matchLabels: | ||
app: lb-backend-3 | ||
template: | ||
metadata: | ||
labels: | ||
app: lb-backend-3 | ||
spec: | ||
containers: | ||
- name: backend | ||
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20231214-v1.0.0-140-gf544a46e | ||
imagePullPolicy: IfNotPresent | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: SERVICE_NAME | ||
value: lb-backend-3 | ||
resources: | ||
requests: | ||
cpu: 10m | ||
--- | ||
apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: BackendTrafficPolicy | ||
metadata: | ||
name: header-lb-policy | ||
namespace: gateway-conformance-infra | ||
spec: | ||
targetRefs: | ||
- group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
name: header-lb-route | ||
loadBalancer: | ||
type: ConsistentHash | ||
consistentHash: | ||
type: Header | ||
header: | ||
name: "Lb-Test-Header" | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: header-lb-route | ||
namespace: gateway-conformance-infra | ||
spec: | ||
parentRefs: | ||
- name: same-namespace | ||
rules: | ||
- matches: | ||
- path: | ||
type: PathPrefix | ||
value: /header | ||
backendRefs: | ||
- name: lb-backend-3 | ||
port: 8080 |
80 changes: 80 additions & 0 deletions
80
test/e2e/testdata/load_balancing_consistent_hash_source_ip.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: lb-backend-2 | ||
namespace: gateway-conformance-infra | ||
spec: | ||
selector: | ||
app: lb-backend-2 | ||
ports: | ||
- protocol: TCP | ||
port: 8080 | ||
targetPort: 3000 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: lb-backend-2 | ||
namespace: gateway-conformance-infra | ||
labels: | ||
app: lb-backend-2 | ||
spec: | ||
replicas: 4 | ||
selector: | ||
matchLabels: | ||
app: lb-backend-2 | ||
template: | ||
metadata: | ||
labels: | ||
app: lb-backend-2 | ||
spec: | ||
containers: | ||
- name: backend | ||
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20231214-v1.0.0-140-gf544a46e | ||
imagePullPolicy: IfNotPresent | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: SERVICE_NAME | ||
value: lb-backend-2 | ||
resources: | ||
requests: | ||
cpu: 10m | ||
--- | ||
apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: BackendTrafficPolicy | ||
metadata: | ||
name: source-ip-lb-policy | ||
namespace: gateway-conformance-infra | ||
spec: | ||
targetRefs: | ||
- group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
name: source-ip-lb-route | ||
loadBalancer: | ||
type: ConsistentHash | ||
consistentHash: | ||
type: SourceIP | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: source-ip-lb-route | ||
namespace: gateway-conformance-infra | ||
spec: | ||
parentRefs: | ||
- name: same-namespace | ||
rules: | ||
- matches: | ||
- path: | ||
type: PathPrefix | ||
value: /source | ||
backendRefs: | ||
- name: lb-backend-2 | ||
port: 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: lb-backend-1 | ||
namespace: gateway-conformance-infra | ||
spec: | ||
selector: | ||
app: lb-backend-1 | ||
ports: | ||
- protocol: TCP | ||
port: 8080 | ||
targetPort: 3000 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: lb-backend-1 | ||
namespace: gateway-conformance-infra | ||
labels: | ||
app: lb-backend-1 | ||
spec: | ||
replicas: 4 | ||
selector: | ||
matchLabels: | ||
app: lb-backend-1 | ||
template: | ||
metadata: | ||
labels: | ||
app: lb-backend-1 | ||
spec: | ||
containers: | ||
- name: backend | ||
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20231214-v1.0.0-140-gf544a46e | ||
imagePullPolicy: IfNotPresent | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: SERVICE_NAME | ||
value: lb-backend-1 | ||
resources: | ||
requests: | ||
cpu: 10m | ||
--- | ||
apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: BackendTrafficPolicy | ||
metadata: | ||
name: round-robin-lb-policy | ||
namespace: gateway-conformance-infra | ||
spec: | ||
targetRefs: | ||
- group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
name: round-robin-lb-route | ||
loadBalancer: | ||
type: RoundRobin | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: round-robin-lb-route | ||
namespace: gateway-conformance-infra | ||
spec: | ||
parentRefs: | ||
- name: same-namespace | ||
rules: | ||
- matches: | ||
- path: | ||
type: PathPrefix | ||
value: /round | ||
backendRefs: | ||
- name: lb-backend-1 | ||
port: 8080 |
Oops, something went wrong.