Istio WorkloadEntry + local pods

Viewed 197

I need to implement this scenario https://istio.io/latest/blog/2020/workload-entry/ where the load should be distributed to local pods and to external service (external service implements the same functionality as local pods).

Local pod service:

apiVersion: v1
kind: Service
metadata:
  name: myapp
spec:
  selector:
    app: myapp
  ports:
    - name: http
      appProtocol: http
      targetPort: http
      port: 80

External service:

apiVersion: networking.istio.io/v1alpha3
kind: WorkloadEntry
metadata:
  name: myapp
spec:
  address: example.net
  labels:
    app: myapp

apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: myapp
spec:
  hosts:
    - myapp.default.svc.cluster.local
  location: MESH_INTERNAL
  ports:
    - number: 8000
      name: http
      protocol: HTTP
      targetPort: 80
  resolution: DNS
  workloadSelector:
    labels:
      app: myapp
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: myapp
spec:
  hosts:
    - '*.mydomain.net'

  gateways:
    - gw
    - mesh

  http:
    - name: myapp
      match:
        - uri:
            prefix: /
      route:
        - destination:
            host: myapp.default.svc.cluster.local
            port:
              number: 8000

      retries:
        attempts: 20
        retryOn: 503,retriable-status-codes,connect-failure,reset
        retryRemoteLocalities: true

With this setup, local pods are never selected and always routed to external service. Load should be balanced across local and external service.

Istio v1.9.4

0 Answers
Related