#!/usr/bin/env bash check_primary() { echo '>>> Waiting for primary to be ready' namespace=$1 retries=50 count=0 ok=false until ${ok}; do kubectl get -n ${namespace} canary/podinfo | grep 'Initialized' && ok=true || ok=false sleep 5 count=$(($count + 1)) if [[ ${count} -eq ${retries} ]]; then kubectl -n flagger-system logs deployment/flagger echo "No more retries left" exit 1 fi done echo '✔ Canary initialization test passed' passed=$(kubectl -n $namespace get svc/podinfo -o jsonpath='{.spec.selector.app}' 2>&1 | { grep podinfo-primary || true; }) if [ -z "$passed" ]; then echo -e '\u2716 podinfo selector test failed' exit 1 fi echo '✔ Canary service custom metadata test passed' } display_httproute() { namespace=$1 if ! kubectl -n ${namespace} get httproute podinfo -oyaml; then echo "Could not find HTTPRoute podinfo in ${namespace} namespace" exit 1 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' cat <>> Create latency metric template' cat <