Istio初识

1.简介

2.整体架构

istio

3.组件说明

3.1 Pilot

属于控制面,承担着服务发现、流量管理、智能路由等,提供一系列的api的入口

3.2 Galley

配置的验证,管理和分发,作为istio的配置中心,通过用validatingWebhook机制对Pilot 和 Mixer 的配置进行验证

3.3 Citadel

负责秘钥和证书的管理,服务鉴权

3.4 Mixer

管理授权和审计,和连接envoy,对应镜像istio-policy,Mixer提供adapter机制
Mixer中现有的Adapter

  • 实现Check的Adapter
    listchecker(黑白名单)
    opa(open Policy Agent)
    RBAC(连接到istioCA)

  • 实现Quota的Adapter
    Menquota(基于单机内存)
    Redisquota(基于外部Redis)

  • 实现Report的Adapter
    Circonus
    Cloudwatch
    Dogstatsd
    Fluentd
    Prometheus
    Solarwinds
    StatsD
    Stdio

3.5 Proxy(Agent+Envoy)

通过sidecar方式部署于pod中,负责接收控制面策略并生成配置文件,作用于pod。

Envoy启动时的启动配置文件中包括:

  • Node信息
    包含的节点信息
  • stats_config
    Envoy的管理信息
  • admin
    Envoy的管理信息主要是指管理API地址(127.0.0.1::15000)
  • dynamic_resources
    根据Polit提供的XDS接口生成的配置信息
  • static_resources
    静态配置信息,包括prometheus,Pilot控制面和zipkin服务发现信息
  • tracing
    链路追踪Tracing的配置信息

Envoy启动的配置文件所在位置

[root@node4 ~]# kubectl exec productpage-v1-8554d58bff-bhlfl -c istio-proxy -- ls /etc/istio/proxy/envoy-rev0.json 
/etc/istio/proxy/envoy-rev0.json

Envoy中的接口:

[root@node4 ~]# kubectl exec productpage-v1-8554d58bff-bhlfl  -c istio-proxy curl http://127.0.0.1:15000/help
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                               Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0admin commands are:
  /: Admin home page
  /certs: print certs on machine
  /clusters: upstream cluster status
  /config_dump: dump current Envoy configs (experimental)
  /contention: dump current Envoy mutex contention stats (if enabled)
  /cpuprofiler: enable/disable the CPU profiler
  /healthcheck/fail: cause the server to fail health checks
  /healthcheck/ok: cause the server to pass health checks
  /heapprofiler: enable/disable the heap profiler
  /help: print out list of admin commands
  /hot_restart_version: print the hot restart compatibility version
  /listeners: print listener info
  /logging: query/change logging levels
  /memory: print current allocation/heap usage
  /quitquitquit: exit the server
  /ready: print server state, return 200 if LIVE, otherwise return 503
  /reset_counters: reset all counters to zero
  /runtime: print runtime values
  /runtime_modify: modify runtime values
  /server_info: print server version/status information
  /stats: print server stats
  /stats/prometheus: print server stats in prometheus format

clusters信息

istio-proxy@productpage-v1-8554d58bff-tqhnk:/$ curl http://127.0.0.1:15000/clusters |grep 9080             
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
outbound|9080||reviews.default.svc.cluster.local::default_priority::max_connections::1024
outbound|9080||reviews.default.svc.cluster.local::default_priority::max_pending_requests::1024
outbound|9080||reviews.default.svc.cluster.local::default_priority::max_requests::1024
outbound|9080||reviews.default.svc.cluster.local::default_priority::max_retries::1024
outbound|9080||reviews.default.svc.cluster.local::high_priority::max_connections::1024
outbound|9080||reviews.default.svc.cluster.local::high_priority::max_pending_requests::1024
outbound|9080||reviews.default.svc.cluster.local::high_priority::max_requests::1024
outbound|9080||reviews.default.svc.cluster.local::high_priority::max_retries::3
outbound|9080||reviews.default.svc.cluster.local::added_via_api::true
outbound|9080||reviews.default.svc.cluster.local::172.10.104.13:9080::cx_active::2
outbound|9080||reviews.default.svc.cluster.local::172.10.104.13:9080::cx_connect_fail::0
outbound|9080||reviews.default.svc.cluster.local::172.10.104.13:9080::cx_total::2
outbound|9080||reviews.default.svc.cluster.local::172.10.104.13:9080::rq_active::0

Envoy的运行时配置信息

[root@node4 ~]# kubectl exec -it productpage-v1-8554d58bff-bhlfl -c istio-proxy curl http://127.0.0.1:15000/config_dump

包含的内容

  • BootstrapConfigDump
    bootstrap包含启动Envoy时的配置西悉尼

  • ClustersConfigDump
    static_clusters:
    主要包括istio平台本省的组件信息,如zipkin、prometheus、STRICT_DNS(Polit控制面)
    dynamic_active_clusters:根据POD产生的cluster,根据类型分为STATIC(如BlackHoleCluster,类似404无匹配时到达)、ORIGINAL_DST和EDS(表示通过API产生的配置)

  • ListenersConfigDump
    static_listeners:在15090端口上开启的listeners
    dynamic_active_listeners:动态在POD和service上创建的listeners
  • ScopedRoutesConfigDump
  • RoutesConfigDump对应VirtualService
    static_route_configs : 平台产生的路由配置信息
    dynamic_route_configs : 根据业务产的路由配置
  • SecretsConfigDump

4.istio中资源类型

  • attributemanifest
    定义属性清单

  • instance rule handler
    instance 表示一系列的数据
    handler 对应着数据处理的适配器
    rule 包含一系列的action,每个action是一个handler 和一组instance 的对应关系

    三个关系

  • DestinationRule
    描述即将流量转发到服务时应用的策略集,包括负载均衡配置,sidecar中的连接池大小和异常值检测设置(主要用于从负载平衡池中逐出不正常的主机)
    其中负载均衡策略包括:ROUND_ROBIN、LEAST_CONN、RANDOM、PASSTHROUGH

  • Gateway
    网关,描述应用在边缘设备(整个mesh对外的入口和出口)上的开放的端口和协议等

  • VirtualService
    定义路由规则,包括headers匹配等

  • ServiceEntry
    ServiceEntry用于将附加条目添加到Istio内部维护的服务注册表中。

4.istio的安装

istio的安装

//下载istio-1.3.4-linux.tar.gz
[root@node4 istio]# wget https://github.com/istio/istio/releases/download/1.3.4/istio-1.3.4-linux.tar.gz
[root@node4 istio]# tar -zxvf istio-1.3.4-linux.tar.gz
[root@node4 istio]# cd istio-1.3.4/
[root@node4 istio-1.3.4]# kubectl apply -f install/kubernetes/istio-demo.yaml
[root@node4 istio-1.3.4]# kubectl -n istio-system get pod 
NAME                                      READY   STATUS      RESTARTS   AGE
grafana-59d57c5c56-sj95t                  1/1     Running     0          21d
istio-citadel-555bff45bf-rtcv6            1/1     Running     0          21d
istio-egressgateway-7fd45cc845-2lzzh      1/1     Running     0          21d
istio-galley-7f8b6db7d7-v992r             1/1     Running     0          21d
istio-grafana-post-install-1.3.4-7bgxj    0/1     Completed   0          21d
istio-ingressgateway-64456bb8b-nqc89      1/1     Running     0          21d
istio-pilot-85894cd4f5-859kp              2/2     Running     0          21d
istio-policy-7d8f44db64-4zggd             2/2     Running     2          21d
istio-security-post-install-1.3.4-2vxhk   0/1     Completed   0          21d
istio-sidecar-injector-65d5f8db56-2x8l5   1/1     Running     0          21d
istio-telemetry-85c7c59b86-wxxsx          2/2     Running     2          21d
istio-tracing-795c9c64c4-8r6p5            1/1     Running     0          21d
kiali-8c9d6fbf6-rblp5                     1/1     Running     0          21d
prometheus-7d7b9f7844-kfpk4               1/1     Running     0          21d
[root@node4 istio-1.3.4]# kubectl -n istio-system get svc
NAME                     TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                                                                                                      AGE
grafana                  ClusterIP   172.20.185.180   <none>        3000/TCP                                                                                                                                     21d
istio-citadel            ClusterIP   172.20.170.209   <none>        8060/TCP,15014/TCP                                                                                                                           21d
istio-egressgateway      ClusterIP   172.20.17.218    <none>        80/TCP,443/TCP,15443/TCP                                                                                                                     21d
istio-galley             ClusterIP   172.20.53.63     <none>        443/TCP,15014/TCP,9901/TCP                                                                                                                   21d
istio-ingressgateway     NodePort    172.20.68.121    <none>        15020:30962/TCP,80:31380/TCP,443:31390/TCP,31400:31400/TCP,15029:30391/TCP,15030:32742/TCP,15031:31213/TCP,15032:31411/TCP,15443:32673/TCP   21d
istio-pilot              ClusterIP   172.20.42.191    <none>        15010/TCP,15011/TCP,8080/TCP,15014/TCP                                                                                                       21d
istio-policy             ClusterIP   172.20.168.15    <none>        9091/TCP,15004/TCP,15014/TCP                                                                                                                 21d
istio-sidecar-injector   ClusterIP   172.20.149.157   <none>        443/TCP,15014/TCP                                                                                                                            21d
istio-telemetry          ClusterIP   172.20.42.203    <none>        9091/TCP,15004/TCP,15014/TCP,42422/TCP                                                                                                       21d
jaeger-agent             ClusterIP   None             <none>        5775/UDP,6831/UDP,6832/UDP                                                                                                                   21d
jaeger-collector         ClusterIP   172.20.50.220    <none>        14267/TCP,14268/TCP,14250/TCP                                                                                                                21d
jaeger-query             ClusterIP   172.20.49.122    <none>        16686/TCP                                                                                                                                    21d
kiali                    ClusterIP   172.20.238.205   <none>        20001/TCP                                                                                                                                    21d
prometheus               ClusterIP   172.20.97.112    <none>        9090/TCP                                                                                                                                     21d
tracing                  ClusterIP   172.20.203.114   <none>        80/TCP                                                                                                                                       21d
zipkin                   ClusterIP   172.20.133.126   <none>        9411/TCP                                                                                                                                     21d

bookinfo实例

//设置default的注入标识
[root@node4 istio-1.3.4]# kubectl label namespace default istio-injection=enabled
[root@node4 istio-1.3.4]# kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
[root@node4 istio-1.3.4]# kubectl get pod
NAME                                                  READY   STATUS              RESTARTS   AGE
details-v1-74f858558f-cqwdk                           2/2     Running             0          21d
productpage-v1-8554d58bff-bhlfl                       2/2     Running             0          21d
ratings-v1-7855f5bcb9-c6d7w                           2/2     Running             0          21d
reviews-v1-59fd8b965b-h759b                           2/2     Running             0          21d
reviews-v2-d6cfdb7d6-v4fjt                            2/2     Running             0          21d
reviews-v3-75699b5cfb-kf8tb                           2/2     Running             0          21d

检查Proxy注入

image.png

访问测试

export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
export INGRESS_HOST=$(kubectl get po -l istio=ingressgateway -n istio-system -o jsonpath='{.items[0].status.hostIP}')
image.png

image.png

image.png

5.访问流程分析

image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,015评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,262评论 1 292
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,727评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,986评论 0 205
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,363评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,610评论 1 219
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,871评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,582评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,297评论 1 242
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,551评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,053评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,385评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,035评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,079评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,841评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,648评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,550评论 2 270

推荐阅读更多精彩内容