在具有 EC2 启动类型或 Kubernetes 集群的 Amazon EKS 集群上设置 Amazon App Mesh 示例工作负载 - Amazon CloudWatch
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

在具有 EC2 启动类型或 Kubernetes 集群的 Amazon EKS 集群上设置 Amazon App Mesh 示例工作负载

如果您要在运行 Amazon EKS 且具有 EC2 启动类型的集群或 Kubernetes 集群上设置 App Mesh,请使用这些说明。

配置 IAM 权限

必须将 AWSAppMeshFullAccess 策略添加到您的 Amazon EKS 或 Kubernetes 节点组的 IAM 角色中。在 Amazon EKS 上,此节点组名称类似于 eksctl-integ-test-eks-prometheus-NodeInstanceRole-ABCDEFHIJKL。在 Kubernetes 上,它可能类似于 nodes.integ-test-kops-prometheus.k8s.local

安装 App Mesh

要安装 App Mesh Kubernetes 控制器,请按照 App Mesh 控制器中的说明进行操作。

安装示例应用程序

aws-app-mesh-examples 包含多个 Kubernetes App Mesh 演练。在本教程中,您将安装一个示例颜色应用程序,该应用程序会展示 http 路由如何使用标头来匹配传入请求。

使用示例 App Mesh 应用程序来测试 Container Insights
  1. 按照以下说明安装应用程序:https://github.com/aws/aws-app-mesh-examples/tree/main/walkthroughs/howto-k8s-http-headers

  2. 启动 curler pod 以生成流量:

    kubectl -n default run -it curler --image=tutum/curl /bin/bash
  3. 通过更改 HTTP 标头来对不同的端点执行 curl。多次运行 curl 命令,如下所示:

    curl -H "color_header: blue" front.howto-k8s-http-headers.svc.cluster.local:8080/; echo; curl -H "color_header: red" front.howto-k8s-http-headers.svc.cluster.local:8080/; echo; curl -H "color_header: yellow" front.howto-k8s-http-headers.svc.cluster.local:8080/; echo;
  4. 通过 https://console.aws.amazon.com/cloudwatch/ 打开 CloudWatch 控制台。

  5. 在集群运行的 Amazon 区域的导航窗格中,选择 Metrics(指标)。指标位于 ContainerInsights/Prometheus 命名空间中。

  6. 要查看 CloudWatch Logs 事件,请在导航窗格中选择 Log groups(日志组)。事件位于日志流 kubernetes-pod-appmesh-envoy 的日志组 /aws/containerinsights/your_cluster_name/prometheus 中。

删除 App Mesh 测试环境

App Mesh 和示例应用程序使用完成后,请使用以下命令删除不必要的资源。输入以下命令删除示例应用程序:

cd aws-app-mesh-examples/walkthroughs/howto-k8s-http-headers/ kubectl delete -f _output/manifest.yaml

输入以下命令删除 App Mesh 控制器:

helm delete appmesh-controller -n appmesh-system