Skip to main content
logoTetrate Istio SubscriptionVersion: Next

TIS1103 - Weight Assumed as 100 for a Single Route Destination

The weight is automatically assumed to be 100 because there is only one route destination defined in the VirtualService.

Recommendation: Simplify or Balance Traffic by Correcting weight Field

To reduce unnecessary configuration, remove the weight field for a single route destination. Alternatively, add more route destinations with specific weights to achieve load balancing.

Examples

  1. VirtualService with Unnecessary Weight Set to 100 for a Single Destination

    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
    name: my-virtual-service
    namespace: example-namespace
    spec:
    hosts:
    - "my-app.example.com"
    http:
    - route:
    - destination:
    host: "my-app-service.example-namespace.svc.cluster.local"
    weight: 100

    Explanation: Since there is only one route destination in the VirtualService, specifying a weight of 100 is redundant. Istio automatically assigns a weight of 100 when there is only one destination, which means the weight field is unnecessary in this case.

Recommendation

Remove the weight field or add another RouteDestination with a specific weight to create a load balancing scenario.

  1. Remove the weight Field for a Single Destination

    If only one destination is needed, remove the weight field to simplify the configuration.

    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
    name: my-virtual-service
    namespace: example-namespace
    spec:
    hosts:
    - "my-app.example.com"
    http:
    - route:
    - destination:
    host: "my-app-service.example-namespace.svc.cluster.local"

    Explanation: Removing the weight field reduces unnecessary complexity, as Istio will automatically assign a weight of 100 for the only available destination.

  2. Add Another Route Destination for Load Balancing

    If multiple destinations are needed, add another RouteDestination with specific weights to distribute traffic.

    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
    name: my-virtual-service
    namespace: example-namespace
    spec:
    hosts:
    - "my-app.example.com"
    http:
    - route:
    - destination:
    host: "my-app-service-v1.example-namespace.svc.cluster.local"
    weight: 50
    - destination:
    host: "my-app-service-v2.example-namespace.svc.cluster.local"
    weight: 50

    Explanation: Adding another route destination with specified weights creates a load balancing setup where traffic is distributed between multiple versions of the service.