【问题标题】:How to set up cloud custodian on Docker如何在 Docker 上设置云托管人
【发布时间】:2020-05-23 00:50:27
【问题描述】:

全部,

我正在尝试在 Fargate 上的 AWS ECS 计划任务上实施云托管解决方案。

我的Dockerfile 看起来像:

FROM cloudcustodian/c7n:latest

WORKDIR /opt/src

COPY policy.yml policy.yml
COPY mailer.yml mailer.yml

ENTRYPOINT [ "/bin/sh" ]

policy.yml 的样子

policies:
  - name: c7n-mailer-test
    resource: sqs
    filters:
     - "tag:MailerTest": absent
    actions:
      - type: notify
        template: default
        priority_header: '2'
        subject: testing the c7n mailer
        to:
          - test@mydomain.com
        transport:
          type: sqs
          queue: arn:aws:iam::xxxx:role/cloud-custodian-mailer-role-svc

还有mailer.yml 看起来像

queue_url: https://sqs.ap-southeast-1.amazonaws.com/xvxvxvx9/cloud-custodian
role: arn:aws:iam::xxxxx:role/cloud-custodian-mailer-role
from_address: test@mydomain.in

运行映像后,我在 SQS 或收件人的电子邮件中看不到任何消息。

另外,我怎样才能将输出也存储在 s3 上。

【问题讨论】:

    标签: amazon-web-services docker cloudcustodian


    【解决方案1】:

    docker hub cloud custodian 上已经有官方 docker 镜像:https://hub.docker.com/r/cloudcustodian/c7n

    如果您想将工具与 custodian 一起使用,那么 docker hub Ex 上还提供了单独的 docker 镜像。邮件人:https://hub.docker.com/r/cloudcustodian/mailer

    但是,如果您想在同一个容器中运行两者,请查看:https://github.com/harsh4870/cloud-custodian

    Dockerfile

    FROM python:3.6-alpine
    
    LABEL MAINTAINER="Harsh Manvar <harsh.manvar111@gmail.com>"
    
    WORKDIR /opt/src
    
    COPY cloud-custodian .
    RUN apk add --no-cache --virtual .build-deps gcc musl-dev
    RUN pip install -r requirements.txt && \
        python setup.py install && \
        cd tools/c7n_mailer/ && \
        pip install -r requirements.txt && \
        pip install requests && \
        python setup.py install
    RUN apk del .build-deps gcc musl-dev
    WORKDIR /opt/src
    
    COPY policy.yml policy.yml
    COPY mailer.yml mailer.yml
    
    ENTRYPOINT [ "/bin/sh" ]
    

    通过命令运行 docker 镜像

    docker run \
            -e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
            -e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
            -e AWS_DEFAULT_REGION="$(REGION)" \
            -v "$(CURDIR)/logs:/tmp" \
            "cloud-custodian:$(VERSION)" \
            -c "/usr/local/bin/custodian run -c policy.yml -s .; /usr/local/bin/c7n-mailer --config mailer.yml --run"
    

    【讨论】:

    • 为什么不单独使用两个容器?
    • 您可以根据自己的要求进行操作。我只为@cloudbud 制作了整个演示,并且要求就像一起运行托管人和邮件。
    • 可以理解。我想知道使用包含这两种工具的自定义容器与分别使用每个容器的优缺点是什么。从您的回答看来,唯一的优点是您不必下载 2 个单独的容器。我认为使用自定义容器与官方容器相比,缺点是更新周期更长。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多