Skip to content

Init container doesn't support restart_policy option (to transform it in a sidecar container) #2446

@arthurgur

Description

@arthurgur

Terraform Version, Provider Version and Kubernetes Version

Terraform version: 1.6.2
Kubernetes provider version: 2.27.0
Kubernetes version: 1.19

Affected Resource(s)

Terraform Configuration Files

resource "kubernetes_deployment_v1" "example" {
  metadata {
    name = "terraform-example"
    labels = {
      test = "MyExampleApp"
    }
  }

  spec {
    replicas = 3

    selector {
      match_labels = {
        test = "MyExampleApp"
      }
    }

    template {
      metadata {
        labels = {
          test = "MyExampleApp"
        }
      }

      spec {
        container {
          name  = "example"
          image = "nginx:1.21.6"

        # Init container
        init_container {
          name  = "init-setup"
          image = "busybox:latest"
          restart_policy = "Always"
        }
      }
    }
  }
}

Debug Output

Terraform v1.6.2
on linux_amd64
Initializing plugins and modules...
╷
│ Error: Unsupported argument
│ 
│   on app.tf line XX, in resource "kubernetes_deployment_v1" "this":
│   XX:             restart_policy = "Always"
│ 
│ An argument named "restart_policy" is not expected here.
╵
Operation failed: failed running terraform plan (exit 1)

Panic Output

Steps to Reproduce

  1. Create a ressource kubernetes_deployment_v1 with init container and set the option restart_policy of the init container to "Always" to transform it in a sidecar.
  2. Apply your code

Expected Behavior

Pod with sidecar init container created

Actual Behavior

Option non supported

Important Factoids

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions