hello. it´s possible to create a Custom Resource w...
# kubernetes
p
hello. it´s possible to create a Custom Resource without using the YAML resource or an Helm chart? In my case I need to create a ClusterIssuer for cert-manager. The solution I was using with terraform was to create a custom Helm chart. Wondering if there is a better way with Pulumi. Note: I dont want to use the yaml resource because there are some properties I have to load from config and replace in the resource
d
yes - look at
[@pulumi/kubernetes].CustomResource
if you're using typescript, you don't get the benefit of type safety for it because Pulumi doesn't know about the schema, but I get around that by manually defining types and creating helper functions to instantiate the various resources
can you confirm whether you're using typescript, as if you are, I can paste how I handle ClusterIssuers
p
yes. I am using Typescript
b
for what it’s worth, I use this thing to create the GCP-specific BackendConfig custom resource:
Copy code
import * as kubernetes from '@pulumi/kubernetes';
import { CustomResourceOptions, Output } from '@pulumi/pulumi';

type BackendConfigArgs = {
  spec: {
    iap: {
      enabled: boolean;
      oauthclientCredentials: {
        secretName: Output<string>;
      };
    };
  };
  name: string;
  // Kubernetes namespace of the resource.
  namespace?: Output<string>;
};

export class BackendConfig extends kubernetes.apiextensions.CustomResource {
  constructor(
    resourceName: string,
    { name, spec, namespace }: BackendConfigArgs,
    opts: Omit<CustomResourceOptions, 'provider'>
  ) {
    const args: kubernetes.apiextensions.CustomResourceArgs = {
      apiVersion: '<http://cloud.google.com/v1beta1|cloud.google.com/v1beta1>',
      kind: 'BackendConfig',
      metadata: { annotations: {}, name, namespace },
      spec,
    };

    super(resourceName, args, opts);
  }
}
i.e., (1) extend kubernetes.apiextensions.CustomResource, (2) write a type for the args you need, and (3) glue everything together and pass it to the superclass
sounds to me like creating a ClusterIssuer should be pretty much the same
p
interesting. Will try this approach. Thanks