Kubernetes Istio流量拆分未正确使用权重
我正在使用默认的bookinfo应用程序,并尝试使用reviews服务测试分割流量。Kiali正在显示拆分,似乎所有配置都正确,但仍在循环。如果我删除所有虚拟服务和目标规则,应用程序将正常工作Kubernetes Istio流量拆分未正确使用权重,kubernetes,yaml,istio,envoyproxy,kind,Kubernetes,Yaml,Istio,Envoyproxy,Kind,我正在使用默认的bookinfo应用程序,并尝试使用reviews服务测试分割流量。Kiali正在显示拆分,似乎所有配置都正确,但仍在循环。如果我删除所有虚拟服务和目标规则,应用程序将正常工作 # Source: bookinfo/templates/destination-rule-all.yaml apiVersion: networking.istio.io/v1alpha3 kind: DestinationRule metadata: name: productpage spec:
# Source: bookinfo/templates/destination-rule-all.yaml
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: productpage
spec:
host: productpage
subsets:
- name: v1
labels:
version: v1
---
# Source: bookinfo/templates/destination-rule-all.yaml
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: ratings
spec:
host: ratings
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
- name: v2-mysql
labels:
version: v2-mysql
- name: v2-mysql-vm
labels:
version: v2-mysql-vm
---
# Source: bookinfo/templates/destination-rule-all.yaml
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: details
spec:
host: details
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
---
# Source: bookinfo/templates/destination-rule-all.yaml
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: reviews
spec:
host: reviews
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
- name: v3
labels:
version: v3
---
# Source: bookinfo/templates/bookinfo-gateway.yaml
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: bookinfo-gateway
chart: bookinfo-0.1.2
release: bookinfo
spec:
selector:
istio: ingressgateway # use istio default controller
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
# Source: bookinfo/templates/bookinfo-gateway.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bookinfo
chart: bookinfo-0.1.2
release: bookinfo
spec:
hosts:
- "*"
gateways:
- bookinfo-gateway
http:
- match:
- uri:
exact: /productpage
- uri:
prefix: /static
- uri:
exact: /login
- uri:
exact: /logout
- uri:
prefix: /api/v1/products
route:
- destination:
host: productpage
port:
number: 9080
---
# Source: bookinfo/templates/virtual-service-all-v1.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: productpage
spec:
hosts:
- productpage
gateways:
- bookinfo-gateway
http:
- route:
- destination:
host: productpage
subset: v1
---
# Source: bookinfo/templates/virtual-service-all-v1.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
gateways:
- bookinfo-gateway
http:
- route:
- destination:
host: reviews
subset: v1
weight: 100
- destination:
host: reviews
subset: v2
weight: 0
- destination:
host: reviews
subset: v3
weight: 0
---
# Source: bookinfo/templates/virtual-service-all-v1.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings
spec:
hosts:
- ratings
gateways:
- bookinfo-gateway
http:
- route:
- destination:
host: ratings
subset: v1
---
# Source: bookinfo/templates/virtual-service-all-v1.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: details
spec:
hosts:
- details
gateways:
- bookinfo-gateway
http:
- route:
- destination:
host: details
subset: v1
# Source: bookinfo/templates/reviews-v1-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: reviews-v1
labels:
chart: bookinfo-0.1.2
release: bookinfo
app: reviews
version: v1
spec:
replicas: 1
selector:
matchLabels:
app: reviews
release: bookinfo
version: v1
template:
metadata:
labels:
app: reviews
release: bookinfo
version: v1
spec:
serviceAccountName: bookinfo-reviews
containers:
- name: reviews
image: myhub/istio/examples-bookinfo-reviews-v1:1.15.0
imagePullPolicy: IfNotPresent
env:
- name: LOG_DIR
value: "/tmp/logs"
ports:
- containerPort: 9080
volumeMounts:
- name: tmp
mountPath: /tmp
- name: wlp-output
mountPath: /opt/ibm/wlp/output
volumes:
- name: wlp-output
emptyDir: {}
- name: tmp
emptyDir: {}
---
# Source: bookinfo/templates/reviews-v2-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: reviews-v2
labels:
chart: bookinfo-0.1.2
release: bookinfo
app: reviews
version: v2
spec:
replicas: 1
selector:
matchLabels:
app: reviews
release: bookinfo
version: v2
template:
metadata:
labels:
app: reviews
release: bookinfo
version: v2
spec:
serviceAccountName: bookinfo-reviews
containers:
- name: reviews
image: myhub/istio/examples-bookinfo-reviews-v2:1.15.0
imagePullPolicy: IfNotPresent
env:
- name: LOG_DIR
value: "/tmp/logs"
ports:
- containerPort: 9080
volumeMounts:
- name: tmp
mountPath: /tmp
- name: wlp-output
mountPath: /opt/ibm/wlp/output
volumes:
- name: wlp-output
emptyDir: {}
- name: tmp
emptyDir: {}
---
# Source: bookinfo/templates/reviews-v3-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
metadata:
name: reviews-v3
labels:
chart: bookinfo-0.1.2
release: bookinfo
app: reviews
version: v3
spec:
replicas: 1
selector:
matchLabels:
app: reviews
release: bookinfo
version: v3
template:
metadata:
labels:
app: reviews
release: bookinfo
version: v3
spec:
serviceAccountName: bookinfo-reviews
containers:
- name: ratings
image: myhub/istio/examples-bookinfo-reviews-v3:1.15.0
imagePullPolicy: IfNotPresent
env:
- name: LOG_DIR
value: "/tmp/logs"
ports:
- containerPort: 9080
volumeMounts:
- name: tmp
mountPath: /tmp
- name: wlp-output
mountPath: /opt/ibm/wlp/output
volumes:
- name: wlp-output
emptyDir: {}
- name: tmp
emptyDir: {}
---
环境
种类v0.7.0 go1.13.6 linux/amd64
K8s v1.18.1 v1.17.0
我试图用istio 1.5.2在gke上重现您的问题,一切正常
我跟着伊斯提奥 如上所述 应用默认目的地规则 在使用Istio控制Bookinfo版本路由之前,您需要在目标规则中定义称为子集的可用版本 运行以下命令为Bookinfo服务创建默认目标规则: 如果未启用相互TLS,请执行以下命令: 如果您是Istio新手并且正在使用演示配置文件,请选择此选项 如果确实启用了相互TLS,请执行以下命令: 等待几秒钟,以便传播目标规则 可以使用以下命令显示目标规则:
应用虚拟服务进行评论 示例 流量仅适用于子集v1
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v1
仅针对子集v2的通信量
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
子集v2和v3的50/50权重流量
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
weight: 50
- destination:
host: reviews
subset: v3
weight: 50
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
weight: 100
- destination:
host: reviews
subset: v3
weight: 0
- destination:
host: reviews
subset: v1
weight: 0
子集v1、v2和v3的100/0/0权重流量
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
weight: 50
- destination:
host: reviews
subset: v3
weight: 50
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
weight: 100
- destination:
host: reviews
subset: v3
weight: 0
- destination:
host: reviews
subset: v1
weight: 0
使用仅适用于v1子集的虚拟服务,Kiali显示流量仅适用于v1 Istio productpage没有显示星星,所以它是review v1
有关于的文档可供审阅。我尝试使用istio 1.5.2在gke上重现您的问题,一切正常
我跟着伊斯提奥 如上所述 应用默认目的地规则 在使用Istio控制Bookinfo版本路由之前,您需要在目标规则中定义称为子集的可用版本 运行以下命令为Bookinfo服务创建默认目标规则: 如果未启用相互TLS,请执行以下命令: 如果您是Istio新手并且正在使用演示配置文件,请选择此选项 如果确实启用了相互TLS,请执行以下命令: 等待几秒钟,以便传播目标规则 可以使用以下命令显示目标规则:
应用虚拟服务进行评论 示例 流量仅适用于子集v1
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v1
仅针对子集v2的通信量
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
子集v2和v3的50/50权重流量
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
weight: 50
- destination:
host: reviews
subset: v3
weight: 50
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
weight: 100
- destination:
host: reviews
subset: v3
weight: 0
- destination:
host: reviews
subset: v1
weight: 0
子集v1、v2和v3的100/0/0权重流量
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
weight: 50
- destination:
host: reviews
subset: v3
weight: 50
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
weight: 100
- destination:
host: reviews
subset: v3
weight: 0
- destination:
host: reviews
subset: v1
weight: 0
使用仅适用于v1子集的虚拟服务,Kiali显示流量仅适用于v1 Istio productpage没有显示星星,所以它是review v1
有关于评论的文档。太奇怪了,我用Kiali的图片更新了我的帖子。它显示所有配置都正确,但当我刷新bookinfo应用程序时,我会看到红色、黑色和无星星。我甚至尝试删除所有虚拟服务和目的地规则,应用程序仍然正常工作。似乎交通不是被迫通过代理的,这很奇怪。您的istio是否部署在istio系统命名空间中?你的istio版本是什么?很奇怪。版本1.5.1,是的,它在istio系统名称空间中,但bookinfo在它自己的名称空间中,但ingress正在工作。我也通过Kind在本地运行我的环境,所以可能是环境的缺陷。太奇怪了,我用Kiali的图片更新了我的帖子。它显示所有配置都正确,但当我刷新bookinfo应用程序时,我会看到红色、黑色和无星星。我甚至尝试删除所有虚拟服务和目的地规则,应用程序仍然正常工作。似乎交通不是被迫通过代理的,这很奇怪。您的istio是否部署在istio系统命名空间中?你的istio版本是什么?很奇怪。版本1.5.1,是的,它在istio系统名称空间中,但bookinfo在它自己的名称空间中,但ingress正在工作。我还通过Kind在本地运行我的环境,因此可能是环境的缺陷。