liveBook · Manning

Weight

As explained in Kubernetes in Action, Second Edition

A weight is a routing value that determines a backend's proportional share of requests relative to the weights of other backends.

In an HTTPRoute, a weight sets a backend’s proportional share of requests relative to the weights of other backends. If you omit weights, traffic is split evenly. section 13.3.2

A 9:1 canary split

Give the stable Service a weight of 9 and the new Service a weight of 1. Their total weight is 10, so the stable Service receives nine-tenths of requests and the new Service receives one-tenth. section 13.3.2

Listing 13.3 Splitting HTTP traffic using weights
spec:
  rules:
  - backendRefs:           #1
    - name: kiada-stable     #2
      port: 80               #2
      weight: 9              #2
    - name: kiada-new     #3
      port: 80            #3
      weight: 1           #3

See how the weights appear in an HTTPRoute backendRefs list. section 13.3.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains proportional shares with a 9:1 worked example and a request-count check, without detailing routing internals.
Examples
Uses stable and new Services with weights of 9 and 1, and suggests checking request counts with curl.
What it assumes
Builds on HTTPRoute backend references to Services, beginning from a route that forwards traffic to one Service.
What you can do after
Configure an HTTPRoute to send a chosen proportional share of requests to multiple backend Services.
How it connects
Connects HTTPRoute backendRefs and Kubernetes Services with traffic splitting and canary deployments.

Also explained in

Compare how 4 books explain weight →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.