api-gateway-service-mesh
mchittineni/cloud-platform-skills/.agents/skills/api-gateway-service-mesh/SKILL.md
API gateway and service mesh architecture: Istio strict mTLS and authorization policy, VirtualService traffic shifting, Envoy Gateway and Kong ingress, retries/timeouts/outlier detection, and rate limiting. Use when configuring ingress routing, enforcing zero-trust service-to-service traffic, or debugging mesh routing and mTLS failures.
Skill1 starsChanged 45 days ago
What's in it
- API Gateway & Service Mesh (Istio & Envoy) Architecture
- When to Use This Skill
- 1. Istio Zero-Trust Strict mTLS & VirtualService Traffic Shifting
- 2. Best Practices & Anti-Patterns
- 3. Default-Deny Authorization & Outlier Detection
- 4. Gateway Choice: Istio Gateway, Envoy Gateway or Kong
---
name: api-gateway-service-mesh
description: "API gateway and service mesh architecture: Istio strict mTLS and authorization policy, VirtualService traffic shifting, Envoy Gateway and Kong ingress, retries/timeouts/outlier detection, and rate limiting. Use when configuring ingress routing, enforcing zero-trust service-to-service traffic, or debugging mesh routing and mTLS failures."
level: senior
tags: [api-gateway, service-mesh, istio, envoy, kong, platform-engineering]
compatible_runtimes: [antigravity, claude, codex, cursor]
---
# API Gateway & Service Mesh (Istio & Envoy) Architecture
## When to Use This Skill
**Triggers — load this skill when:**
- North-south ingress or east-west mesh routing must be designed or changed
- Service-to-service traffic needs mTLS and authorization policy
- A 503/routing/mTLS failure inside the mesh needs diagnosis
**Route elsewhere when:**
- Weighted rollout automation -> `zero-downtime-release-strategies`
- Application-side resilience patterns -> `scalability-high-availability-patterns`
- Mesh telemetry pipelines -> `prometheus-grafana-otel-tracing`
## 1. Istio Zero-Trust Strict mTLS & VirtualService Traffic Shifting
```yaml
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: production
spec:
mtls:
mode: STRICT # Enforce encrypted mTLS across all service-to-service traffic
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: user-service-route
namespace: production
spec:
hosts:
- "user-service.production.svc.cluster.local"
http:
- route:
- destination:
host: user-service.production.svc.cluster.local
subset: v1
weight: 90
- destination:
host: user-service.production.svc.cluster.local
subset: v2
weight: 10
retries:
attempts: 3
perTryTimeout: 2s
retryOn: "5xx,connect-failure,refused-stream"
```
---
## 2. Best Practices & Anti-Patterns
- **Do**: Enforce `STRICT` mTLS across internal namespaces to prevent unauthenticated lateral movement.
- **Do**: Implement API Gateway rate limiting and authentication (JWT verification) at the edge before traffic enters the cluster mesh.
- **Don't**: Never configure retries without idempotent request semantics or backoff limits.
---
## 3. Default-Deny Authorization & Outlier Detection
mTLS proves _who_ is calling; authorization decides _whether they may_. Strict mTLS without an
AuthorizationPolicy still allows every service to call every other service.
```yaml
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: deny-all, namespace: prod } # 1. default deny for the namespace
spec: {} # empty spec + no rules = deny everything
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: checkout-allow-from-web, namespace: prod }
spec:
selector: { matchLabels: { app: checkout } }
action: ALLOW
rules:
- from:
- source:
principals: ["cluster.local/ns/prod/sa/web-frontend"] # SPIFFE identity, not IP
to:
- operation: { methods: ["POST"], paths: ["/api/v1/checkout"] }
```
**DestinationRule** carries the client-side resilience settings the application would otherwise
have to implement:
```yaml
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: checkout, namespace: prod }
spec:
host: checkout.prod.svc.cluster.local
trafficPolicy:
tls: { mode: ISTIO_MUTUAL }
connectionPool:
tcp: { maxConnections: 200, connectTimeout: 2s }
http: { http2MaxRequests: 500, maxRequestsPerConnection: 100 }
outlierDetection: # passive health checking = circuit breaking
consecutive5xxErrors: 5
interval: 10s
baseEjectionTime: 30s
maxEjectionPercent: 50 # never eject the whole fleet
subsets:
- name: v1
labels: { version: v1 }
- name: v2
labels: { version: v2 }
```
`503 UC`/`UF` means the sidecar could not reach upstream: check `istioctl proxy-config
endpoints`, whether the port name carries the right protocol prefix, and whether outlier
detection has ejected the endpoints. `maxRequestsPerConnection: 1` disables keep-alive — set it
only for upstreams that mishandle connection reuse.
---
## 4. Gateway Choice: Istio Gateway, Envoy Gateway or Kong
North-south ingress and east-west mesh are separate decisions; conflating them produces two
overlapping control planes.
| Option | Config surface | Choose it when |
| --- | --- | --- |
| Istio Ingress Gateway | Istio CRDs (`Gateway`, `VirtualService`) | The mesh is already Istio and one control plane is preferred |
| Envoy Gateway | Kubernetes Gateway API (`HTTPRoute`, `GRPCRoute`) | Standards-based routing wanted, mesh-agnostic, no Istio lock-in |
| Kong | Kong CRDs / declarative config, plugin ecosystem | API-management needs dominate: consumers, keys, quotas, monetisation |
```yaml
# Gateway API — portable across Envoy Gateway, Istio and Kong implementations
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: { name: checkout, namespace: prod }
spec:
parentRefs: [{ name: public-gateway, namespace: istio-system }]
hostnames: ["checkout.example.com"]
rules:
- matches: [{ path: { type: PathPrefix, value: /api/v1 } }]
timeouts: { request: 10s }
backendRefs: [{ name: checkout, port: 8080, weight: 100 }]
```
Prefer Gateway API for new ingress: it is the direction all three implementations are moving, and
it keeps the routing contract portable while mesh-internal policy stays in Istio CRDs. Kong earns
its place when the requirement is an API product (consumer onboarding, rate-limit tiers, keys),
not merely routing.
More agent context in mchittineni/cloud-platform-skills
167 other files this repository gives its agents, the first 60 shown.
AGENTS.md
CLAUDE.md
Copilot instructions
Cursor rule
- .cursor/rules/00-index.mdc
- .cursor/rules/skills/ai-agent-security-llm-threats.mdc
- .cursor/rules/skills/api-gateway-service-mesh.mdc
- .cursor/rules/skills/aws-cloud-migration-strategies.mdc
- .cursor/rules/skills/aws-eks-enterprise-patterns.mdc
- .cursor/rules/skills/aws-iam-zero-trust-policies.mdc
- .cursor/rules/skills/azure-aks-enterprise-landing-zones.mdc
- .cursor/rules/skills/azure-cloud-engineering-patterns.mdc
- .cursor/rules/skills/backup-and-disaster-recovery.mdc
- .cursor/rules/skills/chaos-engineering-resilience-testing.mdc
- .cursor/rules/skills/cicd-pipeline-design.mdc
- .cursor/rules/skills/cloud-native-microservices-patterns.mdc
- .cursor/rules/skills/cloud-security-posture-cspm-cis.mdc
- .cursor/rules/skills/configuration-management-ansible.mdc
- .cursor/rules/skills/container-runtime-security-falco.mdc
- .cursor/rules/skills/database-devops-lifecycle.mdc
- .cursor/rules/skills/detection-engineering-threat-hunting.mdc
- .cursor/rules/skills/devops-metrics-dora-kpis.mdc
- .cursor/rules/skills/docker-containerization-basics.mdc
- .cursor/rules/skills/enterprise-iac-governance-terragrunt.mdc
- .cursor/rules/skills/finops-framework-inform-optimize-operate.mdc
- .cursor/rules/skills/gcp-cloud-engineering-patterns.mdc
- .cursor/rules/skills/gcp-gke-autopilot-multi-tenant.mdc
- .cursor/rules/skills/git-branching-merge-strategies.mdc
- .cursor/rules/skills/gitops-multi-cluster-argo-flux.mdc
- .cursor/rules/skills/helm-kubernetes-deployment.mdc
- .cursor/rules/skills/incident-management-and-postmortem.mdc
- .cursor/rules/skills/infrastructure-host-monitoring.mdc
- .cursor/rules/skills/internal-developer-portal-backstage.mdc
- .cursor/rules/skills/linux-sysadmin-troubleshooting.mdc
- .cursor/rules/skills/performance-load-testing.mdc
- .cursor/rules/skills/policy-as-code-opa-kyverno.mdc
- .cursor/rules/skills/prometheus-grafana-otel-tracing.mdc
- .cursor/rules/skills/scalability-high-availability-patterns.mdc
- .cursor/rules/skills/scripting-and-automation.mdc
- .cursor/rules/skills/secops-incident-triage-forensics.mdc
- .cursor/rules/skills/secrets-management-vault-kms.mdc
- .cursor/rules/skills/serverless-event-driven-architecture.mdc
- .cursor/rules/skills/shift-left-security-sast-sca.mdc
- .cursor/rules/skills/sli-slo-error-budget-design.mdc
- .cursor/rules/skills/supply-chain-security-slsa-sigstore.mdc
- .cursor/rules/skills/terraform-iac-modules.mdc
- .cursor/rules/skills/write-a-skill.mdc
- .cursor/rules/skills/zero-downtime-release-strategies.mdc
Skill
- ai-agent-security-llm-threats.agents/skills/ai-agent-security-llm-threats/SKILL.md
- aws-cloud-migration-strategies.agents/skills/aws-cloud-migration-strategies/SKILL.md
- aws-eks-enterprise-patterns.agents/skills/aws-eks-enterprise-patterns/SKILL.md
- aws-iam-zero-trust-policies.agents/skills/aws-iam-zero-trust-policies/SKILL.md
- azure-aks-enterprise-landing-zones.agents/skills/azure-aks-enterprise-landing-zones/SKILL.md
- azure-cloud-engineering-patterns.agents/skills/azure-cloud-engineering-patterns/SKILL.md
- backup-and-disaster-recovery.agents/skills/backup-and-disaster-recovery/SKILL.md
- chaos-engineering-resilience-testing.agents/skills/chaos-engineering-resilience-testing/SKILL.md
- cicd-pipeline-design.agents/skills/cicd-pipeline-design/SKILL.md
- cloud-native-microservices-patterns.agents/skills/cloud-native-microservices-patterns/SKILL.md
- cloud-security-posture-cspm-cis.agents/skills/cloud-security-posture-cspm-cis/SKILL.md
- configuration-management-ansible.agents/skills/configuration-management-ansible/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
Reports can't be read right now.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool public_context_discussion, action report. How to connect one.

