
Introduction
GitHub 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.
Prerequisites
To follow through this tutorial, you need the following:
- A GitHub account
- A deployed Vultr Kubernetes Engine cluster with at least 3 nodes
- The
kubectlCLI installed and configured in your machine
VKE Configuration
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.
Setting Up Runner Requirements
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.yamlGenerate 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.
Deploy and Configure Actions Runner Controller
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.yamlAs 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_TOKENReplace the
PAT_TOKENwith your GitHub PAT token.Create a
runnerdeployment.yamlfile 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-runnerThe
runnerdeployment.yamlfile 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.yamlfile to your K8s cluster as follows:$ kubectl --kubeconfig={VKE_CLUSTER_CONFIG_FILE_PATH} apply -f runnerdeployment.yamlConfirm if the installation was successful using the command below:
$ kubectl --kubeconfig={VKE_CLUSTER_CONFIG_FILE_PATH} get runnersExpected Output:
NAME ENTERPRISE ORGANIZATION REPOSITORY GROUP LABELS STATUS MESSAGE AGE runnerdeploy-gcvdr-bdpf5 FREDERICO23/arc-runner Running 39sCheck the pods status:
$ kubectl --kubeconfig={VKE_CLUSTER_CONFIG_FILE_PATH} get podExpected 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.
Using self-hosted runners in a workflow
To use the previously installed runner, you need a GitHub Actions workflow.
Create a
.github/workflowsfolder on your repo where the runner is installed. 2. Inside the folder,.github/workflows, create ahello-world.ymlfile 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.
Conclusion
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.