{{announcement.body}}
{{announcement.title}}

Build Farms Made Easy With Kubernetes and OneDev

DZone 's Guide to

Build Farms Made Easy With Kubernetes and OneDev

Learn how the open-source OneDev can help you streamline your DevOps'/CI build processes while treating Docker and Kubernetes as first-class citizens.

· Cloud Zone ·
Free Resource

OneDev is an open source DevOps platform with language-aware code search, customizable issue tracking, and a Docker-first, Kubernetes-native CI/build engine. The project is hosted on GitHub: https://github.com/theonedev/onedev

If you're looking for other CI tools, check out another contributor's 20 favorites!

In this tutorial, we'll go through the process of setting up a build farm with Kubernetes and OneDev.

  1. Select the desired OneDev release and download "k8s-resources.zip"

  2. Unzip the file, change into directory "production", change the node selectors, memory settings, and disk settings if necessary, and  run the command  kubectl apply -k .   OneDev resources will be created under the namespace "onedev"

    NOTE:
    • Besides creating resources in the namespace "onedev", a cluster role "onedev" and associated cluster role binding "onedev" will be created in the default namespace. This is necessary, as OneDev needs to be granted some cluster-wide permissions to run builds as pods. For details, please check file "base/cluster-roles.yaml"

    • OneDev will create two persistent volume claims — one to store MySQL database files, and another to store OneDev data, including repositories. The actual place of these volumes varies depending on your Kubernetes cluster config. On Google Kubernetes Engine, they will be created as Google persistent disks.

  3. Wait a while for pods in the namespace "onedev" to get up and running. Run the command below to get the external IP address of the onedev service:
     kubectl get service onedev -n onedev 



  4. Point your browser to  http://<onedev-external-ip>  to set up OneDev. In the system settings page, just use the suggested server URL.

  5. From the OneDev projects page, add a project — we'll be calling ours "my-app"

  6. Run the command below from your local machine to create a React application:
     npx create-react-app my-app 
  7.    
  8. Move into the directory "my-app" and run the command below to push code to OneDev:
    git remote add origin 
    http://<onedev-external-ip>/projects/my-app git push origin master:master 

    When prompted, input the administrator account specified above as your git credentials.

  9. Visit the files page of project "my-app" from OneDev, click "add build spec" to bring up the GUI to add a build specification. For typical projects, OneDev suggests default job templates like below:

    default-job-template
       
  10. Just use the default template and save the spec. Now you will see that a CI build is running as a pod in your cluster.

    react-ci-build-as-a-pod

  11. Congrats! You've finished the tutorial. If you want to learn more, check out the typical usage scenarios.

Further Reading

Top 11 Continuous Delivery Tools for Kubernetes (Part 1)

How to Setup a CI/CD Pipeline with Kubernetes

    Topics:
    git ,devops ,docker ,ci/cd ,onedev ,open source software ,tutorial ,cloud ,kubernetes

    Published at DZone with permission of Robin Shen . See the original article here.

    Opinions expressed by DZone contributors are their own.

    {{ parent.title || parent.header.title}}

    {{ parent.tldr }}

    {{ parent.urlSource.name }}