本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
在具有 AWS App Mesh 启动类型的 Amazon EKS 集群上设置Fargate示例工作负载
如果要在App Mesh以 Amazon EKS 启动类型运行的集群Fargate上设置 ,请按照这些说明操作。
配置 IAM 权限
要设置IAM权限,请输入以下命令。Replace MyCluster
替换为集群的名称。
eksctl create iamserviceaccount --cluster
MyCluster
\ --namespace howto-k8s-fargate \ --name appmesh-pod \ --attach-policy-arn arn:aws:iam::aws:policy/AWSAppMeshEnvoyAccess \ --attach-policy-arn arn:aws:iam::aws:policy/AWSCloudMapDiscoverInstanceAccess \ --attach-policy-arn arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess \ --attach-policy-arn arn:aws:iam::aws:policy/CloudWatchLogsFullAccess \ --attach-policy-arn arn:aws:iam::aws:policy/AWSAppMeshFullAccess \ --attach-policy-arn arn:aws:iam::aws:policy/AWSCloudMapFullAccess \ --override-existing-serviceaccounts \ --approve
安装 App Mesh
要安装 App Mesh Kubernetes 控制器,请按照 App Mesh Controller
安装示例应用程序
aws-app-mesh-examples
使用示例App Mesh应用程序测试 Container Insights
-
按照以下说明安装应用程序:https://github.com/aws/aws-app-mesh-examples/tree/master/walkthroughs/howto-k8s-fargate
。 这些说明假定您正在创建具有正确Fargate配置文件的新集群。如果要使用已设置的 Amazon EKS 集群,您可以使用以下命令为此演示设置该集群。Replace
MyCluster
替换为集群的名称。eksctl create iamserviceaccount --cluster
MyCluster
\ --namespace howto-k8s-fargate \ --name appmesh-pod \ --attach-policy-arn arn:aws:iam::aws:policy/AWSAppMeshEnvoyAccess \ --attach-policy-arn arn:aws:iam::aws:policy/AWSCloudMapDiscoverInstanceAccess \ --attach-policy-arn arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess \ --attach-policy-arn arn:aws:iam::aws:policy/CloudWatchLogsFullAccess \ --attach-policy-arn arn:aws:iam::aws:policy/AWSAppMeshFullAccess \ --attach-policy-arn arn:aws:iam::aws:policy/AWSCloudMapFullAccess \ --override-existing-serviceaccounts \ --approveeksctl create fargateprofile --cluster MyCluster \ --namespace howto-k8s-fargate --name howto-k8s-fargate
-
前置应用程序部署的端口:
kubectl -n howto-k8s-fargate port-forward deployment/front 8080:8080
-
克隆前端应用程序:
while true; do curl -s http://localhost:8080/color; sleep 0.1; echo ; done
-
通过以下网址打开 CloudWatch 控制台:https://console.amazonaws.cn/cloudwatch/
。 -
在运行集群的 AWS 区域中,选择导航窗格中的 Metrics (指标)。指标位于 ContainerInsights/Prometheus 命名空间中。
-
要查看CloudWatch Logs事件,请在导航窗格中选择 Log groups (日志组)。事件位于日志流
/aws/containerinsights/
中的日志组中your_cluster_name
/prometheuskubernetes-pod-appmesh-envoy
。
删除App Mesh测试环境
在使用完 App Mesh 和示例应用程序后,请使用以下命令删除不必要的资源。输入以下命令删除示例应用程序:
cd aws-app-mesh-examples/walkthroughs/howto-k8s-fargate/ kubectl delete -f _output/manifest.yaml
输入以下命令删除App Mesh控制器:
helm delete appmesh-controller -n appmesh-system