Skip to content

Latest commit

 

History

History
67 lines (56 loc) · 1.17 KB

File metadata and controls

67 lines (56 loc) · 1.17 KB

Task 13: Route 100% Traffic to Specific Version

Step 1: Switch Context and Check Service

kubectl config use-context cluster3-admin@cluster3

# Verify echo-pearl service exists
kubectl get svc -n pearl

# Verify sleep-pearl pod has Istio sidecar
kubectl get pod -n pearl -l app=sleep-pearl -o jsonpath='{.items[0].spec.containers[*].name}'
# Should show: sleep istio-proxy

Step 2: Create DestinationRule First

kubectl apply -f - <<'EOF'
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
  name: pearl-ds
  namespace: pearl
spec:
  host: echo-pearl
  subsets:
  - name: v1
    labels:
      version: v1
  - name: v2
    labels:
      version: v2
EOF

Step 3: Create VirtualService

kubectl apply -f - <<'EOF'
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: pearl-vs
  namespace: pearl
spec:
  hosts:
  - echo-pearl
  http:
  - route:
    - destination:
        host: echo-pearl
        subset: v1
      weight: 100
EOF

Testing

# Send multiple requests
for i in {1..20}; do
  kubectl exec -n pearl sleep-pearl -- curl -s http://echo-pearl
done | sort | uniq -c

# All should go to v1