65
loading...
This website collects cookies to deliver better user experience
Self-hosted runners are ideal for use-cases where you need to run workflows in a highly customizable environment with more granular control over hardware requirements, security, operating system, and software tools than GitHub-hosted runners provides.
Self-hosted runners can be physical, virtual, in a container, on-premises, or in a cloud. In this guide, we’ll deploy it as a container in the Kubernetes cluster in the AWS cloud.
If you already have an existing K8s cluster, feel free to skip this step.
us-east-1
region with a dedicated VPC. Feel free to modify the cluster config as per your requirements. See more examples configscluster-config.yaml
$ eksctl create cluster -f cluster-config.yaml
NOTE: The cluster creation may take upto 15–20 minutes.
2021-06-22 19:14:19 [✔] EKS cluster "github-actions" in "us-east-1" region is ready
$HOME/.kube/config
automatically by eksctl
$ kubectl get nodes
$ kubectl get namespaces
Helm is a package manager for Kubernetes to easily install and manage Kubernetes applications. See Installing Helm
action-runner controller operates self-hosted runners for GitHub Actions on the Kubernetes cluster. It provides CRDs (Custom Resource Definition) such as Runner
RunnerDeployment
HorizontalRunnerAutoscaler
which allows us to easily deploy a scalable self-hosted runners on Kubernetes.
# Add repository
$ helm repo add jetstack https://charts.jetstack.io
$ helm repo update
# Install chart
$ helm install --wait --create-namespace --namespace cert-manager cert-manager jetstack/cert-manager --version v1.3.0 --set installCRDs=true
# Verify installation
$ kubectl --namespace cert-manager get all
Generate new token button
repo (Full Control)
scope.Generate Token
custom-values.yaml
as such:authSecret:
github_token: REPLACE_YOUR_TOKEN_HERE
# Add repository
$ helm repo add actions-runner-controller https://actions-runner-controller.github.io/actions-runner-controller
# Install chart
$ helm install -f custom-values.yaml --wait --namespace actions-runner-system --create-namespace actions-runner-controller actions-runner-controller/actions-runner-controller
# Verify installation
$ kubectl --namespace actions-runner-system get all
$ kubectl create namespace self-hosted-runners
self-hosted-runner.yaml
, and modify the following:tuladhar/self-hosted-runner
with your own repository.minReplicas
and maxReplicas
as required.$ kubectl --namespace self-hosted-runners apply -f self-hosted-runner.yaml
$ kubectl --namespace self-hosted-runners get runner
Settings > Actions > Runner
to view the registered runner.🚀 We’re now ready to give our self-hosted runner a try!
.github/workflows/hello-world.yml
in your repository where the self-hosted runner is registered.NOTE: The important part of this workflow is runs-on: self-hosted
$ eksctl delete cluster -f cluster-config.yaml
2021-06-22 20:16:02 [ℹ] eksctl version 0.54.0
2021-06-22 20:16:02 [ℹ] using region us-east-1
2021-06-22 20:16:02 [ℹ] deleting EKS cluster "github-actions"
2021-06-22 20:16:06 [ℹ] deleted 0 Fargate profile(s)
2021-06-22 20:16:10 [✔] kubeconfig has been updated
2021-06-22 20:16:10 [ℹ] cleaning up AWS load balancers created by Kubernetes objects of Kind Service or Ingress
2021-06-22 20:16:23 [ℹ] 2 sequential tasks: { delete nodegroup "ng-1", delete cluster control plane "github-actions" [async] }
2021-06-22 20:16:23 [ℹ] will delete stack "eksctl-github-actions-nodegroup-ng-1"
2021-06-22 20:16:23 [ℹ] waiting for stack "eksctl-github-actions-
2021-06-22 20:18:21 [ℹ] will delete stack "eksctl-github-actions-cluster"
2021-06-22 20:18:22 [✔] all cluster resources were deleted