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

FeatureDetail
Proxylinkerd2-proxy (Rust), ultralight
mTLSAutomatic, on by default
Traffic splitSMI TrafficSplit CRD
GatewayUse with NGINX/Emissary ingress

3. Implementing Consul Connect

ConceptDetail
Service intentionsAllow/deny by service name
Envoy sidecarAuto-injected proxy
Ingress gatewayConsul-managed entry
Terminating gatewayEgress to external services
Mesh gatewayCross-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

SourceMechanism
KubernetesEndpointSlice watch
ConsulCatalog API, DNS
EurekaHTTP register/heartbeat
DNS-SD (SRV)Pure DNS lookup
xDSEnvoy streaming EDS

6. Using mTLS with Service Mesh

SettingDetail
CAMesh-managed (Istiod, Linkerd)
Cert rotation24h default, automatic
IdentitySPIFFE ID per workload
PeerAuthenticationSTRICT vs PERMISSIVE mode

7. Implementing Traffic Policies

PolicyCapability
RetriesN attempts on 5xx
TimeoutsPer-route deadline
Circuit breakerMax conns, pending
Outlier detectionEject unhealthy pod
Locality LBPrefer same-zone

8. Setting Up Observability Integration

SignalTool
MetricsPrometheus scrape sidecar
TracesOTel from envoy
Access logsJSON to stdout
Service graphKiali (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

SidecarPurpose
Envoy/linkerd-proxyL7 traffic, mTLS
Log shipperFluent Bit, Vector
Cert injectorcert-manager-csi
Vault agentSecret rendering
Init containeriptables redirect setup