We now have a dedicated managed node group with Spot capacity. We also installed the Naginator plugin which will allow us to retry failed jobs.
sleep 2m; echo "Job finished successfully"
20
for Fixed delay3
Since this workshop module focuses on resilience and cost optimization for Jenkins jobs, we are running a very simple job that will not perform any actions other than to sleep for 2 minutes and echo a message that it finished successfully to the console.
'jenkins-agent-'
.
Execute the following command on Cloud9 terminal
kubectl get svc kube-ops-view | tail -n 1 | awk '{ print "Kube-ops-view URL = http://"$4 }'
jenkins-agents-mng-spot-2vcpu-8gb
? If so, it means that our labeling and Node Selector were configured successfully.kubectl get pods
, and find the name of the Jenkins controller pod (i.e cicd-jenkins-*
).kubectl logs -f <pod name from last step> -c jenkins
.Building remotely on jenkins-agent-nkz2z (cicd-jenkins-agent) in workspace /home/jenkins/agent/workspace/Sleep-2m
[Sleep-2m] $ /bin/sh -xe /tmp/jenkins7588311786413895922.sh
+ sleep 2m
+ echo Job finished successfully
Job finished successfully
Finished: SUCCESS
Now that we ran our job successfully on Spot Instances, let’s test the failure scenario. We will demonstrate a failure by simply terminating the instance that our job/pod is running on.
kubectl get po --selector jenkins/cicd-jenkins-agent=true -o wide
to find the Jenkins agent pod and the node on which it is running.kubectl describe node <node name from the last command>
to find the node’s EC2 Instance ID under ProviderID: aws:///*/i-xxxxx
.aws ec2 terminate-instances --instance-ids <instance ID from last command>
.Now that we successfully ran a job on a Spot Instance, and automatically restarted a job due to a simulated node failure, let’s move to the next step in the workshop and autoscale our Jenkins nodes.