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

Add equivalent of kubectl rollout restart #2304

Closed
foosinn opened this issue Sep 28, 2023 · 2 comments
Closed

Add equivalent of kubectl rollout restart #2304

foosinn opened this issue Sep 28, 2023 · 2 comments

Comments

@foosinn
Copy link

foosinn commented Sep 28, 2023

Description

This would allow terraform to restart deployments. Especially useful after deploying other things

Potential Terraform Configuration

resource "kubernetes_rollout_restart" "restart_applciation" {
  apiVersion = "apps/v1"
  kind = "Deployment"

  metadata = {
    "name": "nginx"
    "namespace": "myapp"
  }

  restart_on_create = true  # default value
  restart_on_destroy = true  # default value
}

References

This would provide a much cleaner alternative to https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/blob/master/modules/acm/creds.tf#L85-L99, that also respects current context and network settings.

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
@jrhouston
Copy link
Collaborator

The way kubectl rollout restart works is by patching the deployment template with the kubectl.kubernetes.io/restartedAt annotation. Rather than adding a new resource for this, you could use the kubernetes_annotations resource to do the same thing:

resource "time_static" "restarted_at" {}

resource "kubernetes_annotations" "example" {
  api_version = "apps/v1"
  kind        = "Deployment"
  metadata {
    name = "nginx-deployment"
  }
  template_annotations = {
    "kubectl.kubernetes.io/restartedAt" = time_static.restarted_at.rfc3339
  }
}

Copy link

github-actions bot commented Oct 5, 2024

Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you!

@github-actions github-actions bot added the stale label Oct 5, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants