Terraform-provider-kubernetes: How to avoid kubernetes_deployment from always overriding the image field?

Created on 22 Jan 2021  ·  3Comments  ·  Source: hashicorp/terraform-provider-kubernetes

Terraform version, Kubernetes provider version and Kubernetes version

Terraform version: 1.14.2
Kubernetes Provider version: 2.0.1
Kubernetes version: 1.17

Question

In my terraform .tf code I have a kubernetes_deployment which specifies an image property on the container. Right now it's myservice:latest inside terraform. This works perfectly fine for an initial release.

Sometime later, our CI/CD process comes along, builds a new image, gives it an updated tag (say, ABCD) and pushes ABCD to the registry and then calls kubectl set image deployment/foo myservice:ABCD. This also works as expected.

The problem then comes in, the next time I run a terraform plan terraform sees that the image is myservice:ABCD instead of myservice:latest and it then plans an update to the image field to reset it to myservice:latest which is undesirable. Is there anyway to have terraform ignore deltas in the image field after initial creation?

question

Most helpful comment

I had not! Somehow in my searching for an answer to this one I had not come across this. Looks like exactly what I need! Thanks a ton for the quick response.

All 3 comments

I had not! Somehow in my searching for an answer to this one I had not come across this. Looks like exactly what I need! Thanks a ton for the quick response.

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