Flagger on ASM——基于Mixerless Telemetry实现渐进式灰度发布系列 1 遥测数据
序
服務網(wǎng)格ASM的Mixerless Telemetry技術(shù),為業(yè)務容器提供了無侵入式的遙測數(shù)據(jù)。遙測數(shù)據(jù)一方面作為監(jiān)控指標被ARMPS/prometheus采集,用于服務網(wǎng)格可觀測性;另一方面被HPA和flaggers使用,成為應用級擴縮容和漸進式灰度發(fā)布的基石。
本系列聚焦于遙測數(shù)據(jù)在應用級擴縮容和漸進式灰度發(fā)布上的實踐,將分三篇介紹遙測數(shù)據(jù)(監(jiān)控指標)、應用級擴縮容,和漸進式灰度發(fā)布。
總體架構(gòu)
本系列的總體架構(gòu)如下圖所示:
Flagger漸進式發(fā)布流程
Flagger官網(wǎng)描述了漸進式發(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集群,詳情請參見創(chuàng)建Kubernetes托管版集群。
- 已創(chuàng)建ASM實例,詳情請參見創(chuàng)建ASM實例。
Setup Mixerless Telemetry
本篇將介紹如何基于ASM配置并采集應用級監(jiān)控指標(比如請求數(shù)量總數(shù)istio_requests_total和請求延遲istio_request_duration等)。主要步驟包括創(chuàng)建EnvoyFilter、校驗envoy遙測數(shù)據(jù)和校驗Prometheus采集遙測數(shù)據(jù)。
1 EnvoyFilter
登錄ASM控制臺,左側(cè)導航欄選擇服務網(wǎng)格 >網(wǎng)格管理,并進入ASM實例的功能配置頁面。
- 勾選開啟采集Prometheus 監(jiān)控指標
- 點選啟用自建 Prometheus,并填入Prometheus服務地址:`prometheus:9090(本系列將使用社區(qū)版Prometheus,后文將使用這個配置)。如果使用阿里云產(chǎn)品ARMS,請參考集成ARMS Prometheus實現(xiàn)網(wǎng)格監(jiān)控。
- 勾選啟用 Kiali(可選)
點擊確定后,我們將在控制平面看到ASM生成的相關(guān)EnvoyFilter列表:
2 Prometheus
2.1 Install
執(zhí)行如下命令安裝Prometheus(完整腳本參見: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)控指標。登錄ACK控制臺,左側(cè)導航欄選擇配置管理>配置項,在istio-system下找到prometheus一行,點擊編輯。
在prometheus.yaml配置中,將scrape_configs.yaml中的配置追加到scrape_configs中。
保存配置后,左側(cè)導航欄選擇工作負載>容器組,在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驗證
1 podinfo
1.1 部署
使用如下命令部署本系列的示例應用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 生成負載
使用如下命令請求podinfo,以產(chǎn)生監(jiān)控指標數(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 確認生成(Envoy)
本系列重點關(guān)注的監(jiān)控指標項是istio_requests_total和istio_request_duration。首先,我們在envoy容器內(nèi)確認這些指標已經(jīng)生成。
2.1 istio_requests_total
使用如下命令請求envoy獲取stats相關(guān)指標數(shù)據(jù),并確認包含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
使用如下命令請求envoy獲取stats相關(guān)指標數(shù)據(jù),并確認包含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 確認采集(Prometheus)
最后,我們驗證Envoy生成的監(jiān)控指標數(shù)據(jù),是否被Prometheus實時采集上來。對外暴露Prometheus服務,并使用瀏覽器請求該服務。然后在查詢框輸入istio_requests_total,得到結(jié)果如下圖所示。
原文鏈接:https://developer.aliyun.com/article/783550?
版權(quán)聲明:本文內(nèi)容由阿里云實名注冊用戶自發(fā)貢獻,版權(quán)歸原作者所有,阿里云開發(fā)者社區(qū)不擁有其著作權(quán),亦不承擔相應法律責任。具體規(guī)則請查看《阿里云開發(fā)者社區(qū)用戶服務協(xié)議》和《阿里云開發(fā)者社區(qū)知識產(chǎn)權(quán)保護指引》。如果您發(fā)現(xiàn)本社區(qū)中有涉嫌抄襲的內(nèi)容,填寫侵權(quán)投訴表單進行舉報,一經(jīng)查實,本社區(qū)將立刻刪除涉嫌侵權(quán)內(nèi)容。總結(jié)
以上是生活随笔為你收集整理的Flagger on ASM——基于Mixerless Telemetry实现渐进式灰度发布系列 1 遥测数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 钉钉宜搭版本更新
- 下一篇: Flagger on ASM——基于Mi