如何在Terraform CDK中为Helm图表和Kubernetes资源之间添加依赖关系。

huangapple go评论60阅读模式
英文:

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

问题

// Create the CRD <------------- how do I get this to depend on the helm chart?
// 在这种情况下,我希望只有在 Helm Chart 完成安装后才尝试创建 "doppler-kubernetes-operator"。
英文:

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-kubernetes-operator after the helm chart has finished installing.

答案1

得分: 0

事实证明我很蠢。我正在寻找dependsOn(我在AWS类中使用它),但是Intellij没有为Kubernetes Manifest自动补全它,但我猜我的光标位置错了...

英文:

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 kubernetes Manifest but I guess my cursor was in the wrong position...

huangapple
  • 本文由 发表于 2023年1月8日 23:58:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75049227.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定