Flagger on ASM——基于Mixerless Telemetry实现渐进式灰度发布系列 1 遥测数据
序
服務(wù)網(wǎng)格ASM的Mixerless Telemetry技術(shù),為業(yè)務(wù)容器提供了無(wú)侵入式的遙測(cè)數(shù)據(jù)。遙測(cè)數(shù)據(jù)一方面作為監(jiān)控指標(biāo)被ARMPS/prometheus采集,用于服務(wù)網(wǎng)格可觀測(cè)性;另一方面被HPA和flaggers使用,成為應(yīng)用級(jí)擴(kuò)縮容和漸進(jìn)式灰度發(fā)布的基石。
本系列聚焦于遙測(cè)數(shù)據(jù)在應(yīng)用級(jí)擴(kuò)縮容和漸進(jìn)式灰度發(fā)布上的實(shí)踐,將分三篇介紹遙測(cè)數(shù)據(jù)(監(jiān)控指標(biāo))、應(yīng)用級(jí)擴(kuò)縮容,和漸進(jìn)式灰度發(fā)布。
總體架構(gòu)
本系列的總體架構(gòu)如下圖所示:
Flagger漸進(jìn)式發(fā)布流程
Flagger官網(wǎng)描述了漸進(jìn)式發(fā)布流程,這里翻譯如下:
原文如下:
With the above configuration, Flagger will run a canary release with the following steps:
- detect new revision (deployment spec, secrets or configmaps changes)
- scale from zero the canary deployment
- wait for the HPA to set the canary minimum replicas
- check canary pods health
- run the acceptance tests
- abort the canary release if tests fail
- start the load tests
- mirror 100% of the traffic from primary to canary
- check request success rate and request duration every minute
- abort the canary release if the metrics check failure threshold is reached
- stop traffic mirroring after the number of iterations is reached
- route live traffic to the canary pods
- promote the canary (update the primary secrets, configmaps and deployment spec)
- wait for the primary deployment rollout to finish
- wait for the HPA to set the primary minimum replicas
- check primary pods health
- switch live traffic back to primary
- scale to zero the canary
- send notification with the canary analysis result
前提條件
- 已創(chuàng)建ACK集群,詳情請(qǐng)參見(jiàn)創(chuàng)建Kubernetes托管版集群。
- 已創(chuàng)建ASM實(shí)例,詳情請(qǐng)參見(jiàn)創(chuàng)建ASM實(shí)例。
Setup Mixerless Telemetry
本篇將介紹如何基于ASM配置并采集應(yīng)用級(jí)監(jiān)控指標(biāo)(比如請(qǐng)求數(shù)量總數(shù)istio_requests_total和請(qǐng)求延遲istio_request_duration等)。主要步驟包括創(chuàng)建EnvoyFilter、校驗(yàn)envoy遙測(cè)數(shù)據(jù)和校驗(yàn)Prometheus采集遙測(cè)數(shù)據(jù)。
1 EnvoyFilter
登錄ASM控制臺(tái),左側(cè)導(dǎo)航欄選擇服務(wù)網(wǎng)格 >網(wǎng)格管理,并進(jìn)入ASM實(shí)例的功能配置頁(yè)面。
- 勾選開(kāi)啟采集Prometheus 監(jiān)控指標(biāo)
- 點(diǎn)選啟用自建 Prometheus,并填入Prometheus服務(wù)地址:`prometheus:9090(本系列將使用社區(qū)版Prometheus,后文將使用這個(gè)配置)。如果使用阿里云產(chǎn)品ARMS,請(qǐng)參考集成ARMS Prometheus實(shí)現(xiàn)網(wǎng)格監(jiān)控。
- 勾選啟用 Kiali(可選)
點(diǎn)擊確定后,我們將在控制平面看到ASM生成的相關(guān)EnvoyFilter列表:
2 Prometheus
2.1 Install
執(zhí)行如下命令安裝Prometheus(完整腳本參見(jiàn):demo_mixerless.sh)。
kubectl --kubeconfig "$USER_CONFIG" apply -f $ISTIO_SRC/samples/addons/prometheus.yaml2.2 Config Scrape
安裝完P(guān)rometheus,我們需要為其配置添加istio相關(guān)的監(jiān)控指標(biāo)。登錄ACK控制臺(tái),左側(cè)導(dǎo)航欄選擇配置管理>配置項(xiàng),在istio-system下找到prometheus一行,點(diǎn)擊編輯。
在prometheus.yaml配置中,將scrape_configs.yaml中的配置追加到scrape_configs中。
保存配置后,左側(cè)導(dǎo)航欄選擇工作負(fù)載>容器組,在istio-system下找到prometheus一行,刪除Prometheus POD,以確保配置在新的POD中生效。
可以執(zhí)行如下命令查看Prometheus配置中的job_name:
kubectl --kubeconfig "$USER_CONFIG" get cm prometheus -n istio-system -o jsonpath={.data.prometheus\\.yml} | grep job_name - job_name: 'istio-mesh' - job_name: 'envoy-stats' - job_name: 'istio-policy' - job_name: 'istio-telemetry' - job_name: 'pilot' - job_name: 'sidecar-injector' - job_name: prometheusjob_name: kubernetes-apiserversjob_name: kubernetes-nodesjob_name: kubernetes-nodes-cadvisor - job_name: kubernetes-service-endpoints - job_name: kubernetes-service-endpoints-slowjob_name: prometheus-pushgateway - job_name: kubernetes-services - job_name: kubernetes-pods - job_name: kubernetes-pods-slowMixerless驗(yàn)證
1 podinfo
1.1 部署
使用如下命令部署本系列的示例應(yīng)用podinfo:
kubectl --kubeconfig "$USER_CONFIG" apply -f $PODINFO_SRC/kustomize/deployment.yaml -n test kubectl --kubeconfig "$USER_CONFIG" apply -f $PODINFO_SRC/kustomize/service.yaml -n test1.2 生成負(fù)載
使用如下命令請(qǐng)求podinfo,以產(chǎn)生監(jiān)控指標(biāo)數(shù)據(jù)
podinfo_pod=$(k get po -n test -l app=podinfo -o jsonpath={.items..metadata.name}) for i in {1..10}; dokubectl --kubeconfig "$USER_CONFIG" exec $podinfo_pod -c podinfod -n test -- curl -s podinfo:9898/versionecho done2 確認(rèn)生成(Envoy)
本系列重點(diǎn)關(guān)注的監(jiān)控指標(biāo)項(xiàng)是istio_requests_total和istio_request_duration。首先,我們?cè)趀nvoy容器內(nèi)確認(rèn)這些指標(biāo)已經(jīng)生成。
2.1 istio_requests_total
使用如下命令請(qǐng)求envoy獲取stats相關(guān)指標(biāo)數(shù)據(jù),并確認(rèn)包含istio_requests_total。
kubectl --kubeconfig "$USER_CONFIG" exec $podinfo_pod -n test -c istio-proxy -- curl -s localhost:15090/stats/prometheus | grep istio_requests_total返回結(jié)果信息如下:
:::: istio_requests_total :::: # TYPE istio_requests_total counter istio_requests_total{response_code="200",reporter="destination",source_workload="podinfo",source_workload_namespace="test",source_principal="spiffe://cluster.local/ns/test/sa/default",source_app="podinfo",source_version="unknown",source_cluster="c199d81d4e3104a5d90254b2a210914c8",destination_workload="podinfo",destination_workload_namespace="test",destination_principal="spiffe://cluster.local/ns/test/sa/default",destination_app="podinfo",destination_version="unknown",destination_service="podinfo.test.svc.cluster.local",destination_service_name="podinfo",destination_service_namespace="test",destination_cluster="c199d81d4e3104a5d90254b2a210914c8",request_protocol="http",response_flags="-",grpc_response_status="",connection_security_policy="mutual_tls",source_canonical_service="podinfo",destination_canonical_service="podinfo",source_canonical_revision="latest",destination_canonical_revision="latest"} 10istio_requests_total{response_code="200",reporter="source",source_workload="podinfo",source_workload_namespace="test",source_principal="spiffe://cluster.local/ns/test/sa/default",source_app="podinfo",source_version="unknown",source_cluster="c199d81d4e3104a5d90254b2a210914c8",destination_workload="podinfo",destination_workload_namespace="test",destination_principal="spiffe://cluster.local/ns/test/sa/default",destination_app="podinfo",destination_version="unknown",destination_service="podinfo.test.svc.cluster.local",destination_service_name="podinfo",destination_service_namespace="test",destination_cluster="c199d81d4e3104a5d90254b2a210914c8",request_protocol="http",response_flags="-",grpc_response_status="",connection_security_policy="unknown",source_canonical_service="podinfo",destination_canonical_service="podinfo",source_canonical_revision="latest",destination_canonical_revision="latest"} 102.2 istio_request_duration
使用如下命令請(qǐng)求envoy獲取stats相關(guān)指標(biāo)數(shù)據(jù),并確認(rèn)包含istio_request_duration。
kubectl --kubeconfig "$USER_CONFIG" exec $podinfo_pod -n test -c istio-proxy -- curl -s localhost:15090/stats/prometheus | grep istio_request_duration返回結(jié)果信息如下:
:::: istio_request_duration :::: # TYPE istio_request_duration_milliseconds histogram istio_request_duration_milliseconds_bucket{response_code="200",reporter="destination",source_workload="podinfo",source_workload_namespace="test",source_principal="spiffe://cluster.local/ns/test/sa/default",source_app="podinfo",source_version="unknown",source_cluster="c199d81d4e3104a5d90254b2a210914c8",destination_workload="podinfo",destination_workload_namespace="test",destination_principal="spiffe://cluster.local/ns/test/sa/default",destination_app="podinfo",destination_version="unknown",destination_service="podinfo.test.svc.cluster.local",destination_service_name="podinfo",destination_service_namespace="test",destination_cluster="c199d81d4e3104a5d90254b2a210914c8",request_protocol="http",response_flags="-",grpc_response_status="",connection_security_policy="mutual_tls",source_canonical_service="podinfo",destination_canonical_service="podinfo",source_canonical_revision="latest",destination_canonical_revision="latest",le="0.5"} 10istio_request_duration_milliseconds_bucket{response_code="200",reporter="destination",source_workload="podinfo",source_workload_namespace="test",source_principal="spiffe://cluster.local/ns/test/sa/default",source_app="podinfo",source_version="unknown",source_cluster="c199d81d4e3104a5d90254b2a210914c8",destination_workload="podinfo",destination_workload_namespace="test",destination_principal="spiffe://cluster.local/ns/test/sa/default",destination_app="podinfo",destination_version="unknown",destination_service="podinfo.test.svc.cluster.local",destination_service_name="podinfo",destination_service_namespace="test",destination_cluster="c199d81d4e3104a5d90254b2a210914c8",request_protocol="http",response_flags="-",grpc_response_status="",connection_security_policy="mutual_tls",source_canonical_service="podinfo",destination_canonical_service="podinfo",source_canonical_revision="latest",destination_canonical_revision="latest",le="1"} 10 ...3 確認(rèn)采集(Prometheus)
最后,我們驗(yàn)證Envoy生成的監(jiān)控指標(biāo)數(shù)據(jù),是否被Prometheus實(shí)時(shí)采集上來(lái)。對(duì)外暴露Prometheus服務(wù),并使用瀏覽器請(qǐng)求該服務(wù)。然后在查詢(xún)框輸入istio_requests_total,得到結(jié)果如下圖所示。
原文鏈接:https://developer.aliyun.com/article/783550?
版權(quán)聲明:本文內(nèi)容由阿里云實(shí)名注冊(cè)用戶(hù)自發(fā)貢獻(xiàn),版權(quán)歸原作者所有,阿里云開(kāi)發(fā)者社區(qū)不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。具體規(guī)則請(qǐng)查看《阿里云開(kāi)發(fā)者社區(qū)用戶(hù)服務(wù)協(xié)議》和《阿里云開(kāi)發(fā)者社區(qū)知識(shí)產(chǎn)權(quán)保護(hù)指引》。如果您發(fā)現(xiàn)本社區(qū)中有涉嫌抄襲的內(nèi)容,填寫(xiě)侵權(quán)投訴表單進(jìn)行舉報(bào),一經(jīng)查實(shí),本社區(qū)將立刻刪除涉嫌侵權(quán)內(nèi)容。總結(jié)
以上是生活随笔為你收集整理的Flagger on ASM——基于Mixerless Telemetry实现渐进式灰度发布系列 1 遥测数据的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 钉钉宜搭版本更新
- 下一篇: Flagger on ASM——基于Mi