1. Answers
  2. Using Kubernetes Actions.summerwind.dev With Caching.internal.knative.dev

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

  1. Ensure you have Pulumi installed and configured.
  2. Ensure you have access to a Kubernetes cluster.
  3. Ensure you have the necessary permissions to create resources in the cluster.

Setting Up the Pulumi Project

  1. Create a new Pulumi project:
    pulumi new typescript
    
  2. Install the necessary Pulumi packages:
    npm install @pulumi/kubernetes
    

Creating the Kubernetes Resources

  1. Import the Pulumi Kubernetes package:
    import * as k8s from "@pulumi/kubernetes";
    
  2. 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" },
            ],
        },
    });
    
  3. 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",
        },
    });
    
  4. 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 up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up