-
Notifications
You must be signed in to change notification settings - Fork 988
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
Annotations ending in kubernetes.io not being ignored #2411
Comments
Thanks for opening this @mersive-raypitmon. This looks like a regression. I tried the following steps:
On v2.52.2 this results in a diff showing the restartedAt label being deleted. On v2.24.0 there is no diff – so this is a bug. |
Upgraded to v2.26.0 today and this issue seems to have regressed again. Any applies will attempt to remove the restartedAt annotations and cause the pods to restart. Have fallen back to v2.24.0 in the meantime. |
Missed out the documentation, this is resolved. Reference for the next person: https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs#examples-1 |
@BBBmau @arybolovlev I see that there was clarification added to docs regarding this issue, but I am unable to get
Still results in the following plan output following a manual
Should this issue be reopened, or should I create a new one? Thanks. |
@jundersand-chwy - I just ran into this, and when I added the lifecycle block the change went away, so the lifecycle block is working for me, at least on GKE.
The lifecycle block I just added: lifecycle {
ignore_changes = [
spec[0].template[0].metadata[0].annotations["kubectl.kubernetes.io/restartedAt"],
]
} Terraform plan before adding the lifecycle: # kubernetes_deployment.server will be updated in-place
~ resource "kubernetes_deployment" "server" {
id = "ns1/server"
# (1 unchanged attribute hidden)
~ spec {
# (5 unchanged attributes hidden)
~ template {
~ metadata {
~ annotations = {
- "kubectl.kubernetes.io/restartedAt" = "2024-03-13T08:56:54-06:00" -> null
}
# (2 unchanged attributes hidden)
}
# (1 unchanged block hidden)
}
# (2 unchanged blocks hidden)
}
# (1 unchanged block hidden)
} (After adding the |
Thanks, I confirmed locally that upgrading to Terraform v0.14.6 in our project results in the expected behavior. So, anyone stuck on Terraform v0.13.7 may need to pin provider kubernetes v2.24.0 or migrate to a newer TF version. |
I am currently using Terraform CDK, and import { KubernetesProvider } from "@cdktf/provider-kubernetes/lib/provider";
void new KubernetesProvider(this, "k8s", {
host: this.cluster.eksCluster.endpoint,
clusterCaCertificate: Fn.base64decode(this.cluster.eksCluster.certificateAuthority.get(0).data),
token: this.cluster.auth.token,
ignoreAnnotations: [
"kubectl.kubernetes.io/restartedAt",
],
}); I have also tried the I am on Terraform Doing it on a per-deployment basis with the life cycle ignore does work, but it obviously is a bit less ideal given the duplication. |
Terraform Version, Provider Version and Kubernetes Version
Note: I just ran similar terraform against
Kubernetes version: v1.25.10-gke.2700
and I don't see the issue, so is this a k8s problem and not a provider issue?Affected Resource(s)
kubernetes_stateful_set
Steps to Reproduce
terraform plan
Expected Behavior
My STS resource should not show any changes.
Actual Behavior
The output from the plan command states that it will null out a server-set annotation ending in
kubernetes.io
. The provider documentation states this:It is not ignoring that annotation, as here is my output from
terraform plan
:I've ran
terraform plan
on this bit of code several times over the past year, and I haven't noticed this until now. Also note that I am not manually setting any annotations inspec.template.metadata.annotations
I checked the actual YAML for the resource running in the GKE console and it does have the annotation:
Community Note
The text was updated successfully, but these errors were encountered: