启动 Amazon AppConfig agent for Amazon EKS 集成 - Amazon AppConfig
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

启动 Amazon AppConfig agent for Amazon EKS 集成

Amazon AppConfig Agent sidecar 容器在您的 Amazon EKS 环境中自动可用。要使用它,必须启动它。以下过程介绍如何使用 Amazon EKS kubectl 命令行工具来启动代理。

注意

在继续操作之前,请确保 kubeconfig 文件是最新的。有关创建或编辑 kubeconfig 文件的更多信息,请参阅 Amazon EKS 用户指南 中的 为 Amazon EKS 集群创建或更新 kubeconfig 文件

启动 Amazon AppConfig 代理(kubectl 命令行工具)
  1. 打开应用程序的清单,并验证 Amazon EKS 应用程序是否作为单容器部署运行。该文件的内容看起来类似于以下内容:

    apiVersion: apps/v1 kind: Deployment metadata: name: my-app namespace: my-namespace labels: app: my-application-label spec: replicas: 1 selector: matchLabels: app: my-application-label template: metadata: labels: app: my-application-label spec: containers: - name: my-app image: my-repo/my-image imagePullPolicy: IfNotPresent
  2. 将 Amazon AppConfig 代理容器定义详细信息添加到部署清单。

    - name: appconfig-agent image: public.ecr.aws/aws-appconfig/aws-appconfig-agent:2.x ports: - name: http containerPort: 2772 protocol: TCP env: - name: SERVICE_REGION value: Amazon Web Services 区域 imagePullPolicy: IfNotPresent
    注意

    请注意以下信息。

    • 默认情况下,Amazon AppConfig 代理在端口 2772 上运行。也可指定不同的端口。

    • 您可以通过输入环境变量来调整 Amazon AppConfig Agent 的默认行为。有关更多信息,请参阅 (可选)使用环境变量为 Amazon ECS 和 Amazon EKS 配置 Amazon AppConfig 代理

    • 对于 Amazon Web Services 区域,请指定 Amazon AppConfig 代理在其中检索配置数据的 Amazon Web Services 区域代码(例如 us-west-1)。

  3. 运行 kubectl 命令来将更改应用于集群。将 my-deployment 替换为部署清单的名称。

    kubectl apply -f my-deployment.yml
  4. 部署完成后,验证 Amazon AppConfig Agent 是否正在运行。使用以下命令查看应用程序 Pod 日志文件。

    kubectl logs -n my-namespace -c appconfig-agent my-pod

    为 Amazon AppConfig 代理容器找到如下所示的语句:[appconfig agent] 1970/01/01 00:00:00 INFO serving on localhost:2772

注意

您可以通过输入或更改环境变量来调整 Amazon AppConfig Agent 的默认行为。有关可用环境变量的更多信息,请参阅 (可选)使用环境变量为 Amazon ECS 和 Amazon EKS 配置 Amazon AppConfig 代理