diff --git a/test/gatewayapi/install.sh b/test/gatewayapi/install.sh index c7ab9337..20778f79 100755 --- a/test/gatewayapi/install.sh +++ b/test/gatewayapi/install.sh @@ -2,62 +2,56 @@ set -o errexit -CONTOUR_VER="v1.26.0" -GATEWAY_API_VER="v1beta1" +GATEWAY_API_VER="v1.0.0" REPO_ROOT=$(git rev-parse --show-toplevel) -KUSTOMIZE_VERSION=4.5.2 -OS=$(uname -s) -ARCH=$(arch) -if [[ $ARCH == "x86_64" ]]; then - ARCH="amd64" -fi +ISTIO_VER="1.20.0" mkdir -p ${REPO_ROOT}/bin -echo ">>> Installing Contour components, Gateway API CRDs" -kubectl apply -f https://raw.githubusercontent.com/projectcontour/contour/${CONTOUR_VER}/examples/render/contour-gateway-provisioner.yaml +echo ">>> Installing Gateway API CRDs" +kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \ + { kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref=${GATEWAY_API_VER}" | kubectl apply -f -; } -kubectl -n projectcontour rollout status deployment/contour-gateway-provisioner -kubectl -n gateway-system wait --for=condition=complete job/gateway-api-admission -kubectl -n gateway-system wait --for=condition=complete job/gateway-api-admission-patch -kubectl -n gateway-system rollout status deployment/gateway-api-admission-server -kubectl -n projectcontour get all +echo ">>> Downloading Istio ${ISTIO_VER}" +cd ${REPO_ROOT}/bin && \ +curl -L https://istio.io/downloadIstio | ISTIO_VERSION=${ISTIO_VER} sh - -echo ">>> Creating GatewayClass" -cat <>> Installing Istio ${ISTIO_VER}" +${REPO_ROOT}/bin/istio-${ISTIO_VER}/bin/istioctl install --set profile=minimal \ + --set values.pilot.resources.requests.cpu=100m \ + --set values.pilot.resources.requests.memory=100Mi -y + +kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.20/samples/addons/prometheus.yaml +kubectl -n istio-system rollout status deployment/prometheus echo ">>> Creating Gateway" +kubectl create ns istio-ingress cat <>> Installing Kustomize' -cd ${REPO_ROOT}/bin && \ - curl -sL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_${OS}_${ARCH}.tar.gz | \ - tar xz - echo '>>> Installing Flagger' -${REPO_ROOT}/bin/kustomize build ${REPO_ROOT}/kustomize/gatewayapi | kubectl apply -f - -kubectl -n flagger-system set image deployment/flagger flagger=test/flagger:latest +kubectl create ns flagger-system +helm upgrade -i flagger ${REPO_ROOT}/charts/flagger \ + --set crd.create=false \ + --namespace flagger-system \ + --set prometheus.install=false \ + --set meshProvider=gatewayapi:v1 \ + --set metricsServer=http://prometheus.istio-system:9090 +kubectl -n flagger-system set image deployment/flagger flagger=test/flagger:latest kubectl -n flagger-system rollout status deployment/flagger diff --git a/test/gatewayapi/test-ab.sh b/test/gatewayapi/test-ab.sh index 9d5c2604..6c33c5cc 100755 --- a/test/gatewayapi/test-ab.sh +++ b/test/gatewayapi/test-ab.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # This script runs e2e tests for A/B traffic shifting, Canary analysis and promotion -# Prerequisites: Kubernetes Kind and Contour with GatewayAPI +# Prerequisites: Kubernetes Kind and Istio with GatewayAPI set -o errexit @@ -33,10 +33,10 @@ spec: port: 9898 portName: http hosts: - - localproject.contour.io + - www.example.com gatewayRefs: - - name: contour - namespace: projectcontour + - name: gateway + namespace: istio-ingress analysis: interval: 15s threshold: 10 @@ -46,14 +46,6 @@ spec: x-canary: exact: "insider" metrics: - # - name: request-success-rate - # thresholdRange: - # min: 99 - # interval: 1m - # - name: request-duration - # threshold: 500 - # interval: 30s - - name: error-rate templateRef: name: error-rate @@ -74,7 +66,7 @@ spec: url: http://flagger-loadtester.test/ timeout: 5s metadata: - cmd: "hey -z 2m -q 10 -c 2 -host localproject.contour.io -H 'X-Canary: insider' http://envoy-contour.projectcontour/" + cmd: "hey -z 2m -q 10 -c 2 -host www.example.com -H 'X-Canary: insider' http://gateway-istio.istio-ingress" logCmdOutput: "true" EOF diff --git a/test/gatewayapi/test-bg.sh b/test/gatewayapi/test-bg.sh index 40b103b6..b673ca0d 100755 --- a/test/gatewayapi/test-bg.sh +++ b/test/gatewayapi/test-bg.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # This script runs e2e tests for Blue/Green traffic shifting, Canary analysis and promotion -# Prerequisites: Kubernetes Kind and Contour with GatewayAPI +# Prerequisites: Kubernetes Kind and Istio with GatewayAPI set -o errexit @@ -9,6 +9,8 @@ REPO_ROOT=$(git rev-parse --show-toplevel) source ${REPO_ROOT}/test/gatewayapi/test-utils.sh +create_request_duration_metric_template + echo '>>> Deploy podinfo in bg-test namespace' kubectl create ns bg-test kubectl apply -f ${REPO_ROOT}/test/workloads/secret.yaml -n bg-test @@ -30,20 +32,19 @@ spec: port: 9898 portName: http hosts: - - localproject.contour.io + - www.example.com gatewayRefs: - - name: contour - namespace: projectcontour + - name: gateway + namespace: istio-ingress analysis: interval: 10s threshold: 5 iterations: 5 metrics: - - name: request-success-rate - thresholdRange: - min: 99 - interval: 1m - - name: request-duration + - name: custom-requst-duration + templateRef: + name: request-duration + namespace: flagger-system threshold: 500 interval: 30s webhooks: diff --git a/test/gatewayapi/test-canary.sh b/test/gatewayapi/test-canary.sh index 98c361ff..9ab95a26 100755 --- a/test/gatewayapi/test-canary.sh +++ b/test/gatewayapi/test-canary.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # This script runs e2e tests for progressive traffic shifting, Canary analysis and promotion -# Prerequisites: Kubernetes Kind and Contour with GatewayAPI +# Prerequisites: Kubernetes Kind and Istio with GatewayAPI set -o errexit @@ -29,10 +29,10 @@ spec: port: 9898 portName: http hosts: - - localproject.contour.io + - www.example.com gatewayRefs: - - name: contour - namespace: projectcontour + - name: gateway + namespace: istio-ingress analysis: interval: 15s threshold: 15 @@ -59,7 +59,7 @@ spec: url: http://flagger-loadtester.test/ timeout: 5s metadata: - cmd: "hey -z 2m -q 10 -c 2 -host localproject.contour.io http://envoy-contour.projectcontour/" + cmd: "hey -z 2m -q 10 -c 2 -host www.example.com http://gateway-istio.istio-ingress" logCmdOutput: "true" EOF @@ -122,13 +122,13 @@ spec: targetPort: 9898 portName: http hosts: - - localproject.contour.io + - www.example.com gatewayRefs: - - name: contour - namespace: projectcontour + - name: gateway + namespace: istio-ingress analysis: interval: 15s - threshold: 15 + threshold: 6 maxWeight: 50 stepWeight: 10 metrics: @@ -152,7 +152,7 @@ spec: url: http://flagger-loadtester.test/ timeout: 5s metadata: - cmd: "hey -z 2m -q 10 -c 2 -host localproject.contour.io http://envoy-contour.projectcontour/status/500" + cmd: "hey -z 2m -q 10 -c 2 -host www.example.com http://gateway-istio.istio-ingress/status/500" logCmdOutput: "true" EOF diff --git a/test/gatewayapi/test-session-affinity.sh b/test/gatewayapi/test-session-affinity.sh index 8b2ed621..bc7d7668 100755 --- a/test/gatewayapi/test-session-affinity.sh +++ b/test/gatewayapi/test-session-affinity.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # This script runs e2e tests for progressive traffic shifting with session affinity, Canary analysis and promotion -# Prerequisites: Kubernetes Kind and Contour with GatewayAPI +# Prerequisites: Kubernetes Kind and Istio with GatewayAPI set -o errexit @@ -34,10 +34,10 @@ spec: port: 9898 portName: http hosts: - - localproject.contour.io + - www.example.com gatewayRefs: - - name: contour - namespace: projectcontour + - name: gateway + namespace: istio-ingress analysis: interval: 15s threshold: 15 @@ -66,7 +66,7 @@ spec: url: http://flagger-loadtester.test/ timeout: 5s metadata: - cmd: "hey -z 2m -q 10 -c 2 -host localproject.contour.io http://envoy-contour.projectcontour/" + cmd: "hey -z 2m -q 10 -c 2 -host www.example.com http://gateway-istio.istio-ingress" logCmdOutput: "true" EOF @@ -75,7 +75,7 @@ check_primary "sa-test" display_httproute "sa-test" echo '>>> Port forwarding load balancer' -kubectl port-forward -n projectcontour svc/envoy-contour 8888:80 2>&1 > /dev/null & +kubectl port-forward -n istio-ingress svc/gateway-istio 8888:80 2>&1 > /dev/null & pf_pid=$! cleanup() { @@ -104,7 +104,7 @@ until ${ok}; do done echo '>>> Verifying session affinity' -if ! URL=http://localhost:8888 HOST=localproject.contour.io VERSION=6.1.0 COOKIE_NAME=flagger-cookie \ +if ! URL=http://localhost:8888 HOST=www.example.com VERSION=6.1.0 COOKIE_NAME=flagger-cookie \ go run ${REPO_ROOT}/test/gatewayapi/verify_session_affinity.go; then echo "failed to verify session affinity" exit $? @@ -145,7 +145,7 @@ done echo '>>> Verifying cookie cleanup' canary_cookie=$(kubectl -n sa-test get canary podinfo -o=jsonpath='{.status.previousSessionAffinityCookie}' | xargs) -response=$(curl -H "Host: localproject.contour.io" -H "Cookie: $canary_cookie" -D - http://localhost:8888) +response=$(curl -H "Host: www.example.com" -H "Cookie: $canary_cookie" -D - http://localhost:8888) if [[ $response == *"$canary_cookie"* ]]; then echo "✔ Found previous cookie in response" diff --git a/test/gatewayapi/test-utils.sh b/test/gatewayapi/test-utils.sh index c55241e7..825df4d9 100755 --- a/test/gatewayapi/test-utils.sh +++ b/test/gatewayapi/test-utils.sh @@ -36,6 +36,34 @@ display_httproute() { fi } +create_request_duration_metric_template() { + if ! kubectl -n flagger-system get metrictemplates request-duration ; then + echo '>>> Create request-duration metric template' + cat <>> Create latency metric template' @@ -48,13 +76,15 @@ create_latency_metric_template() { spec: provider: type: prometheus - address: http://flagger-prometheus:9090 + address: http://prometheus.istio-system:9090 query: | histogram_quantile(0.99, sum( rate( - envoy_cluster_upstream_rq_time_bucket{ - envoy_cluster_name=~"{{ namespace }}_{{ target }}-canary_[0-9a-zA-Z-]+", + istio_request_duration_milliseconds_bucket{ + reporter="source", + destination_workload_namespace=~"{{ namespace }}", + destination_workload=~"{{ target }}", }[{{ interval }}] ) ) by (le) @@ -75,21 +105,25 @@ create_error_rate_metric_template() { spec: provider: type: prometheus - address: http://flagger-prometheus:9090 + address: http://prometheus.istio-system:9090 query: | 100 - sum( rate( - envoy_cluster_upstream_rq{ - envoy_cluster_name=~"{{ namespace }}_{{ target }}-canary_[0-9a-zA-Z-]+", - envoy_response_code!~"5.*" + istio_requests_total{ + reporter="source", + destination_workload_namespace=~"{{ namespace }}", + destination_workload=~"{{ target }}", + response_code!~"5.*" }[{{ interval }}] ) ) / sum( rate( - envoy_cluster_upstream_rq{ - envoy_cluster_name=~"{{ namespace }}_{{ target }}-canary_[0-9a-zA-Z-]+", + istio_requests_total{ + reporter="source", + destination_workload_namespace=~"{{ namespace }}", + destination_workload=~"{{ target }}", }[{{ interval }}] ) )