ISTIO bookinfo instance (fixed version, matching redirection)
Understanding of istio dr and vs types.
The dr type specifies how other services come in.
The vs type specifies how the service goes out.
For better learning istio, you can do all the examples in the official task and understand it.
Address: http://docs.istio.cn/docs/tasks/traffic-management/
The final result:
all visits will go from the productpage to the v3 version of eviews to ratigs.
Access will always be this interface.
kiali check the situation
achieve
istio installation view the previous article
1. Deploy the bookinfo instance.
kubectl apply -f istio-1.6.14/samples/bookinfo/platform/kube/bookinfo.yaml
# 验证
[root@ops kube]# kubectl get pod,svc
NAME READY STATUS RESTARTS AGE
pod/details-v1-745545f7d-c7q82 2/2 Running 0 7h12m
pod/productpage-v1-58bfbc7c64-lqrqw 2/2 Running 0 7h12m
pod/ratings-v1-649f84d76c-f89f2 2/2 Running 0 5h33m
pod/reviews-v1-57b655849b-x7xdd 2/2 Running 0 7h12m
pod/reviews-v2-685867965b-cjvll 2/2 Running 0 7h12m
pod/reviews-v3-5d6778fd88-j58vr 2/2 Running 0 7h12m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/details ClusterIP 10.97.248.228 <none> 9080/TCP 7h12m
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 121d
service/productpage ClusterIP 10.97.215.247 <none> 9080/TCP 7h12m
service/ratings ClusterIP 10.101.178.164 <none> 9080/TCP 7h12m
service/reviews ClusterIP 10.111.37.79 <none> 9080/TCP 7h12m
2. Create Gateway rules
kubectl apply -f istio-1.6.14/samples/bookinfo/networking/bookinfo-gateway.yaml
# 验证
[root@ops]# kubectl get gateway
NAME AGE
bookinfo-gateway 179m
3. Execute the DestinationRule rules of details and reviews
kubectl apply -f istio-1.6.14/samples/bookinfo/networking/destination-rule-ratings.yaml
kubectl apply -f istio-1.6.14/samples/bookinfo/networking/destination-rule-reviews.yaml
[root@ops networking]# cat destination-rule-reviews.yaml
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: reviews
spec:
host: reviews
trafficPolicy:
loadBalancer:
simple: RANDOM
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
- name: v3
labels:
version: v3
# 验证
[root@ops-jenkins-nexus-ansible networking]# kubectl get dr
NAME HOST AGE
ratings ratings 176m
reviews reviews 176m
4. Create VirtualService rules for details, reviews, and ratings
details Rule writing
# 做了一个uri重定向。把details链接重定向为reviews 然后再把流量直接转到reviews v3的版本上。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: details
spec:
hosts:
- details
http:
- match:
- uri:
prefix: /details/
rewrite:
uri: /reviews/
route:
- destination:
host: reviews
subset: v3
Reviews rules writing
# 进入流量都进入到v3版本
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v3
Rating rules writing
# 可以这写这个,但为了加深印象也直接制定为固定地址。
# 进入流量都进入到v1版本
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings
spec:
hosts:
- ratings
http:
- route:
- destination:
host: ratings
subset: v1
verification
[root@ops networking]# kubectl get vs
NAME GATEWAYS HOSTS AGE
bookinfo [bookinfo-gateway] [*] 3h7m
details [details] 151m
ratings [ratings] 177m
reviews [reviews] 178m
5. Verification
After all the rules are created as shown below:
Access:
IP: port/productpage
Example:
http://192.168.4.4:11499/productpage
4.4 is the node host, 11499 is the istio-ingressgateway 80 nodeport port