Author: Adhing'a Fredrick
Last Updated: Wed, Feb 1, 2023GitHub Actions runner, is a CI/CD system for managing jobs in software projects hosted on GitHub. Runners can be installed in three levels: enterprise, organization, and repository.
In this tutorial, you will learn how to install and use GitHub Actions runner into Vultr Kubernetes Engine.
To follow through this tutorial, you need the following:
A GitHub account
A deployed Vultr Kubernetes Engine cluster with at least 3 nodes
The kubectl
CLI installed and configured in your machine
Access your VKE configuration file by following the steps below:
Login to your Vultr account and navigate to Products > Kubernetes > {Your cluster}>Overview.
Click on the Download Configuration button to download your kubeconfig file.
Note: Keep this configuration file for later use when setting up your GitHub runner.
Install a cert-manager in your VKE cluster using the command below:
$ kubectl --kubeconfig={VKE_CLUSTER_CONFIG_FILE_PATH} apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml
Generate a Personal Access Token (PAT) for ARC for GitHub authentication.
Sign in to your GitHub account and navigate to the Create new Token. page.
Enter a Note for the token to be generated. An example can be Action-Runner
Select repo and workflow.
Customize the time you want the token to last by Adjusting the Expiration settings.
Click the Generate Token button to generate the token.
Copy and securely store the token locally for later use.
To configure and deploy ARC on your VKE k8s using kubectl, follow the steps below:
Deploy the ARC using the command below:
$ kubectl --kubeconfig={VKE_CLUSTER_CONFIG_FILE_PATH} create -f https://github.com/actions/actions-runner-controller/releases/download/v0.26.0/actions-runner-controller.yaml
As at the time of writing this, the latest version is v0.26.0
. Customize the version to your desired ARC version.
Configure the Personal Access Token using the token you saved earlier in the tutorial.
$ kubectl --kubeconfig={VKE_CLUSTER_CONFIG_FILE_PATH} create secret generic controller-manager -n actions-runner-system --from-literal=github_token=PAT_TOKEN
Replace the PAT_TOKEN
with your GitHub PAT token.
Create a runnerdeployment.yaml
file and copy the following YAML contents into it:
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
name: example-runnerdeploy
spec:
replicas: 1
template:
spec:
repository: FREDERICO23/arc-runner
The runnerdeployment.yaml
file is used to create a self-hosted runner and configure it to run against your GitHub repository.
Note: Replace "FREDERICO23/arc-runner" with your repository name.
Apply the runnerdeployment.yaml
file to your K8s cluster as follows:
$ kubectl --kubeconfig={VKE_CLUSTER_CONFIG_FILE_PATH} apply -f runnerdeployment.yaml
Confirm if the installation was successful using the command below:
$ kubectl --kubeconfig={VKE_CLUSTER_CONFIG_FILE_PATH} get runners
Expected Output:
NAME ENTERPRISE ORGANIZATION REPOSITORY GROUP LABELS STATUS MESSAGE AGE
runnerdeploy-gcvdr-bdpf5 FREDERICO23/arc-runner Running 39s
Check the pods status:
$ kubectl --kubeconfig={VKE_CLUSTER_CONFIG_FILE_PATH} get pod
Expected Output:
NAME READY STATUS RESTARTS AGE
runnerdeploy-gcvdr-bdpf5 2/2 Running 0 5m11s
You've finished installing GitHub Actions runner on your VKE. You can now go to your repository settings and check if the runner exists.
To use the previously installed runner, you need a GitHub Actions workflow.
Create a .github/workflows
folder on your repo where the runner is installed. 2. Inside the folder, .github/workflows
, create a hello-world.yml
file and paste the following GitHub Actions Demo content in it.
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions ð
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "ð The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "ð§ This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "ð The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "ð¡ The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "ð¥ï¸ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "ð This job's status is ${{ job.status }}."
Save and commit the file.
On your repo directory, click the Actions tab. You will see the recently created Hello World workflow listed.
You have finished installing GitHub Action Runner in Vultr Kubernetes Engine (VKE) cluster using kubectl and learned how to use it to manage your workflows. You can now create and manage CD/CI projects using the GitHub Actions runner and VKE.