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

Deleting a node via Terraform should delete the Kubernetes node #79

Open
displague opened this issue Apr 29, 2021 · 2 comments
Open

Deleting a node via Terraform should delete the Kubernetes node #79

displague opened this issue Apr 29, 2021 · 2 comments
Assignees

Comments

@displague
Copy link
Member

displague commented Apr 29, 2021

When the node count is modified, a destroy triggered provisioned should attempt to drain and delete the node:

for example:

resource "metal_device" "..." {
  // ...
  provisioner "local-exec" {
    when        = destroy
    command = "kubectl -f ${kubeconfig}  delete node ${self.hostname}" // we would want to drain/cordon first. can we get the kubeconfig path in this block?
  }
}

The CCM (#64) would handle the eventual cleanup of deleted Terraform or UI deleted nodes, but this approach will allow for Terraform deleted nodes to be cleaned up less abruptly.

@jmarhee
Copy link
Contributor

jmarhee commented Apr 29, 2021

I like this idea a lot. This should be doable-- in other locations, we've assumed the kubeadm admin kubeconfig (/etc/kubernetes/admin.conf), so I don't see why we couldn't here.

@jmarhee
Copy link
Contributor

jmarhee commented Jun 7, 2021

#90 addresses this in a best-effort (makes an attempt, reminds user to clean up manually if KUBECONFIG is not set, because a destroy triggered resource can't consume variables in such a way to allow me to push in a path) using local-exec; perhaps something the Kubernetes provider can address (though if I recall, it cannot delete a node).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants