首页 > 其他分享 >istio部署demoapp应用 (十四)sidecar

istio部署demoapp应用 (十四)sidecar

时间:2022-10-31 16:59:41浏览次数:59  
标签:10.100 0.0 istio demoapp client io sidecar

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

查看pod

# kubectl get pod --show-labels 
NAME                          READY   STATUS    RESTARTS   AGE   LABELS
client                        2/2     Running   0          30s   run=client,security.istio.io/tlsMode=istio,service.istio.io/canonical-name=client,service.istio.io/canonical-revision=latest
demoappv10-78b6586d58-7jm25   2/2     Running   0          30m   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-jmjrs   2/2     Running   0          30m   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-5r78m   2/2     Running   0          30m   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-f6xzm   2/2     Running   0          30m   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
proxy-649b4d887d-g6bnm        2/2     Running   0          28m   app=proxy,pod-template-hash=649b4d887d,security.istio.io/tlsMode=istio,service.istio.io/canonical-name=proxy,service.istio.io/canonical-revision=latest

查看svc

~# kubectl get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
demoapp      ClusterIP   10.100.127.199   <none>        8080/TCP   46m
kubernetes   ClusterIP   10.100.0.1       <none>        443/TCP    18d
proxy        ClusterIP   10.100.229.205   <none>        80/TCP     44m

查看listeners

~# kubectl exec -it client -c istio-proxy -- pilot-agent request GET /listeners
42ebe263-b277-409b-83a9-c66c184e710e::0.0.0.0:15090
5182c664-4c5a-4407-8a89-2b762113de65::0.0.0.0:15021
10.100.0.2_53::10.100.0.2:53
10.100.149.76_15012::10.100.149.76:15012
10.100.121.95_443::10.100.121.95:443
10.100.145.112_15443::10.100.145.112:15443
10.100.0.1_443::10.100.0.1:443
10.100.145.112_443::10.100.145.112:443
10.100.145.112_31400::10.100.145.112:31400
10.100.149.76_443::10.100.149.76:443
0.0.0.0_80::0.0.0.0:80
0.0.0.0_9090::0.0.0.0:9090
0.0.0.0_8080::0.0.0.0:8080
10.100.0.2_9153::10.100.0.2:9153
10.100.107.86_443::10.100.107.86:443
0.0.0.0_15014::0.0.0.0:15014
10.100.145.112_15021::10.100.145.112:15021
0.0.0.0_16685::0.0.0.0:16685
10.100.126.122_14268::10.100.126.122:14268
10.100.128.238_8000::10.100.128.238:8000
0.0.0.0_15010::0.0.0.0:15010
0.0.0.0_20001::0.0.0.0:20001
10.100.126.122_14250::10.100.126.122:14250
0.0.0.0_9411::0.0.0.0:9411
10.100.162.68_3000::10.100.162.68:3000
virtualOutbound::0.0.0.0:15001
virtualInbound::0.0.0.0:15006

创建sidecar

sidecar-demo.yaml

apiVersion: networking.istio.io/v1beta1
kind: Sidecar
metadata:
  name: client
  namespace: default
spec:
  workloadSelector:
    labels:
      run: client
  outboundTrafficPolicy:
    # mode: REGISTRY_ONLY
    mode: ALLOW_ANY
  egress:
  - port:
      number: 8080
      protocol: HTTP
      name: demoapp
    hosts:
    - "./*"

or

apiVersion: networking.istio.io/v1beta1
kind: Sidecar
metadata:
  name: client
  namespace: default
spec:
  workloadSelector:
    labels:
      run: client
  outboundTrafficPolicy:
    mode: REGISTRY_ONLY
    #mode: ALLOW_ANY
  egress:
  - port:
      number: 8080
      protocol: HTTP
      name: demoapp
    hosts:
    - "./*"
  - port:
      number: 80
      protocol: HTTP
      name: proxy
    hosts:
    - "./*"

创建sidecar资源

# kubectl apply -f sidecar-demo.yaml 
sidecar.networking.istio.io/proxy created

查看sidecar资源

# kubectl get sidecar
NAME    AGE
client   52s

查看proxy pod listeners

~# kubectl exec -it client -c istio-proxy -- pilot-agent request GET /listeners
42ebe263-b277-409b-83a9-c66c184e710e::0.0.0.0:15090
5182c664-4c5a-4407-8a89-2b762113de65::0.0.0.0:15021
0.0.0.0_8080::0.0.0.0:8080
virtualOutbound::0.0.0.0:15001
virtualInbound::0.0.0.0:15006
# 0.0.0.0_80::0.0.0.0:80

访问demoapp

root@client # while true;do curl demoapp:8080;curl proxy ; sleep 0.5 ;done

查看kiali

参考文档

https://istio.io/latest/zh/docs/reference/config/networking/sidecar/

标签:10.100,0.0,istio,demoapp,client,io,sidecar
From: https://www.cnblogs.com/wangguishe/p/16844782.html

相关文章

  • Istio Policies and Telemetry
    要理解策略和遥测,首先要理解Mixer的架构;[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sUuojjzC-1664190859192)(https://istio.io/docs/conc......
  • Istio(十三):Istio项目实际案例——Online Boutique
    目录一.模块概览二.系统环境三.创建Kubernetes(k8s)集群3.1创建Kubernetes(k8s)集群3.2Kubernetes集群环境四.安装istio4.1安装Istio五.部署onlineBoutique应用5.1部......
  • Istio(十二):Istio问题排查
    目录一.模块概览二.Envoy基础2.1Envoy基础三.Envoy示例四.调试备忘录4.1配置4.2运行时4.3检查Envoy日志4.4配置istiod日志一.模块概览本模块介绍了在使用Isti......
  • Istio(十一):向istio服务网格中引入虚拟机
    目录一.模块概览二.系统环境三.虚拟机负载3.1虚拟机负载3.2单网络架构3.3多网络架构3.4Istio中如何表示虚拟机工作负载?四.实战:向istioMesh中引入虚拟机4.1将虚拟机......
  • Istio(十):istio多集群部署模式
    目录一.模块概览二.多集群部署2.1多集群部署2.2网络部署模式2.3控制平面部署模型2.4网格部署模型2.5租户模式2.6最佳多集群部署一.模块概览在本模块中,我们将了解在......
  • Istio(九):istio安全之授权
    目录一.模块概览二.系统环境三.istio授权3.1istio授权3.2来源3.3操作3.4条件四.实战:授权(访问控制)4.1访问控制4.2清理一.模块概览在Kubernetes集群中,可以对用户进行......
  • Istio(八):istio安全之认证,启用mTLS
    目录一.模块概览二.系统环境三.istio认证3.1证书创建与轮换3.2对等认证和请求认证3.2.1对等认证3.2.2请求认证3.3mTLS3.3.1双向TLS3.3.2允许模式四.实战:启用mTLS4.......
  • Istio(七):ServiceEntry,sidecar,Envoy Filter
    目录一.模块概览二.系统环境三.ServiceEntry四.sidecar4.1Sidecar4.2工作负载选择器4.3入口和出口监听器五.EnvoyFilter5.1EnvoyFilter一.模块概览使用ServiceEntr......
  • Istio(六):Istio弹性(超时&重试)和故障注入
    目录一.模块概览二.系统环境三.弹性(超时&重试)3.1弹性四.故障注入4.1故障注入五.实战:观察错误注入5.1在Grafana、Zipkin和Kiali中观察故障注入和延迟情况5.2清理......
  • Istio(五):使用服务网格Istio进行流量路由
    目录一.模块概览二.系统环境三.简单路由3.1简单路由四.Subset和DestinationRule4.1Subset和DestinationRule4.2DestinationRule中的流量策略4.2.1负载均衡器设置4.2......