Is it possible --from-file ConfigMap using kubernetes_config_map resource?

被刻印的时光 ゝ 提交于 2021-02-10 19:41:36

问题


I want to deploy metallb using terraform. metallb configuration is as follows.

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 172.16.99.1-172.16.99.255

Is it possible deploy such --from-file configuration using kubernetes_config_map resource?


回答1:


You can use the file() interpolation function to read the file contents. That might look like:

resource "kubernetes_config_map" "config" {
  metadata {
    namespace = "metallb_system"
    name = "config"
  }
  data {
    config = "${file(${path.module}/config.yml)}"
  }
}

Unlike kubectl create configmap --from-file you do have to specify the filename twice.



来源:https://stackoverflow.com/questions/53667413/is-it-possible-from-file-configmap-using-kubernetes-config-map-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!