Service Mesh之Istio部署bookinfo

给istio部署插件

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

root@k8s-master01:/usr/local# cd istio

root@k8s-master01:/usr/local/istio# ls samples/addons/

extras  grafana.yaml  jaeger.yaml  kiali.yaml  prometheus.yaml  README.md

root@k8s-master01:/usr/local/istio# kubectl apply -f samples/addons/

serviceaccount/grafana created

configmap/grafana created

service/grafana created

deployment.apps/grafana created

configmap/istio-grafana-dashboards created

configmap/istio-services-grafana-dashboards created

deployment.apps/jaeger created

service/tracing created

service/zipkin created

service/jaeger-collector created

serviceaccount/kiali created

configmap/kiali created

clusterrole.rbac.authorization.k8s.io/kiali-viewer created

clusterrole.rbac.authorization.k8s.io/kiali created

clusterrolebinding.rbac.authorization.k8s.io/kiali created

role.rbac.authorization.k8s.io/kiali-controlplane created

rolebinding.rbac.authorization.k8s.io/kiali-controlplane created

service/kiali created

deployment.apps/kiali created

serviceaccount/prometheus created

configmap/prometheus created

clusterrole.rbac.authorization.k8s.io/prometheus created

clusterrolebinding.rbac.authorization.k8s.io/prometheus created

service/prometheus created

deployment.apps/prometheus created

root@k8s-master01:/usr/local/istio#

  提示:istio插件的部署清单在istio/samples/addons/目录下,该目录下有grafana、jaeger、kiali、prometheus的部署清单;其中jaeger是负责链路追踪,kiali是istio的一个web客户端工具,我们可以在web页面来管控istio,prometheus是负责指标数据采集,grafana负责指标数据的展示工具;应用该目录下的所有部署清单后,对应istio-system名称空间下会跑相应的pod和相应的svc资源;

  验证:在istio-system名称空间下,查看对应pod是否正常跑起来了?对应svc资源是否创建?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

root@k8s-master01:/usr/local/istio# kubectl get pods -n istio-system

NAME                                   READY   STATUS    RESTARTS       AGE

grafana-69f9b6bfdc-cm966               1/1     Running   0              12m

istio-egressgateway-774d6846df-fv97t   1/1     Running   3 (144m ago)   22h

istio-ingressgateway-69499dc-pdgld     1/1     Running   3 (144m ago)   22h

istiod-65dcb8497-9skn9                 1/1     Running   3 (145m ago)   22h

jaeger-cc4688b98-wzfph                 1/1     Running   0              12m

kiali-594965b98c-kbllg                 1/1     Running   0              64s

prometheus-5f84bbfcfd-62nwc            2/2     Running   0              12m

root@k8s-master01:/usr/local/istio# kubectl get svc -n istio-system

NAME                   TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)                                                                      AGE

grafana                ClusterIP      10.107.10.186    <none>          3000/TCP                                                                     12m

istio-egressgateway    ClusterIP      10.106.179.126   <none>          80/TCP,443/TCP                                                               22h

istio-ingressgateway   LoadBalancer   10.102.211.120   192.168.0.252   15021:32639/TCP,80:31338/TCP,443:30597/TCP,31400:31714/TCP,15443:32154/TCP   22h

istiod                 ClusterIP      10.96.6.69       <none>          15010/TCP,15012/TCP,443/TCP,15014/TCP                                        22h

jaeger-collector       ClusterIP      10.100.138.187   <none>          14268/TCP,14250/TCP,9411/TCP                                                 12m

kiali                  ClusterIP      10.99.88.50      <none>          20001/TCP,9090/TCP                                                           12m

prometheus             ClusterIP      10.108.131.84    <none>          9090/TCP                                                                     12m

tracing                ClusterIP      10.100.53.36     <none>          80/TCP,16685/TCP                                                             12m

zipkin                 ClusterIP      10.110.231.233   <none>          9411/TCP                                                                     12m

root@k8s-master01:/usr/local/istio#

  提示:可以看到对应pod都在正常runing并处于ready状态;对应svc资源也都正常创建;我们要想访问对应服务,可以在集群内部访问对应的clusterIP来访问;也可以修改svc对应资源类型为nodeport或者loadbalancer类型;当然除了上述修改svc资源类型的方式实现集群外部访问之外,我们也可以通过istio的入口网关来访问;不过这种方式需要我们先通过配置文件告诉给istiod,让其把对应的服务通过ingressgate的外部IP地址暴露出来;

  这里说一下通过ingressgateway暴露服务的原理;我们在安装istio以后,对应会在k8s上创建一些crd资源,这些crd资源就是用来定义如何管控流量的;即我们通过定义这些crd类型的资源来告诉istiod,对应服务该如何暴露;只要我们在k8s集群上创建这些crd类型的资源以后,对应istiod就会将其收集起来,把对应资源转换为envoy的配置文件格式,再统一下发给通过istio注入的sidecar,以实现配置envoy的目的(envoy就是istio注入到应用pod中的sidecar);

  查看crd 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

root@k8s-master01:~# kubectl get crds

NAME                                                  CREATED AT

authorizationpolicies.security.istio.io               2023-04-02T16:28:24Z

bgpconfigurations.crd.projectcalico.org               2023-04-02T02:26:34Z

bgppeers.crd.projectcalico.org                        2023-04-02T02:26:34Z

blockaffinities.crd.projectcalico.org                 2023-04-02T02:26:34Z

caliconodestatuses.crd.projectcalico.org              2023-04-02T02:26:34Z

clusterinformations.crd.projectcalico.org             2023-04-02T02:26:34Z

destinationrules.networking.istio.io                  2023-04-02T16:28:24Z

envoyfilters.networking.istio.io                      2023-04-02T16:28:24Z

felixconfigurations.crd.projectcalico.org             2023-04-02T02:26:34Z

gateways.networking.istio.io                          2023-04-02T16:28:24Z

globalnetworkpolicies.crd.projectcalico.org           2023-04-02T02:26:34Z

globalnetworksets.crd.projectcalico.org               2023-04-02T02:26:34Z

hostendpoints.crd.projectcalico.org                   2023-04-02T02:26:34Z

ipamblocks.crd.projectcalico.org                      2023-04-02T02:26:34Z

ipamconfigs.crd.projectcalico.org                     2023-04-02T02:26:34Z

ipamhandles.crd.projectcalico.org                     2023-04-02T02:26:34Z

ippools.crd.projectcalico.org                         2023-04-02T02:26:34Z

ipreservations.crd.projectcalico.org                  2023-04-02T02:26:34Z

istiooperators.install.istio.io                       2023-04-02T16:28:24Z

kubecontrollersconfigurations.crd.projectcalico.org   2023-04-02T02:26:34Z

networkpolicies.crd.projectcalico.org                 2023-04-02T02:26:34Z

networksets.crd.projectcalico.org                     2023-04-02T02:26:34Z

peerauthentications.security.istio.io                 2023-04-02T16:28:24Z

proxyconfigs.networking.istio.io                      2023-04-02T16:28:24Z

requestauthentications.security.istio.io              2023-04-02T16:28:24Z

serviceentries.networking.istio.io                    2023-04-02T16:28:24Z

sidecars.networking.istio.io                          2023-04-02T16:28:24Z

telemetries.telemetry.istio.io                        2023-04-02T16:28:24Z

virtualservices.networking.istio.io                   2023-04-02T16:28:24Z

wasmplugins.extensions.istio.io                       2023-04-02T16:28:24Z

workloadentries.networking.istio.io                   2023-04-02T16:28:24Z

workloadgroups.networking.istio.io                    2023-04-02T16:28:24Z

root@k8s-master01:~# kubectl api-resources --api-group=networking.istio.io

NAME               SHORTNAMES   APIVERSION                     NAMESPACED   KIND

destinationrules   dr           networking.istio.io/v1beta1    true         DestinationRule

envoyfilters                    networking.istio.io/v1alpha3   true         EnvoyFilter

gateways           gw           networking.istio.io/v1beta1    true         Gateway

proxyconfigs                    networking.istio.io/v1beta1    true         ProxyConfig

serviceentries     se           networking.istio.io/v1beta1    true         ServiceEntry

sidecars                        networking.istio.io/v1beta1    true         Sidecar

virtualservices    vs           networking.istio.io/v1beta1    true         VirtualService

workloadentries    we           networking.istio.io/v1beta1    true         WorkloadEntry

workloadgroups     wg           networking.istio.io/v1beta1    true         WorkloadGroup

root@k8s-master01:~#

  提示:可以看到在networking.istio.io这个群组里面有很多crd资源类型;其中gateway就是来定义如何接入外部流量的;virtualservice就是来定义虚拟主机的(类似apache中的虚拟主机),destinationrules用于定义外部流量通过gateway进来以后,结合virtualservice路由,对应目标该如何承接对应流量的;我们在k8s集群上创建这些类型的crd资源以后,都会被istiod收集并由它负责将其转换为envoy识别的格式配置统一下发给整个网格内所有的envoy sidecar或istio-system名称空间下所有envoy pod;

  通过istio ingressgateway暴露kiali服务

  定义 kiali-gateway资源实现流量匹配

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

# cat kiali-gateway.yaml

apiVersion: networking.istio.io/v1beta1

kind: Gateway

metadata:

  name: kiali-gateway

  namespace: istio-system

spec:

  selector:

    app: istio-ingressgateway

  servers:

  - port:

      number: 80

      name: http-kiali

      protocol: HTTP

    hosts:

    "kiali.ik8s.cc"

  提示:该资源定义了通过istio-ingresstateway进来的流量,匹配主机头为kiali.ik8s.cc,协议为http,端口为80的流量;

  定义virtualservice资源实现路由

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

# cat kiali-virtualservice.yaml

apiVersion: networking.istio.io/v1beta1

kind: VirtualService

metadata:

  name: kiali-virtualservice

  namespace: istio-system

spec:

  hosts:

  "kiali.ik8s.cc"

  gateways:

  - kiali-gateway

  http:

  - match:

    - uri:

        prefix: /

    route:

    - destination:

        host: kiali

        port:

          number: 20001

  提示:该资源定义了gateway进来的流量匹配主机头为kiali.ik8s.cc,uri匹配“/”;就把对应流量路由至对应服务名为kiali的服务的20001端口进行响应;

  定义destinationrule实现如何承接对应流量

1

2

3

4

5

6

7

8

9

10

11

# cat kiali-destinationrule.yaml

apiVersion: networking.istio.io/v1beta1

kind: DestinationRule

metadata:

  name: kiali

  namespace: istio-system

spec:

  host: kiali

  trafficPolicy:

    tls:

      mode: DISABLE

  提示:该资源定义了对应承接非tls的流量;即关闭kiali服务的tls功能;

  应用上述配置清单

1

2

3

4

5

6

7

8

9

10

11

12

13

14

root@k8s-master01:~/istio-in-practise/Traffic-Management-Basics/kiali-port-80# kubectl apply -f .

destinationrule.networking.istio.io/kiali created

gateway.networking.istio.io/kiali-gateway created

virtualservice.networking.istio.io/kiali-virtualservice created

root@k8s-master01:~/istio-in-practise/Traffic-Management-Basics/kiali-port-80# kubectl get gw -n istio-system

NAME            AGE

kiali-gateway   27s

root@k8s-master01:~/istio-in-practise/Traffic-Management-Basics/kiali-port-80# kubectl get vs -n istio-system 

NAME                   GATEWAYS            HOSTS               AGE

kiali-virtualservice   ["kiali-gateway"]   ["kiali.ik8s.cc"]   33s

root@k8s-master01:~/istio-in-practise/Traffic-Management-Basics/kiali-port-80# kubectl get dr -n istio-system 

NAME    HOST    AGE

kiali   kiali   38s

root@k8s-master01:~/istio-in-practise/Traffic-Management-Basics/kiali-port-80#

  通过集群外部客户端的hosts文件将kiali.ik8s.cc解析至istio-ingressgateway外部地址

  提示:我这里是一台win11的客户端,修改C:\Windows\System32\drivers\etc\hosts文件来实现解析;

  测试,用浏览器访问kiali.ik8s.cc看看对应是否能够访问到kiali服务呢?

  提示:可以看到我们现在就把集群内部kiali服务通过gateway、virtualservice、destinationrule这三种资源的创建将其暴露给ingresgateway的外部地址上;对于其他服务我们也可以采用类似的逻辑将其暴露出来;这里建议kiali不要直接暴露给集群外部客户端访问,因为kiali没有认证,但它又具有管理istio的功能;

  部署bookinfo

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

root@k8s-master01:/usr/local/istio# kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml 

service/details created

serviceaccount/bookinfo-details created

deployment.apps/details-v1 created

service/ratings created

serviceaccount/bookinfo-ratings created

deployment.apps/ratings-v1 created

service/reviews created

serviceaccount/bookinfo-reviews created

deployment.apps/reviews-v1 created

deployment.apps/reviews-v2 created

deployment.apps/reviews-v3 created

service/productpage created

serviceaccount/bookinfo-productpage created

deployment.apps/productpage-v1 created

root@k8s-master01:/usr/local/istio#

  提示:我们安装istio以后,bookinfo的部署清单就在istio/samples/bookinfo/platform/kube/目录下;该部署清单会在default名称空间将bookinfo需要的pod运行起来,并创建相应的svc资源;

  验证:查看default名称空间下的pod和svc资源,看看对应pod和svc是否正常创建?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

root@k8s-master01:/usr/local/istio# kubectl get pods

NAME                             READY   STATUS    RESTARTS   AGE

details-v1-6997d94bb9-4jssp      2/2     Running   0          2m56s

productpage-v1-d4f8dfd97-z2pcz   2/2     Running   0          2m55s

ratings-v1-b8f8fcf49-j8l44       2/2     Running   0          2m56s

reviews-v1-5896f547f5-v2h92      2/2     Running   0          2m56s

reviews-v2-5d99885bc9-dhjdk      2/2     Running   0          2m55s

reviews-v3-589cb4d56c-rw6rw      2/2     Running   0          2m55s

root@k8s-master01:/usr/local/istio# kubectl get svc

NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE

details       ClusterIP   10.109.96.34    <none>        9080/TCP   3m2s

kubernetes    ClusterIP   10.96.0.1       <none>        443/TCP    38h

productpage   ClusterIP   10.101.76.112   <none>        9080/TCP   3m1s

ratings       ClusterIP   10.97.209.163   <none>        9080/TCP   3m2s

reviews       ClusterIP   10.108.1.117    <none>        9080/TCP   3m2s

root@k8s-master01:/usr/local/istio#

  提示:可以看到default名称空间下跑了几个pod,每个pod内部都有两个容器,其中一个是bookinfo程序的主容器,一个是istio注入的sidecar;bookinfo的访问入口是productpage;

  验证:查看istiod是否将配置下发给我们刚才部署的bookinfo中注入的sidecar配置?

1

2

3

4

5

6

7

8

9

10

11

root@k8s-master01:/usr/local/istio# istioctl ps

NAME                                                  CLUSTER        CDS        LDS        EDS        RDS          ECDS         ISTIOD                     VERSION

details-v1-6997d94bb9-4jssp.default                   Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-65dcb8497-9skn9     1.17.1

istio-egressgateway-774d6846df-fv97t.istio-system     Kubernetes     SYNCED     SYNCED     SYNCED     NOT SENT     NOT SENT     istiod-65dcb8497-9skn9     1.17.1

istio-ingressgateway-69499dc-pdgld.istio-system       Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-65dcb8497-9skn9     1.17.1

productpage-v1-d4f8dfd97-z2pcz.default                Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-65dcb8497-9skn9     1.17.1

ratings-v1-b8f8fcf49-j8l44.default                    Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-65dcb8497-9skn9     1.17.1

reviews-v1-5896f547f5-v2h92.default                   Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-65dcb8497-9skn9     1.17.1

reviews-v2-5d99885bc9-dhjdk.default                   Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-65dcb8497-9skn9     1.17.1

reviews-v3-589cb4d56c-rw6rw.default                   Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-65dcb8497-9skn9     1.17.1

root@k8s-master01:/usr/local/istio#

  提示:这里我们只需要关心cds、lds、eds、rds即可;显示synced表示对应配置已经下发;配置下发完成以后,对应服务就可以在集群内部访问了;

  验证:在集群内部部署一个客户端pod,访问productpage:9080看看对应bookinfo是否被访问到?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

root@k8s-master01:/usr/local/istio# kubectl apply -f samples/sleep/sleep.yaml

serviceaccount/sleep created

service/sleep created

deployment.apps/sleep created

root@k8s-master01:/usr/local/istio# kubectl get pods

NAME                             READY   STATUS    RESTARTS   AGE

details-v1-6997d94bb9-4jssp      2/2     Running   0          12m

productpage-v1-d4f8dfd97-z2pcz   2/2     Running   0          12m

ratings-v1-b8f8fcf49-j8l44       2/2     Running   0          12m

reviews-v1-5896f547f5-v2h92      2/2     Running   0          12m

reviews-v2-5d99885bc9-dhjdk      2/2     Running   0          12m

reviews-v3-589cb4d56c-rw6rw      2/2     Running   0          12m

sleep-bc9998558-vjc48            2/2     Running   0          50s

root@k8s-master01:/usr/local/istio#

  进入sleep pod,访问productpage:9080看看是否能访问?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

root@k8s-master01:/usr/local/istio# kubectl exec -it sleep-bc9998558-vjc48 -- /bin/sh

/ $ cd

~ $ curl productpage:9080

<!DOCTYPE html>

<html>

  <head>

    <title>Simple Bookstore App</title>

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Latest compiled and minified CSS -->

<link rel="stylesheet" href="static/bootstrap/css/bootstrap.min.css">

<!-- Optional theme -->

<link rel="stylesheet" href="static/bootstrap/css/bootstrap-theme.min.css">

  </head>

  <body>

     

     

<p>

    <h3>Hello! This is a simple bookstore application consisting of three services as shown below</h3>

</p>

<table class="table table-condensed table-bordered table-hover"><tr><th>name</th><td>http://details:9080</td></tr><tr><th>endpoint</th><td>details</td></tr><tr><th>children</th><td><table class="table table-condensed table-bordered table-hover"><tr><th>name</th><th>endpoint</th><th>children</th></tr><tr><td>http://details:9080</td><td>details</td><td></td></tr><tr><td>http://reviews:9080</td><td>reviews</td><td><table class="table table-condensed table-bordered table-hover"><tr><th>name</th><th>endpoint</th><th>children</th></tr><tr><td>http://ratings:9080</td><td>ratings</td><td></td></tr></table></td></tr></table></td></tr></table>

<p>

    <h4>Click on one of the links below to auto generate a request to the backend as a real user or a tester

    </h4>

</p>

<p><a href="/productpage?u=normal">Normal user</a></p>

<p><a href="/productpage?u=test">Test user</a></p>

     

<!-- Latest compiled and minified JavaScript -->

<script src="static/jquery.min.js"></script>

<!-- Latest compiled and minified JavaScript -->

<script src="static/bootstrap/js/bootstrap.min.js"></script>

  </body>

</html>

~ $

  提示:可以看到对应客户端pod能够正常访问productpage:9080;这里说一下我们在集群内部pod中用productpage来访问服务是可以正常被coredns解析到对应svc上进行响应的;

  暴露bookinfo给集群外部客户端访问

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

root@k8s-master01:~# cat /usr/local/istio/samples/bookinfo/networking/bookinfo-gateway.yaml

apiVersion: networking.istio.io/v1alpha3

kind: Gateway

metadata:

  name: bookinfo-gateway

spec:

  selector:

    istio: ingressgateway # use istio default controller

  servers:

  - port:

      number: 80

      name: http

      protocol: HTTP

    hosts:

    "*"

---

apiVersion: networking.istio.io/v1alpha3

kind: VirtualService

metadata:

  name: 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

root@k8s-master01:~#

  提示:该清单将bookinfo通过关联ingressgateway的外部地址的80端口关联,所以我们访问ingressgateway的外部地址就可以访问到bookinfo;

  应用清单

1

2

3

4

root@k8s-master01:~# kubectl apply -f /usr/local/istio/samples/bookinfo/networking/bookinfo-gateway.yaml

gateway.networking.istio.io/bookinfo-gateway created

virtualservice.networking.istio.io/bookinfo created

root@k8s-master01:~#

  验证:访问ingressgateway的外部地址,看看对应bookinfo是否能够被访问到?

  提示:可以看到现在我们在集群外部通过访问ingressgateway的外部地址就能正常访问到bookinfo,通过多次访问,还可以实现不同的效果;

  模拟客户端访问bookinfo

1

root@k8s-node03:~# while true ; do curl 192.168.0.252/productpage;sleep 0.$RANDOM;done

  在kiali上查看绘图

  提示:我们在kiali上看到的图形,就是通过模拟客户端访问流量所形成的图形;该图形能够形象的展示对应服务流量的top,以及动态显示对应流量访问应用的比例;我们可以通过定义配置文件的方式,动态调整客户端能够访问到bookinfo那个版本;对应绘图也会通过采集到的指标数据动态将流量路径绘制出来;

  通过bookinfo测试流量治理功能

  创建destinationrule

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

root@k8s-master01:/usr/local/istio# cat samples/bookinfo/networking/destination-rule-all.yaml

apiVersion: networking.istio.io/v1alpha3

kind: DestinationRule

metadata:

  name: productpage

spec:

  host: productpage

  subsets:

  - name: v1

    labels:

      version: v1

---

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

---

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

---

apiVersion: networking.istio.io/v1alpha3

kind: DestinationRule

metadata:

  name: details

spec:

  host: details

  subsets:

  - name: v1

    labels:

      version: v1

  - name: v2

    labels:

      version: v2

---

root@k8s-master01:/usr/local/istio#

  提示:上述清单主要定义了不同版本对应的服务的版本;

  应用清单

1

2

3

4

5

6

root@k8s-master01:/usr/local/istio# kubectl apply -f samples/bookinfo/networking/destination-rule-all.yaml

destinationrule.networking.istio.io/productpage created

destinationrule.networking.istio.io/reviews created

destinationrule.networking.istio.io/ratings created

destinationrule.networking.istio.io/details created

root@k8s-master01:/usr/local/istio#

  将所有流量路由至v1版本

1

2

3

4

5

6

root@k8s-master01:/usr/local/istio# kubectl apply -f samples/bookinfo/networking/virtual-service-all-v1.yaml

virtualservice.networking.istio.io/productpage created

virtualservice.networking.istio.io/reviews created

virtualservice.networking.istio.io/ratings created

virtualservice.networking.istio.io/details created

root@k8s-master01:/usr/local/istio#

  验证:在kiali上查看对应流量是否只有v1版本了?

  提示:可以看到现在kiali绘制的图里面就只有v1版本的流量,其他v2,v3版本流量就没有了;

  通过客户端登陆身份标识来路由

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

root@k8s-master01:/usr/local/istio# cat samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml

apiVersion: networking.istio.io/v1alpha3

kind: VirtualService

metadata:

  name: reviews

spec:

  hosts:

    - reviews

  http:

  - match:

    - headers:

        end-user:

          exact: jason

    route:

    - destination:

        host: reviews

        subset: v2

  - route:

    - destination:

        host: reviews

        subset: v1

root@k8s-master01:/usr/local/istio#

  提示:上述清单定义了,登录用户名为jason,就响应v2版本;其他未登录的客户端还是以v1版本响应;

  验证:应用配置清单,登录jason,看看是否是以v2版本响应?

  提示:可以看到我们应用了配置清单以后,对应模拟客户端访问的还是一直以v1的版本响应;我们登录jason用户以后,对应响应给我们的页面就是v2版本,退出jason用户又是以v1版本响应;

  以上就是bookinfo在istio服务网格中,通过定义不同的配置,实现高级流量治理的效果; 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/50052.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

个人博客系统 -- 博客列表页删除Markdown字符

之前的博客系统的列表页会有在markdown编辑器中的特殊字符,比如标题的字符#之类的,在列表页进行展示的时候,我们需要将这些字符进行筛选. 对这些字符进行筛选,我们可以通过排设计正则表达式进行筛选,也可以使用组件的方式进行筛选.下面我来总结一下,使用组件的方式进行筛选. 这…

rcu链表综合实践

基础知识 rcu-read copy update的缩写。和读写锁起到相同的效果。据说牛逼一点。对于我们普通程序员&#xff0c;要先学会使用&#xff0c;再探究其内部原理。 链表的数据结构&#xff1a; struct list_head {struct list_head *next, *prev; };还有一种&#xff1a;struct h…

Codeforces Round 888 (Div. 3)(视频讲解全部题目)

[TOC](Codeforces Round 888 (Div. 3)&#xff08;视频讲解全部题目&#xff09;) Codeforces Round 888 (Div. 3)&#xff08;A–G&#xff09;全部题目详解 A Escalator Conversations #include<bits/stdc.h> #define endl \n #define INF 0x3f3f3f3f using namesp…

第四章 网络层

第四章 网络层 4.1 网络层提供的两种服务 ​ 网络层关注的是如何将分组从源端沿着网络路径送达目的端。在计算机领域&#xff0c;网络层应该向运输层提供怎样的服务&#xff08;“面向连接”还是“无连接”&#xff09;曾引起长期的争论。争论的实质就是&#xff1a;在计算机通…

flex盒子 center排布,有滚动条时,拖动滚动条无法完整显示内容

文章目录 问题示例代码解决问题改进后的效果 问题 最近在开发项目的过程中&#xff0c;发现了一个有趣的事情&#xff0c;与flex盒子有关&#xff0c;不知道算不算是一个bug&#xff0c;不过对于开发者来说&#xff0c;确实有些不方便&#xff0c;感兴趣的同学不妨也去试试。 …

ShardingSphere-Proxy绑定表与广播表详解与实战

&#x1f680; ShardingSphere &#x1f680; &#x1f332; 算法刷题专栏 | 面试必备算法 | 面试高频算法 &#x1f340; &#x1f332; 越难的东西,越要努力坚持&#xff0c;因为它具有很高的价值&#xff0c;算法就是这样✨ &#x1f332; 作者简介&#xff1a;硕风和炜&…

A Deep Framework for Hyperspectral Image Fusion Between Different Satellites

1.摘要 最近&#xff0c;将低分辨率高光谱图像&#xff08;LR-HSI&#xff09;与不同卫星的高分辨率多光谱图像&#xff08;HR-MSI&#xff09;融合已成为提高HSI分辨率的有效方法。然而&#xff0c;由于不同的成像卫星、不同的照明条件和相邻的成像时间&#xff0c;LR-HSI和H…

iOS开发-下拉刷新动画loading旋转指示器动画效果

iOS开发-下拉刷新动画loading旋转指示器动画效果 之前开发中实现下拉刷新动画loading旋转指示器动画效果 一、效果图 二、基础动画 CABasicAnimation类的使用方式就是基本的关键帧动画。 所谓关键帧动画&#xff0c;就是将Layer的属性作为KeyPath来注册&#xff0c;指定动画…

会议OA项目之权限管理个人中心(修改个人信息,选择本地图片进行头像修改)

&#x1f973;&#x1f973;Welcome Huihuis Code World ! !&#x1f973;&#x1f973; 接下来看看由辉辉所写的关于OA项目的相关操作吧 数据表及分析 表数据 表分析 所谓的权限管理就是不同的人管理不同的事&#xff0c;拥有着管理不同事情的不同权力。那么第一张表--权限表&…

docker 搭建jenkins

1、拉取镜像 docker pull jenkins/jenkins:2.4162、创建文件夹 mkdir -p /home/jenkins_mount chmod 777 /home/jenkins_mount3、运行并构建容器 docker run --restartalways -d -p 10240:8080 -p 10241:50000 -v /home/jenkins_mount:/var/jenkins_home -v /etc/localtime:…

Java 注解

对于注解 Annotation 是从 Java 1.5 开始加入&#xff0c;对于 Java 17 来说&#xff0c;主要是来自模块 java.base 下的包java.lang.annotation。该包提供了 Java 编程语言注解的类库支持。 在没有注解之前&#xff0c; Java 中大量的使用了 XML 配置文件的方式&#xff0c; …

【C#】.Net Framework框架下的Authorize权限类

2023年&#xff0c;第31周&#xff0c;第3篇文章。给自己一个目标&#xff0c;然后坚持总会有收货&#xff0c;不信你试试&#xff01; 在C#的.NET Framework中&#xff0c;你可以使用Authorize类来处理权限认证。Authorize类位于System.Web.Mvc命名空间中&#xff0c;它提供了…

JVM | 基于类加载的一次完全实践

引言 我在上篇文章&#xff1a;JVM | 类加载是怎么工作的 中为你介绍了Java的类加载器及其工作原理。我们简单回顾下&#xff1a;我用一个易于理解的类比带你逐步理解了类加载的流程和主要角色&#xff1a;引导类加载器&#xff0c;扩展类加载器和应用类加载器。并带你深入了解…

苍穹外卖-day09

苍穹外卖-day09 本项目学自黑马程序员的《苍穹外卖》项目&#xff0c;是瑞吉外卖的Plus版本 功能更多&#xff0c;更加丰富。 结合资料&#xff0c;和自己对学习过程中的一些看法和问题解决情况上传课件笔记 视频&#xff1a;https://www.bilibili.com/video/BV1TP411v7v6/?sp…

优化企业集成架构:iPaaS集成平台助力数字化转型

前言 在数字化时代全面来临之际&#xff0c;企业正面临着前所未有的挑战与机遇。技术的迅猛发展与数字化转型正在彻底颠覆各行各业的格局&#xff0c;不断推动着企业迈向新的前程。然而&#xff0c;这一数字化时代亦衍生出一系列复杂而深奥的难题&#xff1a;各异系统之间数据…

山水TW91耳机恢复出厂设置

当出现左右耳不互联或者设备无法配对时&#xff0c;可按照以下操作进行重置&#xff1a; ①先在手机端删除“SANSUI”耳机的配对信息。 ②耳机开机未连接状态下&#xff0c;连击4次左/右耳功能键后复位&#xff0c;耳机自动关机清除配对。&#xff08;提示已关机表示操作正确&a…

如何快速用Go获取短信验证码

要用Go获取短信验证码&#xff0c;通常需要连接到一个短信服务提供商的API&#xff0c;并通过该API发送请求来获取验证码。由于不同的短信服务提供商可能具有不同的API和授权方式&#xff0c;我将以一个简单的示例介绍如何使用Go语言来获取短信验证码。 在这个示例中&#xff0…

使用 OpenCV 和 GrabCut 算法进行交互式背景去除

一、说明 我想&#xff0c;任何人都可以尝试从图像中删除背景。当然&#xff0c;有大量可用的软件或工具能够做到这一点&#xff0c;但其中一些可能很昂贵。但是&#xff0c;我知道有人使用窗口绘画3D魔术选择或PowerPoint背景去除来删除背景。 如果您是计算机视觉领域的初学者…

C#时间轴曲线图形编辑器开发1-基本功能

目录 一、前言 1、简介 2、开发过程 3、工程下载链接 二、基本功能实现 1、绘图面板创建 &#xff08;1&#xff09;界面布置 &#xff08;2&#xff09;显示面板代码 &#xff08;3&#xff09; 面板水平方向、竖直方向移动功能实现 &#xff08;4&#xff09;面板放…

2024届IC秋招兆易创新数字IC后端笔试面试题

数字IC后端实现PR阶段设计导入需要哪些文件&#xff1f; 设计导入需要的文件如下图所示。这个必须熟练掌握。只要做过后端训练营项目的&#xff0c;对这个肯定是比较熟悉的。大家还要知道每个input文件的作用是什么。 在吾爱IC后端训练营Cortexa7core项目中&#xff0c;你认为…
最新文章