架构图
imagedestinationrule-demoapp.yaml
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: demoapp
spec:
host: demoapp
subsets:
- name: v10
labels:
version: v1.0
- name: v11
labels:
version: v1.1
删除virtualservice-demoapp
# kubectl delete -f virtualservice-demoapp.yaml
virtualservice.networking.istio.io "demoapp" deleted
删除demoappv10 demoapp-v11 svc
定义子集后不需要demoappv10 demoapp-v11。
# kubectl delete -f service-demoapp-v10.yaml -f service-demoapp-v11.yaml
service "demoappv10" deleted
service "demoappv11" deleted
访问demoapp
root@client # while true;do curl proxy/hostname; sleep 0.5; done
Proxying value: ServerName: demoappv11-78bf898c74-zzcpv
- Took 16 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
- Took 10 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
- Took 5 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 6 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
- Took 3 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 5 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
- Took 4 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 4 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 4 milliseconds.
Proxying value: ServerName: demoappv11-78bf898c74-n88v6
- Took 10 milliseconds.
查看kiaki
image创建destinationrule-demoapp
# kubectl apply -f destinationrule-demoapp.yaml
destinationrule.networking.istio.io/demoapp created
查看destinationrule-demoapp
~# istioctl proxy-config clusters demoappv11-78bf898c74-zzcpv
SERVICE FQDN PORT SUBSET DIRECTION TYPE DESTINATION RULE
8080 - inbound ORIGINAL_DST
BlackHoleCluster - - - STATIC
InboundPassthroughClusterIpv4 - - - ORIGINAL_DST
PassthroughCluster - - - ORIGINAL_DST
agent - - - STATIC
dashboard-metrics-scraper.kubernetes-dashboard.svc.cluster.local 8000 - outbound EDS
demoapp.default.svc.cluster.local 8080 - outbound EDS demoapp.default
demoapp.default.svc.cluster.local 8080 v10 outbound EDS demoapp.default # 子集v10
demoapp.default.svc.cluster.local 8080 v11 outbound EDS demoapp.default # 子集v11
demoappv10.default.svc.cluster.local 8080 - outbound EDS
demoappv11.default.svc.cluster.local 8080 - outbound EDS
grafana.istio-system.svc.cluster.local 3000 - outbound EDS grafana.istio-system
istio-egressgateway.istio-system.svc.cluster.local 80 - outbound EDS
istio-egressgateway.istio-system.svc.cluster.local 443 - outbound EDS
istio-ingressgateway.istio-system.svc.cluster.local 80 - outbound EDS
istio-ingressgateway.istio-system.svc.cluster.local 443 - outbound EDS
istio-ingressgateway.istio-system.svc.cluster.local 15021 - outbound EDS
istio-ingressgateway.istio-system.svc.cluster.local 15443 - outbound EDS
istio-ingressgateway.istio-system.svc.cluster.local 31400 - outbound EDS
istiod.istio-system.svc.cluster.local 443 - outbound EDS
istiod.istio-system.svc.cluster.local 15010 - outbound EDS
istiod.istio-system.svc.cluster.local 15012 - outbound EDS
istiod.istio-system.svc.cluster.local 15014 - outbound EDS
jaeger-collector.istio-system.svc.cluster.local 9411 - outbound EDS
jaeger-collector.istio-system.svc.cluster.local 14250 - outbound EDS
jaeger-collector.istio-system.svc.cluster.local 14268 - outbound EDS
kiali.istio-system.svc.cluster.local 9090 - outbound EDS kiali.istio-system
kiali.istio-system.svc.cluster.local 20001 - outbound EDS kiali.istio-system
kube-dns.kube-system.svc.cluster.local 53 - outbound EDS
kube-dns.kube-system.svc.cluster.local 9153 - outbound EDS
kubernetes-dashboard.kubernetes-dashboard.svc.cluster.local 443 - outbound EDS
kubernetes.default.svc.cluster.local 443 - outbound EDS
prometheus.istio-system.svc.cluster.local 9090 - outbound EDS
prometheus_stats - - - STATIC
proxy.default.svc.cluster.local 80 - outbound EDS
sds-grpc - - - STATIC
tracing.istio-system.svc.cluster.local 80 - outbound EDS
tracing.istio-system.svc.cluster.local 16685 - outbound EDS
xds-grpc - - - STATIC
zipkin - - - STRICT_DNS
zipkin.istio-system.svc.cluster.local 9411 - outbound EDS
virtualservice-demoapp添加子集
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: demoapp
spec:
hosts:
- demoapp
http:
- name: canary
match:
- uri:
prefix: /canary
rewrite:
uri: /
route:
- destination:
host: demoapp
subset: v11
- name: default
route:
- destination:
host: demoapp
subset: v10
创建virutalservice-demoapp
# kubectl apply -f virtualservice-demoapp.yaml
virtualservice.networking.istio.io/demoapp created
访问demoapp v10子集
root@client # while true;do curl proxy/hostname; sleep 0.5; done
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 6 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
- Took 5 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 8 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 4 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 5 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
- Took 4 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 6 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 4 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
- Took 3 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 4 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 16 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
- Took 5 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 9 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
- Took 6 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 7 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 5 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 3 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
- Took 5 milliseconds.
查看kiali
image image image image访问demoapp v11子集
root@client # while true;do curl proxy/canary; sleep 0.5; done
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 11 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 7 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 4 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-zzcpv, ServerIP: 172.20.44.249!
- Took 8 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 4 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-zzcpv, ServerIP: 172.20.44.249!
- Took 5 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 5 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 5 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 4 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-zzcpv, ServerIP: 172.20.44.249!
- Took 5 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 6 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-zzcpv, ServerIP: 172.20.44.249!
- Took 6 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-zzcpv, ServerIP: 172.20.44.249!
- Took 9 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 8 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-zzcpv, ServerIP: 172.20.44.249!
- Took 5 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 4 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 13 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
- Took 6 milliseconds.
查看kiali
image参考文档
https://istio.io/latest/zh/docs/reference/config/networking/destination-rule/#Subset
网友评论