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

Crash when applying kubernetes resources #1039

Closed
ghost opened this issue Oct 16, 2020 · 6 comments
Closed

Crash when applying kubernetes resources #1039

ghost opened this issue Oct 16, 2020 · 6 comments
Labels
acknowledged Issue has undergone initial review and is in our work queue. bug crash stale

Comments

@ghost
Copy link

ghost commented Oct 16, 2020

This issue was originally opened by @martinisoft as hashicorp/terraform#26610. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.13.4
+ provider registry.terraform.io/digitalocean/digitalocean v1.23.0
+ provider registry.terraform.io/hashicorp/helm v1.3.2
+ provider registry.terraform.io/hashicorp/kubernetes v1.13.2
+ provider registry.terraform.io/hashicorp/local v1.4.0

Terraform Configuration Files

resource "kubernetes_secret" "frontend" {
  metadata {
    name = "db-password"
    labels = {
      app     = "ecommerce"
      service = "db"
    }
  }

  data = {
    pw = "password"
  }

  type = "Opaque"
}

resource "kubernetes_deployment" "frontend" {
  metadata {
    name = "frontend"
    labels = {
      service = "frontend"
      app     = "ecommerce"
    }
  }

  spec {
    replicas = 1
    selector {
      match_labels = {
        service = "frontend"
        app     = "ecommerce"
      }
    }

    strategy {
      type = "RollingUpdate"
      rolling_update {
        max_surge       = "25%"
        max_unavailable = "25%"
      }
    }

    template {
      metadata {
        labels = {
          service = "frontend"
          app     = "ecommerce"
        }
      }

      spec {
        container {
          name              = "ecommerce-spree-observability"
          image             = "ddtraining/ecommerce-frontend:latest"
          image_pull_policy = "Always"
          port {
            container_port = 3000
            protocol       = "TCP"
          }
          resources {
            requests {
              cpu    = "100m"
              memory = "100Mi"
            }
            limits {}
          }
          args    = ["docker-entrypoint.sh"]
          command = ["sh"]
          env {
            name  = "DB_USERNAME"
            value = "user"
          }
          env {
            name = "DB_PASSWORD"
            value_from {
              secret_key_ref {
                key  = "pw"
                name = "db-password"
              }
            }
          }
          env {
            name = "DD_AGENT_HOST"
            value_from {
              field_ref {
                field_path = "status.hostIP"
              }
            }
          }
          env {
            name  = "DD_LOGS_INJECTION"
            value = "true"
          }
          env {
            name  = "DD_ANALYTICS_ENABLED"
            value = "true"
          }
        }
      }
    }
  }
}

resource "kubernetes_service" "frontend" {
  metadata {
    name = "frontend"
    labels = {
      service = "frontend"
      app     = "ecommerce"
    }
  }
  spec {
    selector = {
      app     = "ecommerce"
      service = "frontend"
    }

    port {
      port        = 3000
      target_port = 3000
      protocol    = "TCP"
    }

    type = "LoadBalancer"
  }
}

resource "kubernetes_ingress" "frontend" {
  metadata {
    name = "basic-ingress"
  }

  spec {
    backend {
      service_name = "frontend"
      service_port = 3000
    }
  }
}

Debug Output

https://gist.github.com/martinisoft/646e5b312717047457313dc63ce1720c

Crash Output

https://gist.github.com/martinisoft/646e5b312717047457313dc63ce1720c

Expected Behavior

I should have seen it apply the resource modifications to my kubernetes cluster

Actual Behavior

A crash shortly in the middle of the apply

Steps to Reproduce

  1. terraform apply --auto-approve

Additional Context

This is an existing kubernetes cluster with these resources previously deployed, then modifying their deployment type via HCL and using terraform apply.

References

None

@dak1n1
Copy link
Contributor

dak1n1 commented Oct 16, 2020

@martinisoft thanks for this report! I'm going to see if I can reproduce it and work on a fix asap.

@martinisoft
Copy link

Awesome thanks @dak1n1

@dak1n1
Copy link
Contributor

dak1n1 commented Oct 16, 2020

I was able to reproduce the crash by taking a Deployment example I had locally and passing an empty limits{} block (similar to the example given in this issue).

A work-around for this issue is to completely omit the limits{} or specify some kind of value there. Let me know if that doesn't work and we can try something else.

@ryan-cahill
Copy link

Thanks for looking into this @dak1n1. I also ran into this when looking for workarounds for #754

@aareet aareet added the crash label Oct 28, 2020
@alexsomesan alexsomesan added the acknowledged Issue has undergone initial review and is in our work queue. label Oct 28, 2020
@github-actions
Copy link

github-actions bot commented Dec 2, 2021

This issue has been open 365 days with no activity. If this issue is reproducible with the latest version of the provider and with Terraform 0.12/0.13, please comment. Otherwise this issue will be closed in 30 days.

@github-actions github-actions bot added the stale label Dec 2, 2021
@github-actions github-actions bot closed this as completed Jan 2, 2022
@github-actions
Copy link

github-actions bot commented Feb 1, 2022

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 Feb 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
acknowledged Issue has undergone initial review and is in our work queue. bug crash stale
Projects
None yet
Development

No branches or pull requests

5 participants