Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing container CPU resource limit is undetected by Terraform #1876

Closed
dsoyet opened this issue Oct 18, 2022 · 4 comments
Closed

Removing container CPU resource limit is undetected by Terraform #1876

dsoyet opened this issue Oct 18, 2022 · 4 comments

Comments

@dsoyet
Copy link

dsoyet commented Oct 18, 2022

Terraform Version, Provider Version and Kubernetes Version

Terraform version: v1.2.9
Kubernetes provider version:  v2.14.0
Kubernetes version: 1.21.0

Affected Resource(s)

  • kubernetes_deployment

Terraform Configuration Files

resource "kubernetes_deployment" "local-example" {
  metadata {
    name = "local-example"
    namespace = "default"
  }

  spec {
    replicas = 1

    selector {
      match_labels = {
        test = "local-example"
      }
    }

    template {
      metadata {
        labels = {
          test = "local-example"
        }
      }

      spec {
        container {
          # image = "${var.addresses[0]}:5000/rancher/mirrored-library-nginx:1.21.1-alpine"
          image = "rancher/mirrored-library-nginx:1.21.1-alpine"
          name  = "example"

          resources {
            limits = {
              cpu    = "0.5"
              memory = "512Mi"
            }
            requests = {
              cpu    = "250m"
              memory = "50Mi"
            }
          }
          liveness_probe {
            http_get {
              path = "/"
              port = 80

              http_header {
                name  = "X-Custom-Header"
                value = "Awesome"
              }
            }

            initial_delay_seconds = 3
            period_seconds        = 3
          }
        }
      }
    }
  }
}

terraform {
  required_providers {
    kubernetes = {
      source = "hashicorp/kubernetes"
      version = "2.14.0"
    }
  }
}

provider "kubernetes" {
  config_path = "kube_config_cluster.yml"
}

Debug Output

when I comment out the resources {} block, the deployment didn't updated

Steps to Reproduce

  1. terraform apply
  2. comment out the resources {} block
  3. terraform apply

Expected Behavior

the deployment should remove his resources block

Actual Behavior

terraform apply output
No changes. Your infrastructure matches the configuration.

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
@dsoyet dsoyet added the bug label Oct 18, 2022
@github-actions github-actions bot removed the bug label Oct 18, 2022
@dsoyet
Copy link
Author

dsoyet commented Oct 18, 2022

when I change the resources block to

          resources {
            limits = {
            }
            requests = {
            }
          }

it works as expected

@BBBmau
Copy link
Contributor

BBBmau commented Oct 19, 2022

Hello @dsoyet ! Thank you opening this issue, like you stated in your comment the resources block needs to have the attributes set in order for any change to happen since it is expecting some sort of value to be provided.

@BBBmau BBBmau closed this as completed Oct 19, 2022
@jan4984
Copy link

jan4984 commented Oct 20, 2022

Hello @dsoyet ! Thank you opening this issue, like you stated in your comment the resources block needs to have the attributes set in order for any change to happen since it is expecting some sort of value to be provided.

Hello @BBBmau I think it is a bug, just like #754. How a user know "the resources block needs to have the attributes set" ?

@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants