$npx -y skills add wshobson/agents --skill istio-traffic-managementConfigure Istio traffic management including routing, load balancing, circuit breakers, and canary deployments. Use when implementing service mesh traffic policies, progressive delivery, or resilience patterns.
| 1 | # Istio Traffic Management |
| 2 | |
| 3 | Comprehensive guide to Istio traffic management for production service mesh deployments. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | - Configuring service-to-service routing |
| 8 | - Implementing canary or blue-green deployments |
| 9 | - Setting up circuit breakers and retries |
| 10 | - Load balancing configuration |
| 11 | - Traffic mirroring for testing |
| 12 | - Fault injection for chaos engineering |
| 13 | |
| 14 | ## Core Concepts |
| 15 | |
| 16 | ### 1. Traffic Management Resources |
| 17 | |
| 18 | | Resource | Purpose | Scope | |
| 19 | | ------------------- | ----------------------------- | ------------- | |
| 20 | | **VirtualService** | Route traffic to destinations | Host-based | |
| 21 | | **DestinationRule** | Define policies after routing | Service-based | |
| 22 | | **Gateway** | Configure ingress/egress | Cluster edge | |
| 23 | | **ServiceEntry** | Add external services | Mesh-wide | |
| 24 | |
| 25 | ### 2. Traffic Flow |
| 26 | |
| 27 | ``` |
| 28 | Client → Gateway → VirtualService → DestinationRule → Service |
| 29 | (routing) (policies) (pods) |
| 30 | ``` |
| 31 | |
| 32 | ## Templates |
| 33 | |
| 34 | ### Template 1: Basic Routing |
| 35 | |
| 36 | ```yaml |
| 37 | apiVersion: networking.istio.io/v1beta1 |
| 38 | kind: VirtualService |
| 39 | metadata: |
| 40 | name: reviews-route |
| 41 | namespace: bookinfo |
| 42 | spec: |
| 43 | hosts: |
| 44 | - reviews |
| 45 | http: |
| 46 | - match: |
| 47 | - headers: |
| 48 | end-user: |
| 49 | exact: jason |
| 50 | route: |
| 51 | - destination: |
| 52 | host: reviews |
| 53 | subset: v2 |
| 54 | - route: |
| 55 | - destination: |
| 56 | host: reviews |
| 57 | subset: v1 |
| 58 | --- |
| 59 | apiVersion: networking.istio.io/v1beta1 |
| 60 | kind: DestinationRule |
| 61 | metadata: |
| 62 | name: reviews-destination |
| 63 | namespace: bookinfo |
| 64 | spec: |
| 65 | host: reviews |
| 66 | subsets: |
| 67 | - name: v1 |
| 68 | labels: |
| 69 | version: v1 |
| 70 | - name: v2 |
| 71 | labels: |
| 72 | version: v2 |
| 73 | - name: v3 |
| 74 | labels: |
| 75 | version: v3 |
| 76 | ``` |
| 77 | |
| 78 | ### Template 2: Canary Deployment |
| 79 | |
| 80 | ```yaml |
| 81 | apiVersion: networking.istio.io/v1beta1 |
| 82 | kind: VirtualService |
| 83 | metadata: |
| 84 | name: my-service-canary |
| 85 | spec: |
| 86 | hosts: |
| 87 | - my-service |
| 88 | http: |
| 89 | - route: |
| 90 | - destination: |
| 91 | host: my-service |
| 92 | subset: stable |
| 93 | weight: 90 |
| 94 | - destination: |
| 95 | host: my-service |
| 96 | subset: canary |
| 97 | weight: 10 |
| 98 | --- |
| 99 | apiVersion: networking.istio.io/v1beta1 |
| 100 | kind: DestinationRule |
| 101 | metadata: |
| 102 | name: my-service-dr |
| 103 | spec: |
| 104 | host: my-service |
| 105 | trafficPolicy: |
| 106 | connectionPool: |
| 107 | tcp: |
| 108 | maxConnections: 100 |
| 109 | http: |
| 110 | h2UpgradePolicy: UPGRADE |
| 111 | http1MaxPendingRequests: 100 |
| 112 | http2MaxRequests: 1000 |
| 113 | subsets: |
| 114 | - name: stable |
| 115 | labels: |
| 116 | version: stable |
| 117 | - name: canary |
| 118 | labels: |
| 119 | version: canary |
| 120 | ``` |
| 121 | |
| 122 | ### Template 3: Circuit Breaker |
| 123 | |
| 124 | ```yaml |
| 125 | apiVersion: networking.istio.io/v1beta1 |
| 126 | kind: DestinationRule |
| 127 | metadata: |
| 128 | name: circuit-breaker |
| 129 | spec: |
| 130 | host: my-service |
| 131 | trafficPolicy: |
| 132 | connectionPool: |
| 133 | tcp: |
| 134 | maxConnections: 100 |
| 135 | http: |
| 136 | http1MaxPendingRequests: 100 |
| 137 | http2MaxRequests: 1000 |
| 138 | maxRequestsPerConnection: 10 |
| 139 | maxRetries: 3 |
| 140 | outlierDetection: |
| 141 | consecutive5xxErrors: 5 |
| 142 | interval: 30s |
| 143 | baseEjectionTime: 30s |
| 144 | maxEjectionPercent: 50 |
| 145 | minHealthPercent: 30 |
| 146 | ``` |
| 147 | |
| 148 | ### Template 4: Retry and Timeout |
| 149 | |
| 150 | ```yaml |
| 151 | apiVersion: networking.istio.io/v1beta1 |
| 152 | kind: VirtualService |
| 153 | metadata: |
| 154 | name: ratings-retry |
| 155 | spec: |
| 156 | hosts: |
| 157 | - ratings |
| 158 | http: |
| 159 | - route: |
| 160 | - destination: |
| 161 | host: ratings |
| 162 | timeout: 10s |
| 163 | retries: |
| 164 | attempts: 3 |
| 165 | perTryTimeout: 3s |
| 166 | retryOn: connect-failure,refused-stream,unavailable,cancelled,retriable-4xx,503 |
| 167 | retryRemoteLocalities: true |
| 168 | ``` |
| 169 | |
| 170 | ### Template 5: Traffic Mirroring |
| 171 | |
| 172 | ```yaml |
| 173 | apiVersion: networking.istio.io/v1beta1 |
| 174 | kind: VirtualService |
| 175 | metadata: |
| 176 | name: mirror-traffic |
| 177 | spec: |
| 178 | hosts: |
| 179 | - my-service |
| 180 | http: |
| 181 | - route: |
| 182 | - destination: |
| 183 | host: my-service |
| 184 | subset: v1 |
| 185 | mirror: |
| 186 | host: my-service |
| 187 | subset: v2 |
| 188 | mirrorPercentage: |
| 189 | value: 100.0 |
| 190 | ``` |
| 191 | |
| 192 | ### Template 6: Fault Injection |
| 193 | |
| 194 | ```yaml |
| 195 | apiVersion: networking.istio.io/v1beta1 |
| 196 | kind: VirtualService |
| 197 | metadata: |
| 198 | name: fault-injection |
| 199 | spec: |
| 200 | hosts: |
| 201 | - ratings |
| 202 | http: |
| 203 | - fault: |
| 204 | delay: |
| 205 | percentage: |
| 206 | value: 10 |
| 207 | fixedDelay: 5s |
| 208 | abort: |
| 209 | percentage: |
| 210 | value: 5 |
| 211 | httpStatus: 503 |
| 212 | route: |
| 213 | - destination: |
| 214 | host: ratings |
| 215 | ``` |
| 216 | |
| 217 | ### Template 7: Ingress Gateway |
| 218 | |
| 219 | ```yaml |
| 220 | apiVersion: networking.istio.io/v1beta1 |
| 221 | kind: Gateway |
| 222 | metadata: |
| 223 | name: my-gateway |
| 224 | spec: |
| 225 | selector: |
| 226 | istio: ingressgateway |
| 227 | servers: |
| 228 | - port: |
| 229 | number: 443 |
| 230 | name: https |
| 231 | protocol: HTTPS |
| 232 | tls: |
| 233 | mode: SIMPLE |
| 234 | credentialName: my-tls-secret |
| 235 | hosts: |