JonCubed / docker-jenkins-jnlp-slave-windows

Jenkins JNLP Slaves as Windows Container
MIT License
26 stars 21 forks source link

AWS ECS + Jenkins integration #2

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hello. I want to use Jenkins plugin: https://wiki.jenkins.io/display/JENKINS/Amazon+EC2+Container+Service+Plugin and tried to use your image: jonathank/jenkins-jnlp-slave-windows instead of jenkins/jnlp-slave (works good in linux). But it doesn't work and I don't understand why (logs are very poor) (( Did you try to connect your image to aws ecs and jenkins?

Jenkins log:

Apr 25, 2018 4:21:29 PM hudson.slaves.NodeProvisioner$StandardStrategyImpl apply INFO: Started provisioning ECS Slave ecs-windows from ecs-cloud with 1 executors. Remaining excess workload: 0 Apr 25, 2018 4:21:30 PM com.cloudbees.jenkins.plugins.amazonecs.ECSService waitForSufficientClusterResources INFO: Found 1 instances Apr 25, 2018 4:21:30 PM com.cloudbees.jenkins.plugins.amazonecs.ECSService waitForSufficientClusterResources INFO: Resources found in instance arn:aws:ecs:us-east-1:184542755555:container-instance/47bc7f7b-8003-4c1b-9e1b-719c132bf46b: [{Name: CPU,Type: INTEGER,DoubleValue: 0.0,LongValue: 0,IntegerValue: 2048,StringSetValue: []}, {Name: MEMORY,Type: INTEGER,DoubleValue: 0.0,LongValue: 0,IntegerValue: 4095,StringSetValue: []}, {Name: PORTS,Type: STRINGSET,DoubleValue: 0.0,LongValue: 0,IntegerValue: 0,StringSetValue: [135, 445, 3389, 2376, 139, 2375, 80, 5985, 51678, 51679, 53]}, {Name: PORTS_UDP,Type: STRINGSET,DoubleValue: 0.0,LongValue: 0,IntegerValue: 0,StringSetValue: []}] Apr 25, 2018 4:21:30 PM com.cloudbees.jenkins.plugins.amazonecs.ECSService waitForSufficientClusterResources INFO: Instance arn:aws:ecs:us-east-1:184542755555:container-instance/47bc7f7b-8003-4c1b-9e1b-719c132bf46b has 4,095mb of free memory. 512mb are required Apr 25, 2018 4:21:30 PM com.cloudbees.jenkins.plugins.amazonecs.ECSService waitForSufficientClusterResources INFO: Instance arn:aws:ecs:us-east-1:184542755555:container-instance/47bc7f7b-8003-4c1b-9e1b-719c132bf46b has 2,048 units of free cpu. 1 units are required Apr 25, 2018 4:21:30 PM com.cloudbees.jenkins.plugins.amazonecs.ECSCloud$ProvisioningCallback call INFO: Created Slave: ecs-cloud-f6b05ed3d58e6 Apr 25, 2018 4:21:30 PM com.cloudbees.jenkins.plugins.amazonecs.ECSService registerTemplate INFO: Match on container definition: true Apr 25, 2018 4:21:30 PM com.cloudbees.jenkins.plugins.amazonecs.ECSService registerTemplate INFO: Match on volumes: true Apr 25, 2018 4:21:30 PM com.cloudbees.jenkins.plugins.amazonecs.ECSService registerTemplate INFO: Match on task role: true Apr 25, 2018 4:21:30 PM com.cloudbees.jenkins.plugins.amazonecs.ECSCloud$ProvisioningCallback call INFO: Slave ecs-cloud-f6b05ed3d58e6 - Slave Task Started : arn:aws:ecs:us-east-1:184542755555:task/3498c8c2-735e-419a-8b77-eb5dae4050f2

JonCubed commented 6 years ago

@sgithubs manage to make any headway with this?

I have been running a derivative of this image with ecs and jenkins, for months. If you are still having troubles with this, let me know I'll try my best to help you out.

ghost commented 6 years ago

