https://pulumi.com logo
#kubernetes
Title
# kubernetes
p

polite-motherboard-78438

03/08/2020, 12:08 PM
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

damp-painter-36857

03/08/2020, 12:20 PM
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

polite-motherboard-78438

03/08/2020, 4:45 PM
yes. I am using Typescript
b

broad-helmet-79436

03/09/2020, 9:40 AM
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

polite-motherboard-78438

03/09/2020, 7:52 PM
interesting. Will try this approach. Thanks
4 Views