Skip to content

ContainerCraft/projen-pulumi-crd-sdks

Repository files navigation

Projen.io project type for generating Pulumi SDKs of Kubernetes CRDs

Projen is a multi-language tool to automate the setup of a new project. It provides a consistent and opinionated way to bootstrap projects, manage dependencies, and enforce best practices across different programming languages and frameworks.

This project is specifically designed to generate Pulumi SDKs for Kubernetes Custom Resource Definitions (CRDs), allowing developers to easily integrate custom resources into their Pulumi-based infrastructure as code projects.

Usage

If you have a Kubernetes operator containing CRDs that you want to integrate into Pulumi, you can use this project type to generate the Pulumi SDKs for your CRDs. The generated SDKs provide a convenient way to interact with your custom resources from within your Pulumi code, enabling seamless integration and management of your Kubernetes resources as part of your infrastructure as code workflow.

Bootstrapping a new project

Due to an upstream projen issue, it is not possible yet to perform the initialization in a single step. You will need to perform the following steps:

  1. Create a new directory for your project and navigate into it.
  2. Run npx projen new npx projen new --from @containercraft/projen-pulumi-crd-sdks --synth=false --no-git .
  3. Now paste the following template over your .projenrc.json file:
    {
      "type": "@containercraft/projen-pulumi-crd-sdks.PulumiCrdSdksProject",
      "name": "<your-project-name>",
      "latestVersionOnBranch": "1.0.0",
      "upstreamProject": {
        "owner": "<github-user-or-org>",
        "repository": "<github-repository>"
      },
      "crdUrls": [
        "https://raw.githubusercontent.com/<github-user-or-org>/<github-repository>/${VERSION}/<path>/<crd-schema-file>.yaml"
      ],
      "nodePackage": {
        "name": "<your-npm-package-name>",
        "namespace": "<your-npm-namespace-optional>"
      },
      "pythonPackage": {
        "name": "<your_python_package_name>",
        "prefix": "<your_python_package_prefix_optional>"
      },
      "goPackage": "github.com/<github-user-or-org>/<github-repository>/sdk/go/v<version>",
      "dotnetPackage": {
        "name": "<your-dotnet-package-name>",
        "namespace": "<your-dotnet-namespace-optional>"
      },
      "javaPackage": {
        "name": "<your-java-package-name>",
        "basePackage": "<your-java-base-package-optional>"
      }
    }
    Note: The Python package name must be written with underscores instead of hyphens.
  4. Replace the placeholders in the template with the appropriate values.
  5. Create the file .projen/tasks.json with the following content:
    {
      "tasks": {
        "default": {
          "name": "default",
          "description": "Synthesize project files",
          "env": {
            "FILENAME": ".projenrc.json"
          },
          "steps": [
            {
              "builtin": "run-projenrc-json"
            }
          ]
        }
      },
      "//": "~~ Generated by projen. To modify, edit .projenrc.json and run \"npx projen\"."
    }
  6. Run npx projen to generate the required build and release workflows.
  7. Once the project is initialized, you can start using the generated SDKs in your Pulumi code.

About

Projen project type to generate Pulumi SDKs for Kubernetes CRDs

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors