首页 > 其他分享 >istio部署demoapp多版本应用示例

istio部署demoapp多版本应用示例

时间:2022-10-25 15:15:12浏览次数:61  
标签:示例 ServerName Took value istio demoapp milliseconds

环境说明

  • frontend(proxy):前端应用,会请求后端的demoapp

    • service: proxy

  • demoapp:后端应用

    • 同时部署两个版本

 

部署demoappv1.0

deploy-demoapp-v10.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: demoappv10
    version: v1.0
  name: demoappv10
spec:
  replicas: 2
  selector:
    matchLabels:
      app: demoapp
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: demoapp
        version: v1.0
    spec:
      containers:
      - image: ikubernetes/demoapp:v1.0
        name: demoapp
        env:
        - name: PORT
          value: "8080"
        resources: {}

service-demoapp-v10.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    app: demoappv10
  name: demoappv10
spec:
  ports:
  - name: http-8080
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: demoapp
    version: v1.0
  type: ClusterIP

创建demoappv10资源

# kubectl apply -f deploy-demoapp-v10.yaml -f service-demoapp-v10.yaml 
deployment.apps/demoappv10 created
service/demoappv10 created

查看demoappv10 pod 

~# kubectl get pod --show-labels 
NAME                          READY   STATUS    RESTARTS   AGE   LABELS
demoappv10-78b6586d58-css28   2/2     Running   0          55s   app=demoapp,pod-template-hash=78b6586d58,security.istio.io/tlsMode=istio,service.istio.io/canonical-name=demoapp,service.istio.io/canonical-revision=v1.0,version=v1.0
demoappv10-78b6586d58-jmbwx   2/2     Running   0          55s   app=demoapp,pod-template-hash=78b6586d58,security.istio.io/tlsMode=istio,service.istio.io/canonical-name=demoapp,service.istio.io/canonical-revision=v1.0,version=v1.0

部署demoappv1.1

deploy-demoapp-v11.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: demoappv11
    version: v1.1
  name: demoappv11
spec:
  progressDeadlineSeconds: 600
  replicas: 2
  selector:
    matchLabels:
      app: demoapp
      version: v1.1
  template:
    metadata:
      labels:
        app: demoapp
        version: v1.1
    spec:
      containers:
      - image: ikubernetes/demoapp:v1.1
        imagePullPolicy: IfNotPresent
        name: demoapp
        env:
        - name: "PORT"
          value: "8080"
        ports:
        - containerPort: 8080
          name: web
          protocol: TCP
        resources:
          limits:
            cpu: 50m

service-demoapp-v11.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    app: demoappv11
  name: demoappv11
spec:
  ports:
    - name: http-8080
      port: 8080
      protocol: TCP
      targetPort: 8080
  selector:
    app: demoapp
    version: v1.1
  type: ClusterIP

创建demoappv11资源

# kubectl apply -f deploy-demoapp-v11.yaml -f service-demoapp-v11.yaml 
deployment.apps/demoappv11 created
service/demoappv11 created

查看demoappv11 pod

~# kubectl get pod --show-labels 
NAME                          READY   STATUS    RESTARTS   AGE    LABELS
demoappv10-78b6586d58-css28   2/2     Running   0          6m6s   app=demoapp,pod-template-hash=78b6586d58,security.istio.io/tlsMode=istio,service.istio.io/canonical-name=demoapp,service.istio.io/canonical-revision=v1.0,version=v1.0
demoappv10-78b6586d58-jmbwx   2/2     Running   0          6m6s   app=demoapp,pod-template-hash=78b6586d58,security.istio.io/tlsMode=istio,service.istio.io/canonical-name=demoapp,service.istio.io/canonical-revision=v1.0,version=v1.0
demoappv11-78bf898c74-l7sqg   2/2     Running   0          39s    app=demoapp,pod-template-hash=78bf898c74,security.istio.io/tlsMode=istio,service.istio.io/canonical-name=demoapp,service.istio.io/canonical-revision=v1.1,version=v1.1
demoappv11-78bf898c74-x5ccw   2/2     Running   0          39s    app=demoapp,pod-template-hash=78bf898c74,security.istio.io/tlsMode=istio,service.istio.io/canonical-name=demoapp,service.istio.io/canonical-revision=v1.1,version=v1.1

部署demoapp svc

service-demoapp.yaml

---
apiVersion: v1
kind: Service
metadata:
  name: demoapp
spec:
  ports:
    - name: http
      port: 8080
      protocol: TCP
      targetPort: 8080
  selector:
    app: demoapp
  type: ClusterIP
---

创建service-demoapp资源

# kubectl apply -f service-demoapp.yaml 
service/demoapp created

查看service-demoapp svc

~# kubectl get svc -o wide
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE     SELECTOR
demoapp      ClusterIP   10.100.193.250   <none>        8080/TCP   31s     app=demoapp
demoappv10   ClusterIP   10.100.16.210    <none>        8080/TCP   8m54s   app=demoapp,version=v1.0
demoappv11   ClusterIP   10.100.200.213   <none>        8080/TCP   3m28s   app=demoapp,version=v1.1

部署proxy

deploy-proxy.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: proxy
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  selector:
    matchLabels:
      app: proxy
  template:
    metadata:
      labels:
        app: proxy
    spec:
      containers:
        - env:
          - name: PROXYURL
            value: http://demoapp:8080
          image: ikubernetes/proxy:v0.1.1
          imagePullPolicy: IfNotPresent
          name: proxy
          ports:
            - containerPort: 8080
              name: web
              protocol: TCP
          resources:
            limits:
              cpu: 50m
---
apiVersion: v1
kind: Service
metadata:
  name: proxy
spec:
  ports:
    - name: http-80
      port: 80
      protocol: TCP
      targetPort: 8080
  selector:
    app: proxy
---

创建proxy资源

# kubectl apply -f deploy-proxy.yaml 
deployment.apps/proxy created
service/proxy created

查看proxy svc

~# kubectl get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
demoapp      ClusterIP   10.100.180.239   <none>        8080/TCP   35s
demoappv10   ClusterIP   10.100.174.88    <none>        8080/TCP   3m46s
demoappv11   ClusterIP   10.100.2.161     <none>        8080/TCP   76s
proxy        ClusterIP   10.100.43.186    <none>        80/TCP     15s

测试访问demoapp

创建client

~# kubectl run client --image=ikubernetes/admin-box -it --rm --restart=Never --command -- /bin/sh
If you don't see a command prompt, try pressing enter.
root@client # 

访问应用

root@client # while true;do curl proxy/hostname; sleep 0.5; done
Proxying value: ServerName: demoappv11-78bf898c74-x5ccw
 - Took 377 milliseconds.
Proxying value: ServerName: demoappv11-78bf898c74-l7sqg
 - Took 25 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
 - Took 51 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
 - Took 30 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
 - Took 7 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
 - Took 16 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
 - Took 6 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
 - Took 5 milliseconds.

访问kiali

 

自定义route

查看demoapp routes

~# istioctl proxy-config routes demoappv11-78bf898c74-sn9qp
NAME                                                                      DOMAINS                                               MATCH                  VIRTUAL SERVICE
80                                                                        istio-egressgateway.istio-system, 10.100.121.95       /*                     
80                                                                        istio-ingressgateway.istio-system, 10.100.145.112     /*                     
80                                                                        proxy, proxy.default + 1 more...                      /*                     
80                                                                        tracing.istio-system, 10.100.92.199                   /*                     
8080                                                                      demoapp, demoapp.default + 1 more...                  /*                     
8080                                                                      demoappv10, demoappv10.default + 1 more...            /*                     
8080                                                                      demoappv11, demoappv11.default + 1 more...            /*                     
9090                                                                      kiali.istio-system, 10.100.48.203                     /*                     
9090                                                                      prometheus.istio-system, 10.100.42.102                /*                     
9411                                                                      jaeger-collector.istio-system, 10.100.122.235         /*                     
9411                                                                      zipkin.istio-system, 10.100.29.132                    /*                     
15010                                                                     istiod.istio-system, 10.100.149.76                    /*                     
15014                                                                     istiod.istio-system, 10.100.149.76                    /*                     
16685                                                                     tracing.istio-system, 10.100.92.199                   /*                     
20001                                                                     kiali.istio-system, 10.100.48.203                     /*                     
istio-ingressgateway.istio-system.svc.cluster.local:15021                 *                                                     /*                     
jaeger-collector.istio-system.svc.cluster.local:14268                     *                                                     /*                     
kube-dns.kube-system.svc.cluster.local:9153                               *                                                     /*                     
kubernetes-dashboard.kubernetes-dashboard.svc.cluster.local:443           *                                                     /*                     
grafana.istio-system.svc.cluster.local:3000                               *                                                     /*                     
dashboard-metrics-scraper.kubernetes-dashboard.svc.cluster.local:8000     *                                                     /*                     
jaeger-collector.istio-system.svc.cluster.local:14250                     *                                                     /*                     
inbound|8080||                                                            *                                                     /*                     
InboundPassthroughClusterIpv4                                             *                                                     /*                     
                                                                          *                                                     /healthz/ready*        
                                                                          *                                                     /stats/prometheus*     
inbound|8080||                                                            *                                                     /*                     
InboundPassthroughClusterIpv4                                             *                                                     /*                     

virutalservice-demoapp.yaml

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: demoappv11
  - name: default
    route:
    - destination:
        host: demoappv10

创建资源

# kubectl apply -f virutalservice-demoapp.yaml 
virtualservice.networking.istio.io/demoapp created

查看vs资源

~# kubectl get vs 
NAME      GATEWAYS   HOSTS         AGE
demoapp              ["demoapp"]   52s

查看demoapp pod路由

~# istioctl proxy-config routes demoappv11-78bf898c74-sn9qp
NAME                                                                      DOMAINS                                               MATCH                  VIRTUAL SERVICE
80                                                                        demoapp.default.svc.cluster.local                     /canary*               demoapp.default
80                                                                        demoapp.default.svc.cluster.local                     /*                     demoapp.default
80                                                                        istio-egressgateway.istio-system, 10.100.121.95       /*                     
80                                                                        istio-ingressgateway.istio-system, 10.100.145.112     /*                     
80                                                                        proxy, proxy.default + 1 more...                      /*                     
80                                                                        tracing.istio-system, 10.100.92.199                   /*                     
8080                                                                      demoapp, demoapp.default + 1 more...                  /canary*               demoapp.default
8080                                                                      demoapp, demoapp.default + 1 more...                  /*                     demoapp.default
8080                                                                      demoappv10, demoappv10.default + 1 more...            /*                     
8080                                                                      demoappv11, demoappv11.default + 1 more...            /*                     
9090                                                                      kiali.istio-system, 10.100.48.203                     /*                     
9090                                                                      prometheus.istio-system, 10.100.42.102                /*                     
9411                                                                      jaeger-collector.istio-system, 10.100.122.235         /*                     
9411                                                                      zipkin.istio-system, 10.100.29.132                    /*                     
15010                                                                     istiod.istio-system, 10.100.149.76                    /*                     
15014                                                                     istiod.istio-system, 10.100.149.76                    /*                     
16685                                                                     tracing.istio-system, 10.100.92.199                   /*                     
20001                                                                     kiali.istio-system, 10.100.48.203                     /*                     
istio-ingressgateway.istio-system.svc.cluster.local:15021                 *                                                     /*                     
jaeger-collector.istio-system.svc.cluster.local:14268                     *                                                     /*                     
kube-dns.kube-system.svc.cluster.local:9153                               *                                                     /*                     
kubernetes-dashboard.kubernetes-dashboard.svc.cluster.local:443           *                                                     /*                     
grafana.istio-system.svc.cluster.local:3000                               *                                                     /*                     
dashboard-metrics-scraper.kubernetes-dashboard.svc.cluster.local:8000     *                                                     /*                     
jaeger-collector.istio-system.svc.cluster.local:14250                     *                                                     /*                     
inbound|8080||                                                            *                                                     /*                     
InboundPassthroughClusterIpv4                                             *                                                     /*                     
                                                                          *                                                     /healthz/ready*        
                                                                          *                                                     /stats/prometheus*     
inbound|8080||                                                            *                                                     /*                     
InboundPassthroughClusterIpv4                                             *                                                     /*                     

访问demoapp

访问defalut

root@client # while true;do curl proxy/hostname; sleep 0.5; done
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
 - Took 32 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
 - Took 14 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
 - Took 4 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
 - Took 5 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
 - Took 10 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
 - Took 5 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-css28
 - Took 5 milliseconds.
Proxying value: ServerName: demoappv10-78b6586d58-jmbwx
 - Took 5 milliseconds.

查看kiali

 

访问canary

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-zzcpv, ServerIP: 172.20.44.249!
 - Took 46 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-zzcpv, ServerIP: 172.20.44.249!
 - Took 18 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-n88v6, ServerIP: 172.20.154.237!
 - Took 38 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-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 12 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-zzcpv, ServerIP: 172.20.44.249!
 - Took 7 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-zzcpv, ServerIP: 172.20.44.249!
 - Took 5 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-zzcpv, ServerIP: 172.20.44.249!
 - Took 4 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-zzcpv, ServerIP: 172.20.44.249!
 - Took 10 milliseconds.

查看kiali

自定义子集

destinationrule-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

删除virutalservice-demoapp

# kubectl delete -f virutalservice-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

创建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

virutalservice-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 virutalservice-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

访问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

Ingress-gateway暴露demoapp

proxy-gateway.yaml

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: proxy-gateway
  namespace: istio-system
spec:
  selector:
    app: istio-ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "app.wgs.com"
---

virutalservice-demoapp.yaml

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: proxy
spec:
  hosts:
  - "app.wgs.com"                 # 对应于gateways/proxy-gateway
  gateways:
  - istio-system/proxy-gateway    # 相关定义仅应用于Ingress Gateway上
  # - mesh                        # 启用该列表项,意味着该VS同时应用于各Sidecar上
  http:
  - name: default
    route:
    - destination:
        host: proxy

创建资源

# kubectl apply -f proxy-gateway.yaml -f proxy-virutalservice-proxy.yaml 
gateway.networking.istio.io/proxy-gateway created
virtualservice.networking.istio.io/proxy created

查看Istio-ingress-gateway svc EXTERNAL-IP

~# kubectl get svc -n istio-system 
NAME                   TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)                                                                      AGE
grafana                ClusterIP      10.100.124.243   <none>            3000/TCP                                                                     4d19h
istio-egressgateway    ClusterIP      10.100.121.95    <none>            80/TCP,443/TCP                                                               4d19h
istio-ingressgateway   LoadBalancer   10.100.145.112   192.168.174.250   15021:32417/TCP,80:46683/TCP,443:37652/TCP,31400:59146/TCP,15443:30622/TCP   4d19h
istiod                 ClusterIP      10.100.149.76    <none>            15010/TCP,15012/TCP,443/TCP,15014/TCP                                        4d19h
jaeger-collector       ClusterIP      10.100.122.235   <none>            14268/TCP,14250/TCP,9411/TCP                                                 4d19h
kiali                  ClusterIP      10.100.48.203    <none>            20001/TCP,9090/TCP                                                           4d19h
prometheus             ClusterIP      10.100.42.102    <none>            9090/TCP                                                                     4d19h
tracing                ClusterIP      10.100.92.199    <none>            80/TCP,16685/TCP                                                             4d19h
zipkin                 ClusterIP      10.100.29.132    <none>            9411/TCP                                                                     4d19h

添加域名解析

192.168.174.250  app.wgs.com

访问v10子集

~# while true;do curl app.wgs.com; sleep 0.5; done
Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-kdv4m, ServerIP: 172.20.154.244!
 - Took 7 milliseconds.
Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-hq957, ServerIP: 172.20.44.255!
 - Took 7 milliseconds.
Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-kdv4m, ServerIP: 172.20.154.244!
 - Took 4 milliseconds.
Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-hq957, ServerIP: 172.20.44.255!
 - Took 7 milliseconds.
Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-kdv4m, ServerIP: 172.20.154.244!
 - Took 9 milliseconds.
Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-hq957, ServerIP: 172.20.44.255!
 - Took 5 milliseconds.

查看kiali

访问v11子集

~# while true;do curl app.wgs.com/canary; sleep 0.5; done
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
 - Took 7 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
 - Took 5 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
 - Took 4 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
 - Took 4 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
 - Took 11 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-hckjf, ServerIP: 172.20.89.184!
 - Took 6 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-hckjf, ServerIP: 172.20.89.184!
 - Took 7 milliseconds.
Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
 - Took 4 milliseconds.

查看kiali

标签:示例,ServerName,Took,value,istio,demoapp,milliseconds
From: https://www.cnblogs.com/wangguishe/p/16821332.html

相关文章

  • 华科云商golang详细示例代码
    packagemainimport("net/url""net/http""bytes""fmt""io/ioutil")constProxyServer="ip.hahado.cn:39......
  • 国网B接口资源上报(Push_Resourse)接口描述和消息示例
    上篇blog,梳理了国网B接口的REGISTER接口描述和消息示例,前端系统加电启动并初次注册成功后,向平台上报前端系统的设备资源信息(包括:视频服务器、DVR/DVS、摄像机、告警设备、环......
  • 【转】VUE 组件注册使用示例
    首先是main.jsimport{createApp}from'vue'importAppfrom'./App.vue'import'./index.css'importSwiperfrom'./components/01.globalReg/Swiper.vue'imp......
  • golang隧道模式示例
    packagemainimport("net/url""net/http""bytes""fmt""io/ioutil")constProxyServer="ip.hahado.cn:3......
  • golang隧道模式代码示例
    packagemainimport("net/url""net/http""bytes""fmt""io/ioutil")constProxyServer="ip.hahado.cn:39010"typeProxyAuthstruct{LicensestringSecretKe......
  • Sequence Flow示例
    准备实践环境[root@master~]#knservicecreatesq-appender-01--imageikubernetes/appender--envMESSAGE="-HandledbySQ-01"Creatingservice'sq-appender-0......
  • istio部署后端单版本应用示例
    环境说明frontend(proxy):前端应用,会请求后端的demoappservice:proxydemoapp:后端应用service:demoappv10访问流程clientpod--->(EgressListener......
  • Istio流量治理基础
    流量治理Istio的流量路由规则使运维人员可以轻松控制服务之间的流量和API调用Istio简化了诸如断路器,超时和重试之类的服务级别属性的配置,并使其易于设置重要任务(A/B测......
  • 大厂Istio基础与实践 云原生“薪”能力合集,一线大厂实战
    大厂Istio基础与实践云原生“薪”能力合集,一线大厂实战导言:上一篇章给大家介绍了服务治理方案ServiceMesh(服务网格)产生的背景、逻辑架构、应用场景。本篇将要介绍的......
  • java -jar 的脚本示例
    #!/bin/bash#chkconfig:23458090#date:2022年3月21日#启动第一个jar包PID=$(ps-ef|grepruoyi-monitor-admin.jar|grep-vgrep|awk'{print$2}')if[......