Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 1005 Bytes

File metadata and controls

51 lines (40 loc) · 1005 Bytes

Task 05: Configure Retry Policy for HTTP Errors

Step 1: Switch to Correct Context

kubectl config use-context cluster3-admin@cluster3

Step 2: Create VirtualService with Retry Policy

kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: gray-echo-vs
  namespace: gray
spec:
  hosts:
    - gray-echo
  http:
    - retries:
        attempts: 2
        perTryTimeout: 1s
        retryOn: 5xx
      route:
        - destination:
            host: gray-echo.gray.svc.cluster.local
            port:
              number: 80
EOF

Step 3: Verify Configuration

# Check VirtualService exists
kubectl get virtualservice -n gray

Testing

Test 1: Trigger Retries with 500 Error

# Run a test pod
kubectl exec sleep-red -n red -- curl -s -o /dev/null -w "%{http_code}\n"  http://gray-echo.gray.svc.cluster.local/blackhole

kubectl logs -n gray -l app=gray-echo -c istio-proxy | grep 'HTTP/1.1" 500'