Hey, just needed help on this issue, my agents appear to be offline and I’m not able to debug this issue from a long time
Hi,
Could you share more details about the issue you’re facing? Does it handle heavy workloads and then go offline, or does it always show as offline?
Sure
So the configuration I want is:
Jenkins master on an ec2, with ECS EC2 launch type with ASG which will act as slaves
I’m not able to run jobs and connect to ECS, with the instances provisioned by ASG
User data:
#!/bin/bash
sudo apt update -y && sudo apt upgrade -y
sudo apt install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker
sudo apt install -y openjdk-21-jdk
java --version
sudo apt install -y maven
export MAVEN_HOME="/usr/share/maven"
export MAVEN_CONFIG="/etc/maven"
export PATH="$MAVEN_HOME/bin:$PATH"
# shellcheck disable=SC2129
sudo echo "export MAVEN_HOME=/usr/share/maven" >> /etc/profile.d/maven.sh
sudo echo "export MAVEN_CONFIG=/etc/maven" >> /etc/profile.d/maven.sh
sudo echo "export PATH=\$MAVEN_HOME/bin:\$PATH" >> /etc/profile.d/maven.sh
sudo chmod +x /etc/profile.d/maven.sh
sudo source /etc/profile.d/maven.sh
sudo usermod -aG docker $USER
sudo snap install aws-cli --classic
sudo systemctl restart docker
export AWS_REGION="us-east-1"
export OS_PACKAGE="amd64.deb"
curl -O https://s3.${AWS_REGION}.amazonaws.com/amazon-ecs-agent-${AWS_REGION}/amazon-ecs-init-latest.${OS_PACKAGE}
sudo dpkg -i amazon-ecs-init-latest.${OS_PACKAGE}
sudo sed -i '/\[Unit\]/a After=cloud-final.service' /lib/systemd/system/ecs.service
echo "ECS_CLUSTER=ecs-jenkins-cluster" | sudo tee /etc/ecs/ecs.config
sudo systemctl enable ecs
sudo systemctl daemon-reload
sudo systemctl restart ecs
sudo systemctl reboot
sudo chmod 666 /var/run/docker.sock
SERVICE="ecs"
while true
do
# Check if service is running
if ! systemctl is-active --quiet $SERVICE
then
echo "Service $SERVICE is down. Restarting..."
systemctl restart $SERVICE
fi
# Wait for 2 minutes
sleep 120
done
I’m using ECS Fargate plugin in Jenkins to configure the cloud