如何在Docker上设置云托管人 [英] How to set up cloud custodian on Docker
问题描述
全部
我正在尝试在Fargate的AWS ECS计划任务上实施云托管解决方案.
I am trying to implement cloud custodian solution on AWS ECS scheduled task on Fargate.
我的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或收件人的电子邮件中看到任何消息.
After running the image I cannot see any message on the SQS or in the recipient's email.
此外,如何将输出也存储在s3上.
Also, how can I store the output on s3 also.
推荐答案
在Docker中心云托管者上已经有一个官方的docker镜像可用:
There is an official docker image already available on docker hub cloud custodian: https://hub.docker.com/r/cloudcustodian/c7n
如果您想与托管人一起使用工具,则在docker hub Ex上也可以使用单独的docker映像.邮件程序: https://hub.docker.com/r/cloudcustodian/mailer
if you want to use tools with custodian there is also separate docker images available on docker hub Ex. Mailer: https://hub.docker.com/r/cloudcustodian/mailer
但是,如果您想同时在同一容器中运行它们,请查看以下内容: https://github.com/harsh4870/cloud-custodian
however, if you want to run both in the same container please have a look at this : 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"
这篇关于如何在Docker上设置云托管人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!