简体   繁体   中英

How to add dependency between helm chart and kubernetes resource in terraform CDK

I'm installing a helm chart which creates a CRD and then I want to instantiate the CRD defined in the helm chart. What's the correct way to declare a dependency between them so that terraform doesn't try to create the CRD until after the helm chart has finished installing?

    new helm.Release(this, "doppler-kubernetes-operator-helm-chart", {
      chart: "doppler-kubernetes-operator",
      name: "doppler",
      repository: "https://helm.doppler.com",
      version: "1.2.0"
    })

    const dopplerOperatingSystemNamespace = "doppler-operator-system";

    // create a secret referenced by the CRD
    const dopplerApiServerProjectServiceTokenSecret = new kubernetes.Secret(this, "doppler-api-server-project-service-token", {
      metadata: {
        name: "doppler-api-server-project-service-token",
        namespace: dopplerOperatingSystemNamespace
      },
      data: {
        "serviceToken": "<some secret>"
      }
    })

    // Create the CRD <------------- how do I get this to depend on the helm chart?
    new kubernetes.Manifest(this, "doppler-kubernetes-operator", {
      manifest: {
        apiVersion: "secrets.doppler.com/v1alpha1",
        kind: "DopplerSecret",
        metadata: {
          name: "doppler-secret-default",
          namespace: dopplerOperatingSystemNamespace,
        },
        spec: {
          tokenSecret: {
            name: dopplerApiServerProjectServiceTokenSecret.metadata.name
          },
          managedSecret: {
            name: "doppler-api-server-managed-secret",
            namespace: "default"
          }
        }
      }
    })

In this case I would like to only attempt creating doppler-kube.netes-operator after the helm chart has finished installing.

Turns out I'm an idiot. I was looking for dependsOn (which I use with AWS classes) and Intellij wasn't autocompleting it for the kube.netes Manifest but I guess my cursor was in the wrong position...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM