如何将yaml configmap文件转换为Terraform

时间:2019-03-28 12:05:40

标签: kubernetes terraform

我正在尝试将Kubewatch集成到kubernetes集群中。该集群是使用Terraform的kubernetes提供程序构建的。如何将configmap yaml文件的data部分转换为terraform?

YAML
apiVersion: v1
kind: ConfigMap
metadata:
  name: kubewatch
data:
  .kubewatch.yaml: |
    namespace: "default"
    handler:
      slack:
        token: xoxb-OUR-BOT-TOKEN
        channel: kubernetes-events
    resource:
      deployment: true
      replicationcontroller: false
      replicaset: false
      daemonset: false
      services: true
      pod: true
      secret: true
      configmap: false

1 个答案:

答案 0 :(得分:0)

虽然我还没有完成非常复杂的配置映射,但这应该可以使您更加接近。

resource "kubernetes_config_map" "example" {
  metadata {
    name = "kubewatch"
  }

  data {
    namespace = "default"
    handler {
        slack {
            token   = "xoxb-OUR-BOT-TOKEN"
            channel = "kubernetes-events"
        }
    } 
    resource {
       deployment            = true
       replicationcontroller = false
       replicaset            = false
       daemonset             = false
       services              = true
       pod                   = true
       secret                = true
       configmap             = false
    }
    api_host = "myhost:443"
    db_host  = "dbhost:5432"
  }
}