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

Open
foosinn opened this issue Sep 28, 2023 · 1 comment
Open

Add equivalent of kubectl rollout restart #2304

foosinn opened this issue Sep 28, 2023 · 1 comment

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
  }
}

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