CI Pipeline with Drone and Kubernetes Runner using Gitea

In this post, we will create a new git repository on Gitea and create a .drone.yml file which will be the definition of our CI job for Drone.

First, create the Gitea Repository:

image

Next, create a new file, .drone.yml with the following content:

kind: pipeline  
name: default  
type: kubernetes

platform:  
  os: linux
  arch: arm

node:  
  hardware: rpi
  runnerid: default

steps:  
  - name: test
    image: busybox
    privileged: true
    commands:
      - uname -a
      - echo $$(hostname)

Let's go through the file in segments.

We are defining that it's a pipeline, we provide a name default and that we are defining that we will be using it with the kubernetes type which we will use our kubernetes runner to run the tasks.

Then we are defining the platform is arm and linux as the runner is hosted on a raspberry pi, more info here

Now this is where the labels constraints comes in, we are instructing drone to only launch this task on a runner with the labels: hardware:rpi,runnerid:default as mentioned in DRONE_RUNNER_LABELS on our kubernetes runner post. More info here

Then our steps will be the instructions of the task that will be run, in this example we will be using the busybox docker image to run:

  • uname -a
  • echo $hostname (can be $${HOSTNAME} or $HOSTNAME for an env var )

After you commit the file to gitea, head over to your drone ui and select "Sync", then you should see your gitea repository:

image

Activate the repository, then head over to settings if you would like to configure your replository further. You will see that it shows you the drone config that it will read, and by default it is .drone.yml:

image

Select save, then head over to gitea and commit a dummy file to gitea:

image

Once you commit the file to gitea, you will see in the drone ui that the pipeline has kicked off and we can look at the task's build logs:

image

And we will see that the task completed.

This was a basic example, but you can do powerful things with Drone: