Skip to content

Autogenerated CRD unnecessarily(?) requires kubernetes plugin on pulumi up #28

@pcuci

Description

@pcuci

After crd2pulumi'ing cert-manager crds yamls, I'm trying to use the generated code, but can't figure out where this dependency comes from on pulumi up.

Diagnostics:
  pulumi:providers:kubernetes (default_0_0_1):
    error: no resource plugin 'kubernetes-v0.0.1' found in the workspace or on your $PATH, install the plugin using `pulumi plugin install resource kubernetes v0.0.1`

package.json of my local autogenerated package:

{
  "name": "@pulumi/depo-cert-manager",
  "version": "0.0.1",
  "scripts": {
    "build": "tsc"
  },
  "peerDependencies": {
    "@pulumi/pulumi": "^2.22.0"
  },
  "pulumi": {
    "resource": true
  },
  "devDependencies": {
    "typescript": "^4.2.3"
  }
}

loading that package in the main pulumi program package.json with:

"dependencies": {
    "@pulumi/depo-cert-manager": "file:cert-manager-types",

What's causing pulumi to think of this package as a plugin?

I changed to "version": "0.0.2" , and I get the following on pulumi up:

Diagnostics:
  pulumi:providers:kubernetes (default_0_0_2):
    error: no resource plugin 'kubernetes-v0.0.2' found in the workspace or on your $PATH, install the plugin using `pulumi plugin install resource kubernetes v0.0.2`

Expected behavior

Strange workaround, updating the npm package version to match the installed kubernetes plugin version bypasses the blocking error

  "version": "2.8.2",
$ pulumi up
[...]
     Type                                                              Name                                       Plan       Info
     pulumi:pulumi:Stack                                               haze-omega
 +   ├─ kubernetes:cert-manager.io/v1:ClusterIssuer                    letsencrypt-staging                        create
[...]

Steps to reproduce

In a new pulumi typescript project

mkdir cert-manager
cd cert-manager/
mkdir crds
wget https://github.com/jetstack/cert-manager/releases/download/v1.2.0/cert-manager.crds.yaml --output-document crds/cert-manager.crds.yaml
crd2pulumi crds/cert-manager.crds.yaml --nodejsName depo-cert-manager --nodejsPath cert-manager-types --force
sed -i 's/"version": ""/"version": "0.0.1"/g' cert-manager-types/package.json
npm install typescript --save-dev
cd ../../../
npm install --save cert-manager/cert-manager-types/

Using local lib inside the pulumi project, something like this:

[...]
import * as cert from "@pulumi/depo-cert-manager"

const certName = 'vouch'
const certNamespaceName = 'cert-manager'
const certNamespace = new k8s.core.v1.Namespace(certNamespaceName, {
  metadata: { name: certNamespaceName, labels: { name: certName } }
})

const certManager = new k8s.helm.v3.Chart(certName, {
  repo: "jetstack",
  chart: "cert-manager",
  namespace: certNamespace.metadata.name, values: { installCRDs: true }
})

const clusterIssuerName = 'letsencrypt-staging'

const clusterIssuer = new cert.certmanager.v1.ClusterIssuer(clusterIssuerName, {
  metadata: { name: certNamespaceName, labels: { name: certName }, namespace: certNamespace.metadata.name },
  spec: {
    acme: {
      server: "https://acme-staging-v02.api.letsencrypt.org/directory",
      email: "admin@example.com",
      privateKeySecretRef: {
        name: clusterIssuerName
      },
      solvers: [
        {
          http01: {
            ingress: {
              class: "nginx"
            }
          }
        }
      ]
    }
  }
})
[...]

Context (Environment)

Wanted TS type checking on writing a cert-manager ClusterIssuer definition.

Affected feature

Unknown(?)

Original Slack post

https://pulumi-community.slack.com/archives/CJ909TL6P/p1615095347031700

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions