DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Effortless OneDev CI/CD Farm withΒ Agents
Robin Shen
Robin Shen

Posted on

Effortless OneDev CI/CD Farm withΒ Agents

Introduction

From day 1, OneDev is able to run CI/CD jobs as pods on Kubernetes clusters. In case you do not have a Kubernetes cluster, it is now possible to install OneDev agents on other machines to get a CI/CD farm. Agent is designed to be maintenance free: the server will push updates to agents automatically when it is upgraded.

How to SetΒ Up

Let's go through an example to see how to set up the CI/CD farm

  1. Start OneDev server with below command on Linux or Mac (this command is for demonstration purpose, follow installation guide for production use):

    docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/onedev:/opt/onedev -p 6610:6610 -p 6611:6611 1dev/server
    
  2. Open browser to visit http://localhost:6610 to complete the setup

  3. Visit agent management page, click the add agent button, and show the docker command to run agent:
    Image description

  4. Copy the command to your terminal (Linux/Mac), change serverUrl environment to http://:6610 (do not use localhost here as otherwise OneDev agent running inside container can not access OneDev server), and run the command to start agent. If connected, the agent will be online in agent management page like below:
    Image description

  5. Now let's create a job executor to use the agent. Switch to job executors page, delete the default auto-discover executor, and create an executor of type Remote Docker Executor, give it a name and leave others as default. Test and save the setting:
    Image description

  6. Create a test project, define CI spec with a simple job, and run the job. You will see that the job is running on the agent:
    Image description

  7. When OneDev dispatches jobs to agents, it choses the best one based on agent cpu/memory capacity and job cpu/memory requirement. If no agents satisfies the requirement, the job will be in waiting state.

Thanks for reading!

Top comments (0)

Timeless DEV post...

Arguably the single most important piece of documentation for any open source project is the README. A good README not only informs people what the project does and who it is for but also how they use and contribute to it.

How to write a kickass README