Terraform:通过helm_release

时间:2020-06-01 13:56:14

标签: terraform

这是我的结构:

.
├── development
│   ├── inputs.tf
│   ├── main.tf
│   └── provider.tf
└── modules
    ├── kafka
    │   ├── inputs.tf
    │   └── main.tf
    └── zookeeper
        ├── inputs.tf
        ├── main.tf
        └── outputs.tf

每个kafkazookeeper模块是:

_/modules/kafka/main.tf中的Kafka模块:

resource "helm_release" "kafka" {
    name       = "kafka"
    repository = "https://charts.bitnami.com/bitnami" 
    chart      = "kafka"
    version    = "10.3.3"
    namespace  = var.namespace

    set {
        name = "zookeeper.enabled"
        value = false
    }

    set {
        name = "externalZookeeper.servers"
        value = var.zookeeper_service
    }

    set {
        name = "replicaCount"
        value = var.nodes
    }
}

_/modules/zookeeper/main.tf中的Zookeeper模块:

resource "helm_release" "zookeeper" {
    name       = "zookeeper"
    repository = "https://charts.bitnami.com/bitnami" 
    chart      = "zookeeper"
    version    = "5.14.3"
    namespace  = var.namespace
}

如您所见,kafka模块需要知道哪个是在zookeepper前面创建的服务。

我想在zookeeper模块上生成输出,以获取创建的服务,并同时在kafka和zookeeper之间创建模块依赖关系。我的意思是,kafka模块需要zookeeper

我创建了一个_/modules/zookeeper/output.tf

output "service_name" {
  description = "The name of the created zookeeper service."
  value       = "zookeeper"
}

我想用从"zookeeper"获得的任何值替换helm_release字符串文字。

这里的问题是zookeeper舵图正在创建此服务:

apiVersion: v1
kind: Service
metadata:
  name: {{ template "zookeeper.fullname" . }}
  ...

您可以找到头盔图表代码here

一旦正确部署头盔,如何获得该值并将其作为zookeeper模块输出传递?

0 个答案:

没有答案