Skip to content

crd2pulumi ​

Deprecated. crd2pulumi is superseded by provider extensions as of pulumi-kubernetes v4.34.0. See Typed CustomResources with Provider Extensions.

crd2pulumi is a CLI tool that generates typed Pulumi SDK classes from Kubernetes CustomResourceDefinition (CRD) YAML schemas. While Pulumi lets you manage Kubernetes CustomResources directly, those resources are untyped by default because every CRD schema is different. crd2pulumi solves this by reading a CRD's OpenAPI schema and generating strongly typed classes for your language of choice, enabling IDE autocompletion and compile-time type checking.

This is particularly useful for complex CRDs with large schemas, such as cert-manager or Istio, where manually constructing resource arguments is error-prone.

Installation ​

Install crd2pulumi via Homebrew:

bash
brew install pulumi/tap/crd2pulumi

Alternatively, download a binary from the GitHub releases page.

Usage ​

The following example uses the CronTab CRD from the Kubernetes documentation. Generate typed SDK classes with crd2pulumi, then use them alongside ConfigFile to register the CRD and instantiate a typed resource.

Generate TypeScript types:

bash
crd2pulumi --nodejsPath ./crontabs resourcedefinition.yaml

Import the generated types into your Pulumi program:

typescript
import * as crontabs from "./crontabs";
import * as k8s from "@pulumi/kubernetes";

const cronTabDefinition = new k8s.yaml.v2.ConfigFile("my-crontab-definition", {
    file: "resourcedefinition.yaml",
});

const myCronTab = new crontabs.stable.v1.CronTab("my-new-cron-object", {
    metadata: {
        name: "my-new-cron-object",
    },
    spec: {
        cronSpec: "* * * * */5",
        image: "my-awesome-cron-image",
    },
});

Content from the official Pulumi documentation (github.com/pulumi/docs).