We now have our Jenkins Master running inside our EKS cluster, and we can reach the Jenkins dashboard via an ELB. We can create jobs which will be executed by Jenkins agents in pods within our cluster, but before we do that, let’s create a dedicated Spot based nodegroup for our Jenkins agents, which will be slightly different from our existing nodegroups. In the next section in the workshop, Increasing Resilience, you will understand why we’re creating a new nodegroup which is different than our existing nodegroups, dedicated to the Jenkins agent pods.
Earlier in the workshop, in the Adding Spot Workers with eksctl step, we created nodegroups that run a diversified set of Spot Instances to run our applications.
Let’s create a new eksctl nodegroup configuration file called
spot_nodegroup_jenkins.yml. The Jenkins default resource requirements (Request and Limit CPU/Memory) are 512m (~0.5 vCPU) and 512Mi (~0.5 GB RAM), and since we are not going to perform any large build jobs in this workshop, we can stick to the defaults and also choose relatively small instance types that can accommodate the Jenkins agent pods.
cat <<EoF > ~/environment/spot_nodegroup_jenkins.yml apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: eksworkshop-eksctl region: $AWS_REGION nodeGroups: - name: jenkins-agents-2vcpu-8gb-spot minSize: 1 maxSize: 5 instancesDistribution: instanceTypes: ["m5.large", "m5d.large", "m4.large","t3.large","t3a.large","m5a.large","t2.large"] onDemandBaseCapacity: 0 onDemandPercentageAboveBaseCapacity: 0 spotInstancePools: 4 labels: lifecycle: Ec2Spot intent: jenkins-agents tags: k8s.io/cluster-autoscaler/node-template/label/intent: jenkins-agents EoF
This will create a
spot_nodegroup_jenkins.yml file that we will use to instruct eksctl to create one nodegroup (EC2 Auto Scaling group), with the labels
intent: jenkins-agents and
lifecycle: Ec2Spot. The ASG will also have a custom tag key
k8s.io/cluster-autoscaler/node-template/label/intent with the value
jenkins-agents - This is in order for Kubernetes cluster-autoscaler to respect the node selector configuration that we will apply later in the module.
eksctl create nodegroup -f spot_nodegroup_jenkins.yml
The creation of the workers will take about 3 minutes.
Now, when Jenkins creates new pods (=agents), these will be created with a Node Selector that instructs the kube-scheduler to only deploy the pods on nodes with the above mentioned labels, which only exist in the dedicated Jenkins nodegroup.
The last step is to change the default pod name for the Jenkins agents, because we want to be able to identify the pods that are running in our clusters by name.
1. In the Jenkins Dashboard, go to Manage Jenkins -> Configure System -> Scroll down to the Kubernetes Pod Template and change the Name field from
2. Click Save
Move to the next step in the workshop to learn how to increase the resilience of your Jenkins jobs.