Experimenting with Kuma for the first time and trying to create a POC to understand its features. I’ve created a simple app which has different behavior depending on an environment setting passed to the container, and am trying to get a TrafficRoute configured to alternate to which pod the request is sent. This is the Kubernetes config for the test API (it just returns the current time either in standard or military format):
apiVersion: v1
kind: Pod
metadata:
name: dntapi-mil
namespace: meshdemo
labels:
uservice: dntapi
format: military
spec:
containers:
- name: dntapi
image: meshdemo:dntapi
ports:
- name: http
containerPort: 4000
env:
- name: MILITARY
value: "true"
---
apiVersion: v1
kind: Pod
metadata:
name: dntapi-std
namespace: meshdemo
labels:
uservice: dntapi
format: standard
spec:
containers:
- name: dntapi
image: meshdemo:dntapi
ports:
- name: http
containerPort: 4000
env:
- name: MILITARY
value: "false"
---
apiVersion: v1
kind: Service
metadata:
name: dntapi
namespace: meshdemo
spec:
selector:
uservice: dntapi
ports:
- protocol: TCP
port: 4000
targetPort: 4000
And this is the TrafficRoute configuration:
apiVersion: kuma.io/v1alpha1
kind: TrafficRoute
mesh: default
metadata:
name: split-traffic
namespace: meshdemo
spec:
sources:
- match:
kuma.io/service: webapp_meshdemo_svc_8080
destinations:
- match:
kuma.io/service: dntapi_meshdemo_svc_4000
conf:
split:
- weight: 50
destination:
kuma.io/service: dntapi_meshdemo_svc_4000
format: military
- weight: 50
destination:
kuma.io/service: dntapi_meshdemo_svc_4000
format: standard
It sort of works in that calls to “webapp” do display the value from dntapi in the different formats, but using a weight of 50/50, I guess I expected it to alternate almost like a round robin load balancer. But it seems more time based … if I call webapp multiple times in a row, it will be one format for every response, but if I wait a bit and call it again, it will have changed to the other format.
I take it that “weight” should not be interpreted like percentage? If that’s the case, how do those values work?
Thanks in advance.