定义库玛/特使的分裂交通路线
我正在尝试使用kuma创建服务网格的演示,并且我对如何在查看示例 。我有两个微服务的版本,这些版本取决于在Kubernetes配置中定义的环境变量。并且与POD关联的服务是由其配置配置的,它要使用的pod(不确定这是否正确地执行此操作):
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
format: military
ports:
- protocol: TCP
port: 4000
targetPort: 4000
如果我更改服务上的选择器,则可以从纯粹的K8S角度来使用,但要查看Kuma拆分流量的示例:
conf:
split:
- weight: 90
destination:
kuma.io/service: redis_default_svc_6379
version: '1.0'
- weight: 10
destination:
kuma.io/service: redis_default_svc_6379
version: '2.0'
与服务关联时的“版本”是什么(我必须承认我不明白如何使用相同的标识符有两个服务)。这些K8选择器吗?
我应该补充一点,当我检查使用Kumactl的服务时,我会看到两个用于此微服务,一个没有端口名称:
dntapi-std_meshdemo_svc Online 1/1
dntapi_meshdemo_svc_4000 Online 1/1
预先感谢。
I'm trying to create a demo of a service mesh using Kuma, and I'm confused about how to configure a traffic traffic split when viewing the example in the docs. I have two versions of a microservice which return different results depending on an environment variable which is defined in the Kubernetes config. And the service associated with the pods is configured by its config which pod to use (not sure if this the right way to do this):
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
format: military
ports:
- protocol: TCP
port: 4000
targetPort: 4000
This works from a purely K8s perspective if I change the selector on the service, but looking at the Kuma example of split traffic:
conf:
split:
- weight: 90
destination:
kuma.io/service: redis_default_svc_6379
version: '1.0'
- weight: 10
destination:
kuma.io/service: redis_default_svc_6379
version: '2.0'
To what is "version" referring when associated with the service (and I have to admit that I don't understand how there could be two services with the same identifier). Are these K8s selectors?
I should add that when I inspect services with kumactl, I see two for this microservice, one without a port name:
dntapi-std_meshdemo_svc Online 1/1
dntapi_meshdemo_svc_4000 Online 1/1
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改您的服务定义以仅使用工作负载的两种变化的标签(看起来这是
uservice:dntapi
)。然后使用格式
标签作为Kuma ClockitRoute目标中的“标签”,就像示例使用版本
TAG(可以/可以直接从Kubernetes标签派生)一样。这将使您可以控制将哪些流量发送到标有格式的POD:Standard
以及将哪些百分比发送到标有格式的Pods:Morials
。请参阅 https://github.com/kuma/kumahq/kuma-demo/kuma/kuma/tree/master/master/master/master /kubernetes 另一个例子。向下滚动到“流量路由”部分;该示例确实做了我上面描述的。
Change your Service definition to use only a label common to both variations of the workload (looks like this would be
uservice: dntapi
). Then use theformat
label as "tags" in the Kuma TrafficRoute destination, just as the example uses theversion
tag (which is/can be derived directly from the Kubernetes labels). This would allow you to control what percentage of traffic is sent to Pods labeledformat: standard
and what percentage is sent to Pods labeledformat: military
.See https://github.com/kumahq/kuma-demo/tree/master/kubernetes for another example. Scroll down to the "Traffic Routing" section; that example does exactly what I describe above.