https://pulumi.com logo
#general
Title
# general
f

faint-motherboard-95438

12/07/2018, 1:29 AM
Wanting to install the helm chart for cert-manager, I finding myself confronted with a case I didn’t encounter before : the chart declares new type of resources (
Issuer
,
ClusterIssuer
,
Certificate
, etc) that pulumi don’t know about (or at least I didn’t find the library that do) and I don’t know what to do from here. Should I create `CustomResource`s for those myself ? But if so I miss the needed knowledge to make it properly (I tried and got something kind of working but there’s things weird, like it doesn’t detect changes in the specs of some components I’ve made).
c

creamy-potato-29402

12/07/2018, 1:32 AM
So the chart creates CRDs for each of those things, and it’s up to you to call
apiextensions.CustomResource
with the right stuff in it?
Yes, that … sucks.
When apiextensions matures we will be able to auto-generate types from the schemas, but they’re not there yet, and so we aren’t either.
There’s not really a great way of doing this yet, unfortunately, except to write your own base class.
We’re working with, e.g., Istio on this.
f

faint-motherboard-95438

12/07/2018, 1:37 AM
well, based on what you are doing in your own libraries I did something like that :
Copy code
export default class ClusterIssuer extends pulumi.CustomResource {
  readonly apiVersion: pulumi.Output<string>
  readonly kind: pulumi.Output<string>
  readonly metadata: pulumi.Output<any>
  private readonly __inputs

  /**
  * Create a certmanager.v1alpha1.ClusterIssuer resource with
  * the given unique name, arguments, and options.
  *
  * @param name The _unique_ name of the resource.
  * @param args The arguments to use to populate this resource's properties.
  * @param opts A bag of options that control this resource's behavior.
  */
  constructor (name, args, opts) {
    let inputs = {}
    inputs['apiVersion'] = '<http://certmanager.k8s.io/v1alpha1|certmanager.k8s.io/v1alpha1>'
    inputs['kind'] = 'ClusterIssuer'
    inputs['metadata'] = args && args.metadata || undefined
    // super(`kubernetes:${inputs.apiVersion}:${inputs.kind}`, name, inputs, opts)
    super('kubernetes:<http://certmanager.k8s.io/v1alpha1:ClusterIssuer|certmanager.k8s.io/v1alpha1:ClusterIssuer>', name, inputs, opts)
    this.__inputs = args
  }

  /**
   * Get the state of an existing `ClusterIssuer` resource,
   * as identified by `id`.
   * Typically this ID is of the form <namespace>/<name> ;
   * if <namespace> is omitted, then (per Kubernetes convention)
   * the ID becomes default/<name>.
   *
   * Pulumi will keep track of this resource using `name` as the Pulumi ID.
   *
   * @param name _Unique_ name used to register this resource with Pulumi.
   * @param id An ID for the Kubernetes resource to retrive. Takes the form
   *  <namespace>/<name> or <name>.
   */
  static get (name, id) {
    return new ClusterIssuer(name, undefined, { id })
  }

  getInputs () { return this.__inputs }
}
c

creamy-potato-29402

12/07/2018, 1:37 AM
yeah, that sucks and I’m sorry to see it. All i can say is that we will mature with the ecosystem. 🙂
When we have the tools to auto-generate, we will.
f

faint-motherboard-95438

12/07/2018, 1:38 AM
sure, but am I doing it right this way in the meantime ?
because I’m not really sure of what I’m doing 😅
c

creamy-potato-29402

12/07/2018, 1:38 AM
this looks like what you’d approximately want, yes.
you’re not doing so bad. 🙂
f

faint-motherboard-95438

12/07/2018, 1:39 AM
haha, thanks. Any idea why if I change things in the spec (so the
args
parameter) a
pulumi up
don’t detect it and does not want to refresh the resource ?
surely I’m missing something in my draft here, I don’t get yet the whole process of a pulumi Resource under the hood
c

creamy-potato-29402

12/07/2018, 1:46 AM
uh
best guess is that you’re not passing the correct things to
super
?
I have to dinner but happy to chat later/tomorrow if you need.
f

faint-motherboard-95438

12/07/2018, 1:53 AM
Sure no worries, have a good evening, thanks
well, I wasn’t sure of the first parameter
'kubernetes:<http://certmanager.k8s.io/v1alpha1:ClusterIssuer|certmanager.k8s.io/v1alpha1:ClusterIssuer>'
I just guessed the string based on other resources in the library, don’t know if that’s important
fyi I finally succeeded to make it works, thanks for your help 🙂
c

creamy-potato-29402

12/08/2018, 1:29 AM
@faint-motherboard-95438 thanks so much for your work! I’d love to turn your problems into canonical solutions. Was it just the CRD stuff
f

faint-motherboard-95438

12/08/2018, 1:34 AM
About the update detection ? Actually I’m not sure, but I was missing to initialize 2 values in
inputs
in the
constructor
:
Copy code
inputs['spec'] = args && args.spec || undefined
    inputs['status'] = args && args.status || undefined
I think after that, it worked as expected.
c

creamy-potato-29402

12/08/2018, 1:35 AM
ah
that makes sense.
f

faint-motherboard-95438

12/08/2018, 1:36 AM
I could try to make a dedicated package for
cert-manager
in typescript if that makes sense to do it, or will it be quickly outdated if you are able to generate everything from any chart soon
i

important-carpenter-15282

12/08/2018, 4:37 PM
I'm glad I saw this--I'm about to embark on fixing my k8s cluster at home to be Pulumi-based rather than just-a-bunch-of-YAML, and I'd definitely need cert-manager. 😄
f

faint-motherboard-95438

12/09/2018, 1:01 AM
@important-carpenter-15282 if you can give me a few days I’ll share a package with what I did, or if you are in a hurry I can send you a bunch of files dedicated to gcloud atm, I’d like to make it cloud agnostic.
i

important-carpenter-15282

12/09/2018, 6:44 PM
I'm not in a hurry, no. Bare metal cluster for me, so cloud-specific stuff will not be super helpful. 😄
f

faint-motherboard-95438

12/11/2018, 9:35 AM
@important-carpenter-15282 I was planning to do something agnostic (well, as much as I can), I’ll share it with you and we’ll see how we can work this out 🙂
b

better-rainbow-14549

12/13/2018, 4:16 PM
i've got a working cert-manager typescript using the helm chart and CRDs for issuer + certificate, happy to share.. i was going to make a package but didnt know how to do it properly
f

faint-motherboard-95438

12/14/2018, 1:38 PM
@better-rainbow-14549 would definitely be interested to see it 🙂
ripped it out of my stack, untested...
it should be very close though
2 Views