Thanks @JonCubed. I think I won and it works. But the building of the project takes 11 minutes. It is so long... :(

burtonr commented 6 years ago

@sgithubs Could you expand a little on what your issue was and how you resolved it? I am in the process of setting this up on ECS as well, and want to make sure I don't end up with a similar issue. Thanks!

ghost commented 6 years ago

@BurtonR I have configured:

  1. aws ecs fargate cluster.
  2. jenkins ecs plugin: https://wiki.jenkins.io/display/JENKINS/Amazon+EC2+Container+Service+Plugin
  3. "ECS slave templates" inside jenkins main configure should be:

Template Name |   jnlp-slave Label |  ecs-windows Docker Image |   jonathank/jenkins-jnlp-slave-windows Filesystem root |  c:\\Jenkins Soft Memory Reservation | 0

  1. Inside jenkins job: Restrict where this project can be run: ecs-windows
burtonr commented 6 years ago

Great! Thank you @sgithubs! That's also great you have it running on Fargate as that is our plan as well. Thanks for the quick response! :100:

JonCubed commented 6 years ago

@sgithubs no super familiar with fargate yet but I found that in normal ECS, upping the instance size made for quicker builds. In Fargate terms this probably mean higher CPU

JonCubed commented 6 years ago

@sgithubs I'm going to close this now, feel free to reopen if you think there is something still outstanding

prashanthkasoju commented 5 years ago

@burtonr I have configured:

  1. aws ecs fargate cluster.
  2. jenkins ecs plugin: https://wiki.jenkins.io/display/JENKINS/Amazon+EC2+Container+Service+Plugin
  3. "ECS slave templates" inside jenkins main configure should be:

Template Name |   jnlp-slave Label |  ecs-windows Docker Image |   jonathank/jenkins-jnlp-slave-windows Filesystem root |  c:\Jenkins Soft Memory Reservation | 0

  1. Inside jenkins job: Restrict where this project can be run: ecs-windows

@burtonr I have configured:

  1. aws ecs fargate cluster.
  2. jenkins ecs plugin: https://wiki.jenkins.io/display/JENKINS/Amazon+EC2+Container+Service+Plugin
  3. "ECS slave templates" inside jenkins main configure should be:

Template Name |   jnlp-slave Label |  ecs-windows Docker Image |   jonathank/jenkins-jnlp-slave-windows Filesystem root |  c:\Jenkins Soft Memory Reservation | 0

  1. Inside jenkins job: Restrict where this project can be run: ecs-windows

Hello: we have tried using ecs plugin for spinngup linux fargate container using docker image jenkinsci/jnlp-slave and working fine.

Now we are trying to spinup windows fargate and we are using same docker image jenkinsci/jnlp-slave and the slave is spinningup but we have observed jnlpurl and secret text on the agent , but now the question is how to pass this values to the container?

we have tried using jonathank/jenkins-jnlp-slave-windows docker image still not working .

Could you please share your configuration for windows which was working for you and help us in resoving this issue? is there any pre defined docker image that we can leverage for windows fargate container?

appreciate your help here.

prashanthkasoju commented 5 years ago

image

prashanthkasoju commented 5 years ago

Above is my configuration screenshot which i have tried still not working . below is my log image

JonCubed commented 5 years ago

@prashanthkasoju I havent used it with fargate, 2 things I can think of to help diagnose what is going wrong are. Check ECS console to see if the containers are trying to start, there could be an error message there. The other is make sure you have specified the two roles in your configuration (was not included in your screenshot above)

prashanthkasoju commented 5 years ago

Hi Jonathan,

many thanks for replying to my post. i am including the screenshots which you have requested. image

when i am running the job by restricting the label 'fargate_tss_dev_windows we have observed ECS is trying to provision a new fargate slave and waiting for few seconds and terminating and again it is trying to start new slave and waiting for few seconds and terminating.

attaching few screenshot from ECS cluster as well. image image

Below is the output from my linux server.

INFO: [ecs_windows-qw4tz]: Waiting for agent to start Aug 12, 2019 4:39:06 AM com.cloudbees.jenkins.plugins.amazonecs.ECSLauncher launch INFO: [ecs_windows-qw4tz]: Waiting for agent to start Aug 12, 2019 4:39:07 AM com.cloudbees.jenkins.plugins.amazonecs.ECSLauncher launch INFO: [ecs_windows-qw4tz]: Waiting for agent to start Aug 12, 2019 4:39:08 AM com.cloudbees.jenkins.plugins.amazonecs.ECSLauncher launch INFO: [ecs_windows-qw4tz]: Waiting for agent to start

Please help me if iam missing any configuration and you let me know if you need further information. thank you, Prashanth k.

prashanthkasoju commented 5 years ago

FYI .. whole configuration looks like this. image image

JonCubed commented 5 years ago

@prashanthkasoju under Advanced.. you need to fill Task Role ARN and Task Execution Role ARN jenkins roles You can also click on the task id in the console and look at the containers for extra information on why it exited

prashanthkasoju commented 5 years ago

Hello,

i just want to mention on point here . i have did similar kind of configuration for linux and it is working fine and it is spinning fargate container in aws cluster there we have not mentioned Task Role ARN & Task Execution Role ARN ,both are empty still we could able to spinup fargate containers.