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

State is unable to track/update change made by kubectl if the resource is in a module #1136

Closed
khumps opened this issue Jan 30, 2021 · 4 comments · Fixed by #1138
Closed
Labels

Comments

@khumps
Copy link

khumps commented Jan 30, 2021

Terraform version: 0.14.5
Kubernetes provider version: 2.0.1
Kubernetes version:

Affected Resource(s)

Tested with kubernetes_deployment and kubernetes_ingress that are in a module

Terraform Configuration Files

resource "kubernetes_deployment" "planetside-tk" {
  metadata {
	name = var.name
	labels = {
	  app = var.name
	}
  }
  spec {
	replicas = 1
	selector {
	  match_labels = {
		app: var.name
	  }
	}
	template {
	  metadata {
		labels = {
		  app: var.name
		}
	  }
	  spec {
		container {
		  name = "nginx"
		  image = "nginx:latest"
		  port {
			container_port = var.container_port
		  }
		  volume_mount {
			mount_path = "/usr/share/nginx/html"
			sub_path = var.name
			name       = "html"
		  }
		}
		volume {
		  name = "html"
		  persistent_volume_claim {
			claim_name = var.name
		  }
		}
	  }
	}
  }
}

Module is defined in:

module "planetside-tk" {
  source = "./planetside.tk"
  name = "planetside-tk"
  container_port = 80
  storage_class_name = kubernetes_storage_class.freenas.metadata[0].name
}

Debug Output

https://gist.github.com/khumps/bf17b0af5c7d965452d3b218593c70cf

Steps to Reproduce

  1. kubectl delete deployment/planetside-tk
  2. terraform plan

Expected Behavior

Plan should acknowledge that the deployment is missing and try to recreate it

Actual Behavior

Plan says it is up to date

Important Factoids

These resources are in a module. If I move them out of the module the plan tries to create it but also delete it (this shouldn't happen since it no longer exists)

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
@khumps khumps added the bug label Jan 30, 2021
@khumps khumps changed the title State is unable to track/update change made by kubectl to a module State is unable to track/update change made by kubectl if the resource is in a module Jan 30, 2021
@jrhouston
Copy link
Collaborator

Thanks for opening this @khumps. This looks like a bug that was introduced in the upgrade to the new SDK, which deprecated the Exists function in favour of Read. I have an PR with a fix incoming.

@khumps
Copy link
Author

khumps commented Feb 2, 2021

Thank you for this @jrhouston. Is this something that I need to pull from master to use? What is the release cycle like?

@aareet
Copy link
Contributor

aareet commented Feb 2, 2021

@khumps there should be a release going out today. We try to release every two weeks in general (if it makes sense to)

@ghost
Copy link

ghost commented Mar 4, 2021

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 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants