# ALTERNATIVE provider-owner example; only if sidecar sees plaintext HTTP before TLS.
# Not effective for excluded outbound capture or opaque JVM-originated HTTPS.
# No egress gateway. Names/domains and every numeric value are illustrative.
apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: example-provider
  namespace: obrh-example
spec:
  hosts: [provider.example.com]
  location: MESH_EXTERNAL
  resolution: DNS
  ports:
  - number: 80
    name: http-provider
    protocol: HTTP
    targetPort: 443 # Sidecar originates server-authenticated TLS to this port.
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: example-provider-capacity
  namespace: obrh-example
spec:
  host: provider.example.com
  workloadSelector:
    matchLabels:
      app: obrh-direct-example
  trafficPolicy:
    connectionPool:
      tcp:
        maxConnections: 20
        connectTimeout: 500ms
      http:
        http2MaxRequests: 20
        http1MaxPendingRequests: 5
        maxRetries: 2 # Simultaneously outstanding retries; not retry attempts/request.
    outlierDetection:
      consecutive5xxErrors: 5
      interval: 5s
      baseEjectionTime: 30s
      maxEjectionPercent: 50
      minHealthPercent: 0 # Keep detection active even with few healthy endpoints.
    tls:
      mode: SIMPLE # Not partner mTLS; credential custody requires separate design.
      sni: provider.example.com
      subjectAltNames: [provider.example.com]
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: example-provider-read-only-retry
  namespace: obrh-example
spec:
  hosts: [provider.example.com]
  gateways: [mesh]
  http:
  - name: read-only-example
    match:
    - method:
        exact: GET
      uri:
        prefix: /reference-data/
    timeout: 3s # Includes original attempt and retries.
    retries:
      attempts: 1 # One retry after the original attempt: at most two attempts.
      perTryTimeout: 1s
      retryOn: connect-failure,reset # Even reset can be an ambiguous execution result.
    route:
    - destination:
        host: provider.example.com
        port:
          number: 80
  - name: all-other-operations-no-retry
    timeout: 3s
    retries:
      attempts: 0 # Explicitly suppress inherited/default retry behavior.
    route:
    - destination:
        host: provider.example.com
        port:
          number: 80
