How do I configure a kubernetes actions.summerwind.dev horizontalrunnerautoscaler with Pulumi?
In this guide, we will configure a HorizontalRunnerAutoscaler
from the actions.summerwind.dev
API using Pulumi. This resource is used to automatically scale GitHub Actions runners in a Kubernetes cluster based on the number of queued and running workflow jobs.
Key Points
- We will create a
HorizontalRunnerAutoscaler
resource. - We will define the scaling behavior for GitHub Actions runners.
- The configuration will be done using Pulumi in TypeScript.
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
// Define the Kubernetes namespace
const namespace = new k8s.core.v1.Namespace("actions-runner-system", {
metadata: { name: "actions-runner-system" },
});
// Define the RunnerDeployment
const runnerDeployment = new k8s.apiextensions.CustomResource("runnerDeployment", {
apiVersion: "actions.summerwind.dev/v1alpha1",
kind: "RunnerDeployment",
metadata: {
name: "example-runner-deployment",
namespace: namespace.metadata.name,
},
spec: {
replicas: 2,
template: {
spec: {
repository: "your-github-repo/your-repo",
image: "summerwind/actions-runner:latest",
},
},
},
});
// Define the HorizontalRunnerAutoscaler
const horizontalRunnerAutoscaler = new k8s.apiextensions.CustomResource("horizontalRunnerAutoscaler", {
apiVersion: "actions.summerwind.dev/v1alpha1",
kind: "HorizontalRunnerAutoscaler",
metadata: {
name: "example-autoscaler",
namespace: namespace.metadata.name,
},
spec: {
scaleTargetRef: {
name: runnerDeployment.metadata.name,
},
minReplicas: 1,
maxReplicas: 10,
metrics: [
{
type: "TotalNumberOfQueuedAndInProgressWorkflowRuns",
repositoryNames: ["your-github-repo/your-repo"],
scaleUpThreshold: 5,
scaleDownThreshold: 2,
},
],
},
});
Summary
In this guide, we configured a HorizontalRunnerAutoscaler
for GitHub Actions runners in a Kubernetes cluster using Pulumi. We defined a RunnerDeployment
and set up the autoscaler to adjust the number of runners based on the number of queued and in-progress workflow runs. This ensures efficient scaling of resources based on the workload.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.