Terraform-provider-kubernetes: Multiple secret_ref and env_from do not work

Created on 22 Nov 2018  ·  5Comments  ·  Source: hashicorp/terraform-provider-kubernetes

Terraform Version

Terraform v0.11.10

  • provider.kubernetes v1.3.0

Affected Resource(s)

Please list the resources as a list, for example:

  • kubernetes_deployment

Terraform Configuration Files

          env = [{
            name  = "PORT"
            value = "${var.pod_port}"
            }
          ]
          env_from = [{
            secret_ref {
              name = "server"
            }
            secret_ref {
              name = "redis"
            }
          }]

Debug Output

https://gist.github.com/Anthonyzou/10f620bc8022e6772f5fa146c71c0f82

Expected Behavior

Multiple secrets get loaded into the deployment

Actual Behavior

No deployment

Steps to Reproduce

  1. terraform apply

Most helpful comment

Also allow usage of both secret_ref and config_map_ref together.

env_from {
  config_map_ref {
    name = "config-map"
  }
  secret_ref {
    name = "secret"
  }
}
Error: Error applying plan:

1 error(s) occurred:

* kubernetes_deployment.frontend_php_fpm_deployment: 1 error(s) occurred:

* kubernetes_deployment.frontend_php_fpm_deployment: Failed to create deployment: Deployment.apps "toppy-webshop-frontend-php-fpm-deployment" is invalid: spec.template.spec.containers[0].envFrom: Invalid value: "": may not have more than one field specified at a time

All 5 comments

Also allow usage of both secret_ref and config_map_ref together.

env_from {
  config_map_ref {
    name = "config-map"
  }
  secret_ref {
    name = "secret"
  }
}
Error: Error applying plan:

1 error(s) occurred:

* kubernetes_deployment.frontend_php_fpm_deployment: 1 error(s) occurred:

* kubernetes_deployment.frontend_php_fpm_deployment: Failed to create deployment: Deployment.apps "toppy-webshop-frontend-php-fpm-deployment" is invalid: spec.template.spec.containers[0].envFrom: Invalid value: "": may not have more than one field specified at a time

I'm running into this issue as well. Is there currently a way to get it working or am I going to have to merge all my config into secrets

This one has definitely tripped me up a few times. The appropriate terraform practice here is to a define an env_from block for each reference you want to make, as env_from is itself a list.

env_from {
  secret_ref {
    name = "secret"
  }
}

env_from {
  config_map_ref {
    name = "configmap"
  }
}

I can see how how this would be a little surprising if you were using YAML before.

I just use pulumi now.

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings