Skip to content

Commit f526201

Browse files
authored
Add steps for running conformance tests on Envoy Gateway (#3266)
* Add steps for running conformance tests on Envoy Gateway Signed-off-by: Arko Dasgupta <[email protected]> * add `--allow-crds-mismatch` Signed-off-by: Arko Dasgupta <[email protected]> * fix license Signed-off-by: Arko Dasgupta <[email protected]> * mv create-cluster.sh to hack/implementations/common Signed-off-by: Arko Dasgupta <[email protected]> * run a specific test as an example Signed-off-by: Arko Dasgupta <[email protected]> --------- Signed-off-by: Arko Dasgupta <[email protected]>
1 parent d027515 commit f526201

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/bash
2+
3+
# Copyright 2024 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# This file contains code derived from Envoy Gateway,
18+
# https://github.com/envoyproxy/gateway
19+
# from the source file
20+
# https://github.com/envoyproxy/gateway/blob/main/tools/hack/create-cluster.sh
21+
# and is provided here subject to the following:
22+
# Copyright Envoy Gateway Authors
23+
# SPDX-License-Identifier: Apache-2.0
24+
25+
set -euo pipefail
26+
27+
# Setup default values
28+
CLUSTER_NAME=${CLUSTER_NAME:-"envoy-gateway"}
29+
METALLB_VERSION=${METALLB_VERSION:-"v0.13.10"}
30+
KIND_NODE_TAG=${KIND_NODE_TAG:-"v1.28.0"}
31+
NUM_WORKERS=${NUM_WORKERS:-""}
32+
33+
34+
KIND_CFG=$(cat <<-EOM
35+
kind: Cluster
36+
apiVersion: kind.x-k8s.io/v1alpha4
37+
nodes:
38+
- role: control-plane
39+
EOM
40+
)
41+
42+
# https://kind.sigs.k8s.io/docs/user/quick-start/#multi-node-clusters
43+
if [[ -n "${NUM_WORKERS}" ]]; then
44+
for _ in $(seq 1 "${NUM_WORKERS}"); do
45+
KIND_CFG+=$(printf "\n%s" "- role: worker")
46+
done
47+
fi
48+
49+
## Check if kind cluster already exists.
50+
if kind get clusters | grep -q "${CLUSTER_NAME}"; then
51+
echo "Cluster ${CLUSTER_NAME} already exists."
52+
else
53+
## Create kind cluster.
54+
if [[ -z "${KIND_NODE_TAG}" ]]; then
55+
cat << EOF | kind create cluster --name "${CLUSTER_NAME}" --config -
56+
${KIND_CFG}
57+
EOF
58+
else
59+
cat << EOF | kind create cluster --image "kindest/node:${KIND_NODE_TAG}" --name "${CLUSTER_NAME}" --config -
60+
${KIND_CFG}
61+
EOF
62+
fi
63+
fi
64+
65+
66+
## Install MetalLB.
67+
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/"${METALLB_VERSION}"/config/manifests/metallb-native.yaml
68+
needCreate="$(kubectl get secret -n metallb-system memberlist --no-headers --ignore-not-found -o custom-columns=NAME:.metadata.name)"
69+
if [ -z "$needCreate" ]; then
70+
kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
71+
fi
72+
73+
# Wait for MetalLB to become available.
74+
kubectl rollout status -n metallb-system deployment/controller --timeout 5m
75+
kubectl rollout status -n metallb-system daemonset/speaker --timeout 5m
76+
77+
# Apply config with addresses based on docker network IPAM.
78+
subnet=$(docker network inspect kind | jq -r '.[].IPAM.Config[].Subnet | select(contains(":") | not)')
79+
# Assume default kind network subnet prefix of 16, and choose addresses in that range.
80+
address_first_octets=$(echo "${subnet}" | awk -F. '{printf "%s.%s",$1,$2}')
81+
address_range="${address_first_octets}.255.200-${address_first_octets}.255.250"
82+
kubectl apply -f - <<EOF
83+
apiVersion: metallb.io/v1beta1
84+
kind: IPAddressPool
85+
metadata:
86+
namespace: metallb-system
87+
name: kube-services
88+
spec:
89+
addresses:
90+
- ${address_range}
91+
---
92+
apiVersion: metallb.io/v1beta1
93+
kind: L2Advertisement
94+
metadata:
95+
name: kube-services
96+
namespace: metallb-system
97+
spec:
98+
ipAddressPools:
99+
- kube-services
100+
EOF
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Running Conformance Tests for Envoy Gateway
2+
3+
## Prerequisities
4+
5+
Make sure you have these tools installed
6+
7+
* [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
8+
* [helm](https://helm.sh/docs/intro/install/)
9+
10+
## (Optional) Step 1: Create kind cluster
11+
12+
* Skip this step if you have an existing Kubernetes you would like to use.
13+
14+
```shell script
15+
../common/create-cluster.sh
16+
```
17+
18+
## Step 2: Install Envoy Gateway (`v0.0.0-latest`)
19+
20+
```shell script
21+
helm install eg oci://docker.io/envoyproxy/gateway-helm --version v0.0.0-latest -n envoy-gateway-system --create-namespace
22+
```
23+
24+
## Step 3: Install the GatewayClass resource
25+
26+
```shell script
27+
cat <<EOF | kubectl apply -f -
28+
kind: GatewayClass
29+
apiVersion: gateway.networking.k8s.io/v1
30+
metadata:
31+
name: envoy-gateway
32+
spec:
33+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
34+
EOF
35+
```
36+
37+
## Step 4: Run a specific conformance test
38+
39+
```shell script
40+
go test -v ./conformance \
41+
--run TestConformance/TLSRouteSimpleSameNamespace \
42+
--gateway-class=envoy-gateway --supported-features=Gateway,TLSRoute \
43+
--allow-crds-mismatch
44+
```
45+
46+
## (Optional) Step 4: Delete kind cluster
47+
48+
```shell script
49+
kind delete cluster --name envoy-gateway
50+
```

0 commit comments

Comments
 (0)