Using Kubernetes Actions.summerwind.dev With Caching.internal.knative.dev
Introduction
In this guide, we will demonstrate how to use Kubernetes resources from the actions.summerwind.dev
and caching.internal.knative.dev
APIs with Pulumi. These APIs are useful for managing GitHub Actions runners and caching mechanisms within a Knative environment, respectively.
Step-by-Step Explanation
Prerequisites
- Ensure you have Pulumi installed and configured.
- Ensure you have access to a Kubernetes cluster.
- Ensure you have the necessary permissions to create resources in the cluster.
Setting Up the Pulumi Project
- Create a new Pulumi project:
pulumi new typescript
- Install the necessary Pulumi packages:
npm install @pulumi/kubernetes
Creating the Kubernetes Resources
- Import the Pulumi Kubernetes package:
import * as k8s from "@pulumi/kubernetes";
- Define the GitHub Actions runner resource:
const runner = new k8s.apiextensions.CustomResource("runner", { apiVersion: "actions.summerwind.dev/v1alpha1", kind: "Runner", metadata: { name: "my-runner", namespace: "default", }, spec: { repository: "my-org/my-repo", image: "my-runner-image", env: [ { name: "RUNNER_TOKEN", value: "my-runner-token" }, ], }, });
- Define the Knative caching resource:
const cache = new k8s.apiextensions.CustomResource("cache", { apiVersion: "caching.internal.knative.dev/v1alpha1", kind: "Cache", metadata: { name: "my-cache", namespace: "default", }, spec: { size: "1Gi", path: "/cache-path", }, });
- Export the resource names:
export const runnerName = runner.metadata.name; export const cacheName = cache.metadata.name;
Summary
In this guide, we have shown how to create Kubernetes resources for GitHub Actions runners and Knative caching using Pulumi. By following these steps, you can automate the deployment and management of these resources within your Kubernetes cluster.
Full Code Example
import * as k8s from "@pulumi/kubernetes";
const runner = new k8s.apiextensions.CustomResource("runner", {
apiVersion: "actions.summerwind.dev/v1alpha1",
kind: "Runner",
metadata: {
name: "my-runner",
namespace: "default",
},
spec: {
repository: "my-org/my-repo",
image: "my-runner-image",
env: [
{ name: "RUNNER_TOKEN", value: "my-runner-token" },
],
},
});
const cache = new k8s.apiextensions.CustomResource("cache", {
apiVersion: "caching.internal.knative.dev/v1alpha1",
kind: "Cache",
metadata: {
name: "my-cache",
namespace: "default",
},
spec: {
size: "1Gi",
path: "/cache-path",
},
});
export const runnerName = runner.metadata.name;
export const cacheName = cache.metadata.name;
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.