-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
810 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
## Introduction | ||
This document provides a high level overview of Actions Runner Controller (ARC). ARC enables running Github Actions Runners on Kubernetes (K8s) clusters. | ||
|
||
This document provides a background of Github Actions, self-hosted runners and ARC overview. By the end of the doc, the reader should have a foundation with basic scenarios and be capable of reviewing other advanced topics. | ||
|
||
## GitHub Actions | ||
[GitHub Actions]](https://github.com/features/actions) is a continuous integration and continuous delivery (CI/CD) platform to automate your build, test, and deployment pipeline. | ||
|
||
You can create workflows that build and test every pull request to your repository, or deploy merged pull requests to production. Your workflow contains one or more jobs which can run in sequential order or in parallel. Each job will run inside its own runner and has one or more steps that either run a script that you define or run an action, which is a reusable extension that can simplify your workflow. To learn more about about Actions - see "[Learn Github Actions](https://docs.github.com/en/actions/learn-github-actions)". | ||
|
||
## Runners | ||
Runners execute the job that is assigned to them by Github Actions workflow. There are two types of Runners: | ||
|
||
- [Github-hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners) - GitHub provides Linux, Windows, and macOS virtual machines to run your workflows. These virtual machines are hosted in the cloud by Github. | ||
- [Self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners) - you can host your own self-hosted runners in your own data center or cloud infrastructure. ARC deploys self-hosted runners. | ||
|
||
## Self hosted runners | ||
Self-hosted runners offer more control of hardware, operating system, and software tools than GitHub-hosted runners. With self-hosted runners, you can create custom hardware configurations that meet your needs with processing power or memory to run larger jobs, install software available on your local network, and choose an operating system not offered by GitHub-hosted runners. | ||
|
||
### Types of Self hosted runners | ||
Self-hosted runners can be physical, virtual, in a container, on-premises, or in a cloud. | ||
- Traditional Deployment is having a physical machine, with OS and apps on it. The runner runs on this machine and executes any jobs. It comes with the cost of owning and operating the hardware 24/7 even if it isn't in use that entire time. | ||
- Virtualized deployments are simpler to manage. Each runner runs on a virtual machine (VM) that runs on a host. There could be multiple such VMs running on the same host. VMs are complete OS’s and might take time to bring up everytime a clean environment is needed to run workflows. | ||
- Containerized deployments are similar to VMs, but instead of bringing up entire VM’s, a container gets deployed.Kubernetes (K8s) provides a scalable and reproducible environment for containerized workloads. They are lightweight, loosely coupled, highly efficient and can be managed centrally. There are advantages to using Kubernetes (outlined "[here](https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/)."), but it is more complicated and less widely-understood than the other options. A managed provider makes this much simpler to run at scale. | ||
|
||
*Actions Runner Controller(ARC) makes it simpler to run self hosted runners on K8s managed containers.* | ||
|
||
## Actions Runner Controller (ARC) | ||
ARC is a K8s controller to create self-hosted runners on your K8s cluster. With few commands, you can set up self hosted runners that can scale up and down based on demand. And since these could be ephemeral and based on containers, new instances of the runner can be brought up rapidly and cleanly. | ||
|
||
### Deploying ARC | ||
We have a quick start guide that demonstrates how to easily deploy ARC into your K8s environment. For more details, see "[QuickStart Guide](https://github.com/actions-runner-controller/actions-runner-controller/blob/master/QuickStartGuide.md)." | ||
|
||
## ARC components | ||
ARC basically consists of a set of custom resources. An ARC deployment is applying these custom resources onto a K8s cluster. Once applied, it creates a set of Pods, with the Github Actions runner running within them. Github is now able to treat these Pods as self hosted runners and allocate jobs to them. | ||
|
||
### Custom resources | ||
ARC consists of several custom resource definitions (Runner, Runner Set, Runner Deployment, Runner Replica Set and Horizontal Runner AutoScaler). For more information on CRDs, refer "[Kubernetes Custom Resources](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/)." | ||
|
||
The helm command (in the QuickStart guide) installs the custom resources into the actions-runner-system namespace. | ||
```console | ||
helm install -f custom-values.yaml --wait --namespace actions-runner-system \ | ||
--create-namespace actions-runner-controller \ | ||
actions-runner-controller/actions-runner-controller | ||
``` | ||
|
||
### Runner deployment | ||
Once the custom resources are installed, another command deploys ARC into your K8s cluster. | ||
|
||
 | ||
|
||
|
||
|
||
The `Deployment and Configure ARC` section in the `Quick Start guide` lists the steps to deploy ARC using a `runnerdeployment.yaml` file. Here, we will explain the details | ||
For more details, see "[QuickStart Guide](https://github.com/actions-runner-controller/actions-runner-controller/blob/master/QuickStartGuide.md)." | ||
|
||
```yaml | ||
apiVersion: actions.summerwind.dev/v1alpha1 | ||
kind: RunnerDeployment | ||
metadata: | ||
name: example-runnerdeploy | ||
spec: | ||
replicas: 1 | ||
template: | ||
spec: | ||
repository: mumoshu/actions-runner-controller-ci | ||
``` | ||
- `kind: RunnerDeployment`: indicates its a kind of custom resource RunnerDeployment. | ||
- `replicas: 1` : will deploy one replica. Multiple replicas can also be deployed ( more on that later). | ||
- `repository: mumoshu/actions-runner-controller-ci` : is the repository to link to when the pod comes up with the Actions runner (Note, this can be configured to link at the Enterprise or Organization level also). | ||
|
||
When this configuration is applied with `kubectl apply -f runnerdeployment.yaml` , ARC creates one pod `example-runnerdeploy-[**]` with 2 containers `runner` and `docker`. | ||
`runner` container has the github runner component installed, `docker` container has docker installed. | ||
|
||
|
||
### The Runner container image | ||
The GitHub hosted runners include a large amount of pre-installed software packages. For complete list, see "[Runner images](https://github.com/actions/virtual-environments/tree/main/images/linux)." | ||
|
||
ARC maintains a few runner images with `latest` aligning with GitHub's Ubuntu version. These images do not contain all of the software installed on the GitHub runners. They contain subset of packages from the GitHub runners: Basic CLI packages, git, docker and build-essentials. To install additional software, it is recommended to use the corresponding setup actions. For instance, `actions/setup-java` for Java or `actions/setup-node` for Node. | ||
|
||
## Executing workflows | ||
Now, all the setup and configuration is done. A workflow can be created in the same repository that could target the self hosted runner created from ARC. The workflow needs to have `runs-on: self-hosted` so it can target the self host pool. For more information on targeting workflows to run on self hosted runners, see "[Using Self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow)." | ||
|
||
## Scaling runners - statically with replicas count | ||
With a small tweak to the replicas count (for eg - `replicas: 2`) in the `runnerdeployment.yaml` file, more runners can be created. Depending on the count of replicas, those many sets of pods would be created. As before, Each pod contains the two containers. | ||
|
||
|
||
## Scaling runners - dynamically with Pull Driven Scaling | ||
ARC also allows for scaling the runners dynamically. There are two mechanisms for dynamically scaling - (1) Webhook driven scaling and (2) Pull Driven scaling, This document describes the Pull Driven scaling model. | ||
|
||
 | ||
|
||
|
||
|
||
You can enable scaling with 3 steps | ||
1) Enable `HorizontalRunnerAutoscaler` - Create a `deployment.yaml` file of type `HorizontalRunnerAutoscaler`. The schema for this file is defined below. | ||
2) Scaling parameters - `minReplicas` and `maxReplicas` indicates the min and max number of replicas to scale to. | ||
3) Scaling metrics - ARC currently supports `PercentageRunnersBusy` as a metric type. The `PercentageRunnersBusy` will poll GitHub for the number of runners in the `busy` state in the RunnerDeployment's namespace, it will then scale depending on how you have configured the scale factors. | ||
|
||
### Pull Driven Scaling Schema | ||
```yaml | ||
apiVersion: actions.summerwind.dev/v1alpha1 | ||
kind: HorizontalRunnerAutoscaler | ||
metadata: | ||
name: example-runner-deployment-autoscaler | ||
spec: | ||
scaleTargetRef: | ||
# Your RunnerDeployment Here | ||
name: example-runnerdeploy | ||
kind: RunnerDeployment | ||
minReplicas: 1 | ||
maxReplicas: 5 | ||
metrics: | ||
- type: PercentageRunnersBusy | ||
scaleUpThreshold: '0.75' | ||
scaleDownThreshold: '0.25' | ||
scaleUpFactor: '2' | ||
scaleDownFactor: '0.5' | ||
``` | ||
|
||
For more details - please see "[Pull Driven Scaling](https://github.com/actions-runner-controller/actions-runner-controller#pull-driven-scaling)." | ||
|
||
*The period between polls is defined by the controller's `--sync-period` flag. If this flag isn't provided then the controller defaults to a sync period of `1m`, this can be configured in seconds or minutes.* | ||
|
||
## Other Configurations | ||
ARC supports several different advanced configuration. | ||
- support for alternate runners : Setting up runner pods with Docker-In-Docker configuration. | ||
- managing runner groups : Managing a set of running with runner groups thus making it easy to manage different groups within enterprise | ||
- Webhook driven scaling. | ||
|
||
Please refer to the documentation in this repo for further details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
## Introduction | ||
|
||
GitHub Actions can be run in GitHub-hosted cloud or self hosted environments. Self-hosted runners offer more control of hardware, operating system, and software tools than GitHub-hosted runners provide. | ||
|
||
With just a few steps, you can set up your kubernetes (K8s) cluster to be a self-hosted environment. | ||
In this guide, we will setup prerequistes, deploy Actions Runner controller (ARC) and then target that cluster to run GitHub Action workflows. | ||
|
||
<p align="center"> | ||
<img src="https://user-images.githubusercontent.com/53718047/181159115-dbf41416-89a7-408c-b575-bb0d059a1a36.png" /> | ||
</p> | ||
|
||
|
||
|
||
## Setup your K8s cluster | ||
|
||
<details><summary><sub>Create a K8s cluster, if not available.</sub></summary> | ||
<sub> | ||
If you don't have a K8s cluster, you can install a local environment using minikube. For more information, see "[Installing minikube](https://minikube.sigs.k8s.io/docs/start/)." | ||
|
||
"[Using workflows](/actions/using-workflows)." | ||
</sub> | ||
</details> | ||
|
||
:one: Install cert-manager in your cluster. For more information, see "[cert-manager](https://cert-manager.io/docs/installation/)." | ||
|
||
```shell | ||
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.8.2/cert-manager.yaml | ||
``` | ||
<sub> *note:- This command uses v1.8.2. Please replace with a later version, if available.</sub> | ||
|
||
|
||
>You may also install cert-manager using Helm. For instructions, see "[Installing with Helm](https://cert-manager.io/docs/installation/helm/#installing-with-helm)." | ||
|
||
:two: Next, Generate a Personal Access Token (PAT) for ARC to authenticate with GitHub. | ||
- Login to GitHub account and Navigate to https://github.com/settings/tokens/new. | ||
- Select **repo**. | ||
- Click **Generate Token** and then copy the token locally ( we’ll need it later). | ||
|
||
|
||
|
||
|
||
## Deploy and Configure ARC | ||
1️⃣ Deploy and configure ARC on your K8s cluster. You may use Helm or Kubectl. | ||
|
||
|
||
<details><summary>Helm deployment</summary> | ||
|
||
##### Add repository | ||
```shell | ||
helm repo add actions-runner-controller https://actions-runner-controller.github.io/actions-runner-controller | ||
``` | ||
|
||
##### Install Helm chart | ||
```shell | ||
helm upgrade --install --namespace actions-runner-system --create-namespace\ | ||
--set=authSecret.create=true\ | ||
--set=authSecret.github_token="REPLACE_YOUR_TOKEN_HERE"\ | ||
--wait actions-runner-controller actions-runner-controller/actions-runner-controller | ||
``` | ||
<sub> *note:- Replace REPLACE_YOUR_TOKEN_HERE with your PAT that was generated in Step 1 </sub> | ||
</details> | ||
|
||
<details><summary>Kubectl deployment</summary> | ||
|
||
##### Deploy ARC | ||
```shell | ||
kubectl apply -f \ | ||
https://github.com/actions-runner-controller/actions-runner-controller/\ | ||
releases/download/v0.22.0/actions-runner-controller.yaml | ||
``` | ||
<sub> *note:- Replace "v0.22.0" with the version you wish to deploy </sub> | ||
|
||
|
||
##### Configure Personal Access Token | ||
```shell | ||
kubectl create secret generic controller-manager \ | ||
-n actions-runner-system \ | ||
--from-literal=github_token=REPLACE_YOUR_TOKEN_HERE | ||
```` | ||
<sub> *note:- Replace REPLACE_YOUR_TOKEN_HERE with your PAT that was generated in Step 1. </sub> | ||
|
||
</details> | ||
|
||
2️⃣ Create the GitHub self hosted runners and configure to run against your repository. | ||
|
||
Create a `runnerdeployment.yaml` file containing.. | ||
|
||
```yaml | ||
apiVersion: actions.summerwind.dev/v1alpha1 | ||
kind: RunnerDeployment | ||
metadata: | ||
name: example-runnerdeploy | ||
spec: | ||
replicas: 1 | ||
template: | ||
spec: | ||
repository: mumoshu/actions-runner-controller-ci | ||
```` | ||
<sub> *note:- Replace mumoshu/actions-runner-controller-ci with the full path to your github repository. </sub> | ||
Apply this file to your K8s cluster. | ||
```shell | ||
kubectl apply -f runnerdeployment.yaml | ||
```` | ||
|
||
|
||
> | ||
>🎉 We are done - now we should have self hosted runners running in K8s configured to your repository. 🎉 | ||
> | ||
> Up Next - lets verify and execute some workflows. | ||
|
||
## Verify and execute workflows | ||
:one: Verify your setup is successful with.. | ||
```shell | ||
$ kubectl get runners | ||
NAME REPOSITORY STATUS | ||
example-runnerdeploy2475h595fr mumoshu/actions-runner-controller-ci Running | ||
$ kubectl get pods | ||
NAME READY STATUS RESTARTS AGE | ||
example-runnerdeploy2475ht2qbr 2/2 Running 0 1m | ||
```` | ||
Also, this runner has been registered directly to the specified repository, you can see it in repository settings. For more information, see "[settings](https://docs.github.com/en/actions/hosting-your-own-runners/monitoring-and-troubleshooting-self-hosted-runners#checking-the-status-of-a-self-hosted-runner)." | ||
:two: You are ready to execute workflows against this self hosted runner. | ||
GitHub documentation lists the steps to target Actions against self hosted runners. For more information, see "[Using self-hosted runners in a workflow - GitHub Docs](https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow#using-self-hosted-runners-in-a-workflow)." | ||
There's also has a quick start guide to get started on Actions, For more information, see "[Quick start Guide to GitHub Actions](https://docs.github.com/en/actions/quickstart)." | ||
## Next steps | ||
ARC provides several interesting features and capabilities. For more information, see "[readme](https://github.com/actions-runner-controller/actions-runner-controller/blob/master/README.md)." | ||
Oops, something went wrong.