简体   繁体   English

AWS 上的 Dockerized Jenkins 服务器

[英]Dockerized Jenkins server on AWS

I have a dockerized Jenkins build server set up like below and I want move it to AWS.我有一个 dockerized Jenkins 构建服务器,如下所示,我想将它移动到 AWS。

I have some questions on how to do it, Thanks.我有一些关于如何做的问题,谢谢。

  1. Is ECS the right choice to deploy dockerized Jenkins agents? ECS 是部署 dockerized Jenkins 代理的正确选择吗?

  2. Is Fargate launch type of ECS support Windows containers? Fargate 启动类型的 ECS 是否支持 Windows 容器?

  3. I know ECS can dynamically provision EC2 instances, can ECS provision like below?我知道 ECS 可以动态配置 EC2 实例,ECS 可以像下面这样配置吗?

    a.一个。 If there is no job to build, there is no ECS2 instance running in the cluster.如果没有要构建的作业,则集群中没有运行 ECS2 实例。

    b.湾。 If a build job started, ECS dynamically launch a EC2 instance to run the dockerized agents to handle it.如果构建作业启动,ECS 会动态启动 EC2 实例以运行 dockerized 代理来处理它。

    c. c。 After build job is finished, ECS cluster will automatically stop or terminate the running EC2 instance.构建作业完成后,ECS 集群将自动停止或终止正在运行的 EC2 实例。

================================================================== ==================================================== =================

Jenkins master:
Runs as a Linux container hosted on a UBUNTU virtual machine.

Jenkins Agents:

Linux Agent:
Runs as a Linux container hosted on the same UBUNTU virtual machine as master.

Windows Agents:
Runs as a windows container hosted on a Windows server 2019. 

Well, I have some tips for you:好吧,我有一些建议给你:

  • Yes, ECS can dynamically provision EC2 Instances using autoscaling, but only when the threshold of a metric is reached in cloudwatch and an alarm is thrown out and autoscaling start to works.是的,ECS 可以使用自动缩放动态配置 EC2 实例,但前提是在 cloudwatch 中达到指标阈值并且发出警报并且自动缩放开始起作用。 Start a task in ECS with a jenkins master server, and then start 1 or 2 agents when you go to execute a job is not a good tactic neither practical idea, who going to wake up these tasks?用 jenkins 主服务器在 ECS 中启动任务,然后在 go 执行任务时启动 1 或 2 个代理,这不是一个好策略,也不是实用的想法,谁来唤醒这些任务?

  • If you want to use a jenkins docker inside an EC2 instance and you have a master node running and you want to keep stopped your unused agents and start it only if is needed by a job maybe in your Jenkinsfile you can call a lambda function to start your agent, here and example in a Jenkinsfile: If you want to use a jenkins docker inside an EC2 instance and you have a master node running and you want to keep stopped your unused agents and start it only if is needed by a job maybe in your Jenkinsfile you can call a lambda function to start您的代理,此处和 Jenkinsfile 中的示例:

     stage('Start Infrastructure') { steps { sh ''' #:/bin/bash aws lambda invoke --function-name Wake_Up_Jenkins_Agent --invocation-type Event --log-type Tail --payload '{"node","NodeJS-Java-Agent":"action"."start"}' logsfile.txt ''' } }

And later another stage to stop your agent, but your master node need to be online because it is the key and main component either called from the repository or your CI/CD process.稍后另一个阶段停止您的代理,但您的主节点需要在线,因为它是从存储库或 CI/CD 流程调用的关键和主要组件。 Also you need to implement the lambda with a logical procedure to start or stop the instance.您还需要使用逻辑过程来实现 lambda 以启动或停止实例。

  • In my experience run Jenkins directly in EC2 is a better choice that run it in ECS or Fargate.根据我的经验,直接在 EC2 中运行 Jenkins 是在 ECS 或 Fargate 中运行它的更好选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM