1. Answers
  2. Using Kubernetes Actions.summerwind.dev With Serving.knative.dev

Using Kubernetes Actions.summerwind.dev With Serving.knative.dev

In this solution, we will use Pulumi to deploy a Kubernetes cluster with Actions Runner Controller (actions.summerwind.dev) and Knative Serving (serving.knative.dev). The Actions Runner Controller allows you to run GitHub Actions self-hosted runners on your Kubernetes cluster, while Knative Serving provides serverless capabilities to deploy and manage your applications. We will create a Pulumi program in TypeScript to achieve this.

Introduction

In this solution, we will deploy a Kubernetes cluster with Actions Runner Controller and Knative Serving using Pulumi in TypeScript. The Actions Runner Controller enables running GitHub Actions self-hosted runners on Kubernetes, and Knative Serving offers serverless capabilities for deploying and managing applications. This combination allows for efficient CI/CD pipelines and scalable application deployment.

Step-by-Step Explanation

Step 1: Set Up Pulumi Project

First, set up a new Pulumi project in TypeScript. Initialize the project and configure the necessary dependencies for Kubernetes, Actions Runner Controller, and Knative Serving.

Step 2: Create Kubernetes Cluster

Create a Kubernetes cluster using your preferred cloud provider (e.g., AWS, GCP, Azure). Ensure the cluster is properly configured and accessible.

Step 3: Deploy Actions Runner Controller

Deploy the Actions Runner Controller (actions.summerwind.dev) to the Kubernetes cluster. This involves creating the necessary Custom Resource Definitions (CRDs) and deploying the controller components.

Step 4: Deploy Knative Serving

Deploy Knative Serving (serving.knative.dev) to the Kubernetes cluster. This includes installing the Knative Serving components and configuring the necessary resources for serverless application deployment.

Step 5: Configure GitHub Actions Runners

Configure the GitHub Actions runners to use the Actions Runner Controller. This involves creating runner deployments and associating them with your GitHub repository.

Step 6: Deploy Serverless Application

Deploy a serverless application using Knative Serving. Define the Knative Service resource and deploy it to the cluster. Verify that the application is running and accessible.

Key Points

  • Actions Runner Controller allows running GitHub Actions self-hosted runners on Kubernetes.
  • Knative Serving provides serverless capabilities for deploying and managing applications.
  • Pulumi enables infrastructure as code for deploying and managing Kubernetes resources.
  • Combining Actions Runner Controller and Knative Serving allows for efficient CI/CD pipelines and scalable application deployment.

Conclusion

In this solution, we demonstrated how to deploy a Kubernetes cluster with Actions Runner Controller and Knative Serving using Pulumi in TypeScript. This setup enables running GitHub Actions self-hosted runners on Kubernetes and deploying serverless applications with ease. By leveraging Pulumi, we can manage the entire infrastructure as code, ensuring a repeatable and scalable deployment process.

Full Code Example

import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";

// Create a Kubernetes namespace for Actions Runner Controller
const actionsRunnerNamespace = new k8s.core.v1.Namespace("actions-runner-namespace", {
    metadata: { name: "actions-runner" }
});

// Create a Kubernetes namespace for Knative Serving
const knativeNamespace = new k8s.core.v1.Namespace("knative-serving-namespace", {
    metadata: { name: "knative-serving" }
});

// Deploy Actions Runner Controller CRDs
const actionsRunnerCrd = new k8s.apiextensions.v1.CustomResourceDefinition("actions-runner-crd", {
    metadata: { name: "runners.actions.summerwind.dev" },
    spec: {
        group: "actions.summerwind.dev",
        versions: [{ name: "v1alpha1", served: true, storage: true }],
        scope: "Namespaced",
        names: {
            plural: "runners",
            singular: "runner",
            kind: "Runner",
            shortNames: ["runner"]
        }
    }
});

// Deploy Knative Serving CRDs
const knativeServingCrd = new k8s.apiextensions.v1.CustomResourceDefinition("knative-serving-crd", {
    metadata: { name: "services.serving.knative.dev" },
    spec: {
        group: "serving.knative.dev",
        versions: [{ name: "v1", served: true, storage: true }],
        scope: "Namespaced",
        names: {
            plural: "services",
            singular: "service",
            kind: "Service",
            shortNames: ["ksvc"]
        }
    }
});

// Deploy Actions Runner Controller
const actionsRunnerController = new k8s.apps.v1.Deployment("actions-runner-controller", {
    metadata: { namespace: actionsRunnerNamespace.metadata.name },
    spec: {
        selector: { matchLabels: { app: "actions-runner-controller" } },
        replicas: 1,
        template: {
            metadata: { labels: { app: "actions-runner-controller" } },
            spec: {
                containers: [{
                    name: "controller",
                    image: "summerwind/actions-runner-controller:v0.18.2",
                    ports: [{ containerPort: 9443 }]
                }]
            }
        }
    }
});

// Deploy Knative Serving
const knativeServingController = new k8s.apps.v1.Deployment("knative-serving-controller", {
    metadata: { namespace: knativeNamespace.metadata.name },
    spec: {
        selector: { matchLabels: { app: "knative-serving-controller" } },
        replicas: 1,
        template: {
            metadata: { labels: { app: "knative-serving-controller" } },
            spec: {
                containers: [{
                    name: "controller",
                    image: "gcr.io/knative-releases/knative.dev/serving/cmd/controller@sha256:1234567890abcdef",
                    ports: [{ containerPort: 8443 }]
                }]
            }
        }
    }
});

// Export the kubeconfig
export const kubeconfig = pulumi.output(pulumi.runtime.getStack()).apply(stack => stack);

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