Implementing Service Mesh Integration
1. Configuring Istio Integration
Example: Istio Gateway + VirtualService
apiVersion: networking.istio.io/v1
kind: Gateway
metadata: { name: api-gw }
spec:
selector: { istio: ingressgateway }
servers:
- port: { number: 443, name: https, protocol: HTTPS }
tls: { mode: SIMPLE, credentialName: api-tls }
hosts: ["api.example.com"]
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata: { name: orders }
spec:
hosts: ["api.example.com"]
gateways: [api-gw]
http:
- match: [{ uri: { prefix: /orders } }]
route: [{ destination: { host: orders.svc.cluster.local, port: { number: 80 } } }]
2. Using Linkerd Integration
| Feature | Detail |
|---|---|
| Proxy | linkerd2-proxy (Rust), ultralight |
| mTLS | Automatic, on by default |
| Traffic split | SMI TrafficSplit CRD |
| Gateway | Use with NGINX/Emissary ingress |
3. Implementing Consul Connect
| Concept | Detail |
|---|---|
| Service intentions | Allow/deny by service name |
| Envoy sidecar | Auto-injected proxy |
| Ingress gateway | Consul-managed entry |
| Terminating gateway | Egress to external services |
| Mesh gateway | Cross-DC connectivity |
4. Setting Up Envoy Proxy Integration
Example: Envoy xDS listener
listeners:
- name: api_listener
address: { socket_address: { address: 0.0.0.0, port_value: 8443 } }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: api
route_config:
virtual_hosts:
- name: api
domains: ["*"]
routes:
- match: { prefix: "/" }
route: { cluster: orders }
http_filters:
- name: envoy.filters.http.router
5. Configuring Service Discovery
| Source | Mechanism |
|---|---|
| Kubernetes | EndpointSlice watch |
| Consul | Catalog API, DNS |
| Eureka | HTTP register/heartbeat |
| DNS-SD (SRV) | Pure DNS lookup |
| xDS | Envoy streaming EDS |
6. Using mTLS with Service Mesh
| Setting | Detail |
|---|---|
| CA | Mesh-managed (Istiod, Linkerd) |
| Cert rotation | 24h default, automatic |
| Identity | SPIFFE ID per workload |
| PeerAuthentication | STRICT vs PERMISSIVE mode |
7. Implementing Traffic Policies
| Policy | Capability |
|---|---|
| Retries | N attempts on 5xx |
| Timeouts | Per-route deadline |
| Circuit breaker | Max conns, pending |
| Outlier detection | Eject unhealthy pod |
| Locality LB | Prefer same-zone |
8. Setting Up Observability Integration
| Signal | Tool |
|---|---|
| Metrics | Prometheus scrape sidecar |
| Traces | OTel from envoy |
| Access logs | JSON to stdout |
| Service graph | Kiali (Istio), Linkerd viz |
9. Configuring Circuit Breakers
Example: Istio DestinationRule
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata: { name: orders-cb }
spec:
host: orders.svc.cluster.local
trafficPolicy:
connectionPool:
tcp: { maxConnections: 100 }
http: { http1MaxPendingRequests: 50, http2MaxRequests: 1000 }
outlierDetection:
consecutive5xxErrors: 5
interval: 30s
baseEjectionTime: 30s
maxEjectionPercent: 50
10. Using Sidecar Patterns
| Sidecar | Purpose |
|---|---|
| Envoy/linkerd-proxy | L7 traffic, mTLS |
| Log shipper | Fluent Bit, Vector |
| Cert injector | cert-manager-csi |
| Vault agent | Secret rendering |
| Init container | iptables redirect setup |