How do I build a kubernetes actions.summerwind.dev runnerdeployment with Pulumi?
In this guide, we will create a Kubernetes RunnerDeployment
using Pulumi. The RunnerDeployment
resource from the actions.summerwind.dev
API is used to manage self-hosted GitHub Actions runners within a Kubernetes cluster. We will define all necessary entities within the Pulumi program to ensure it works seamlessly.
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
// Define the namespace for the GitHub Actions Runner
const namespace = new k8s.core.v1.Namespace("actions-runner-system", {
metadata: {
name: "actions-runner-system",
},
});
// Define the RunnerDeployment resource
const runnerDeployment = new k8s.apiextensions.CustomResource("runnerdeployment", {
apiVersion: "actions.summerwind.dev/v1alpha1",
kind: "RunnerDeployment",
metadata: {
name: "example-runnerdeployment",
namespace: namespace.metadata.name,
},
spec: {
replicas: 2, // Number of runner replicas
template: {
spec: {
repository: "your-github-org/your-repo", // Replace with your GitHub repository
image: "summerwind/actions-runner:latest", // Docker image for the runner
env: [
{
name: "RUNNER_TOKEN",
valueFrom: {
secretKeyRef: {
name: "github-actions-secrets",
key: "runner-token",
},
},
},
],
},
},
},
});
// Define the secret for the GitHub Actions Runner token
const runnerTokenSecret = new k8s.core.v1.Secret("github-actions-secrets", {
metadata: {
name: "github-actions-secrets",
namespace: namespace.metadata.name,
},
stringData: {
"runner-token": "YOUR_GITHUB_RUNNER_TOKEN", // Replace with your GitHub runner token
},
});
// Export the namespace and runner deployment details
export const namespaceName = namespace.metadata.name;
export const runnerDeploymentName = runnerDeployment.metadata.name;
Key Points
- Namespace: The
Namespace
resource is created to isolate the resources related to the GitHub Actions Runner. - RunnerDeployment: The
RunnerDeployment
resource is defined with the necessary specifications, including the number of replicas, repository, and Docker image. - Secret: A
Secret
resource is created to securely store the GitHub runner token.
Summary
In this guide, we successfully created a Kubernetes RunnerDeployment
using Pulumi. We defined a namespace, a runner deployment, and a secret to manage self-hosted GitHub Actions runners within a Kubernetes cluster. This setup ensures that the runners are properly configured and securely managed.
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.