

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# （可选）在 Amazon EKS DaemonSet 中以 a Amazon AppConfig 身份运行


使用 Amazon EKS，您可以将 Amazon AppConfig 代理作为边车运行，这样*每个应用程序 pod* 就会有一个代理容器。或者，如果您愿意，也可以将 Amazon AppConfig Agent 作为运行 [DaemonSet](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/)，这样*集群中的每个节点*都有一个代理容器。

**注意**  
如果您以身份运行 Amazon AppConfig Agent DaemonSet，则代理将在单独的 pod 中运行，这意味着您无法通过调用来访问它`localhost`。您必须注入或以其它方式发现代理容器组（pod）的 IP 地址，才能调用它。

要以身份运行 Amazon AppConfig Agent DaemonSet，请创建一个包含以下内容的清单文件。将*highlighted*文本替换为应用程序和环境的详细信息。对于 *Amazon Web Services 区域*，请指定 Amazon Web Services 区域 代码（例如，`us-west-1`）。

```
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: aws-appconfig-agent
  namespace: my_namespace
  labels:
    app: my_application_label
spec:
   selector:
    matchLabels:
      app: my_application_label
  template:
    metadata:
      labels:
        app: my_application_label
    spec:
      containers:
      - name: aws-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
      # set a high priority class to ensure the agent is running on every node
      priorityClassName: system-node-critical
```

运行以下命令将 Amazon AppConfig 代理应用 DaemonSet 到您的集群。*aws\$1appconfig\$1agent\$1daemonset*替换为 DaemonSet清单的名称。

```
kubectl apply -f aws_appconfig_agent_daemonset.yml
```