How to Set Up Jenkins Agent on Kubernetes for Task Execution?

0
3
Asked By CloudyNomad42 On

Hey everyone! I'm pretty familiar with Kubernetes, but I'm new to Jenkins and could use some guidance. I recently switched jobs and am working with Jenkins now. I'm looking to run a Jenkins agent similar to how a GitLab runner operates, which means I want it to poll for jobs/tasks and execute them within the same cluster/namespace (using the right service account). Ultimately, I want this Jenkins executor to perform a `helm install`. Has anyone set up something like this before and can offer any advice? Thanks!

1 Answer

Answered By DevGuru_101 On

Check out the Kubernetes plugin for Jenkins – it’s exactly what you need! It can spawn Jenkins executors whenever a new job is triggered. The documentation is quite helpful, and you'll find more resources around it too.

K8sExpert88 -

We're transitioning our Jenkins builds to a Kubernetes setup using this plugin. Most of our jobs are working perfectly fine with it. I recommend creating custom agent images with the necessary tools pre-installed. You can map image paths in your pod templates right in Jenkins. Also, setting up Docker-in-Docker (DinD) didn't take much effort and helps maintain consistency in builds—agents can build and run Docker images inside the pods. We deploy using the official Jenkins helm chart and manage our configs with Jenkins Configuration as Code (CasC) via values files. For `helm install`, we use a separate pod template that inherits from the main one but has a service account set up with appropriate permissions.

NiceGuy_Nate -

I appreciate the info! I think I’ve seen similar setups in parts of our infrastructure. However, I find the configuration section a bit tricky. I’m considering using kubeconfig to get the cluster token, since we're on EKS, and it's all about Roles and Trust Relationships. Do you think that approach will work?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.