Skip to content

Commit

Permalink
♻️ Add script to clean up Linode nodebalancers
Browse files Browse the repository at this point in the history
  • Loading branch information
jpetazzo committed Feb 4, 2023
1 parent cfbe578 commit 1aa0e06
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions prepare-tf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,21 @@ terraform destroy
```bash
rm stage2/terraform.tfstate*
```

10. Clean up leftovers.

Some providers don't clean up properly the resources created by the CCM.
For instance, when you create a Kubernetes `Service` of type
`LoadBalancer`, it generally provisions a cloud load balancer.
On Linode (and possibly other providers, too!) these cloud load balancers
aren't deleted when the cluster gets deleted, and they keep incurring
charges. You should check for those, to make sure that you don't
get charged for resources that you don't use anymore. As I write this
paragraph, there is specifically one script to remove the Linode
nodebalancers; but be careful: it deletes **all** the nodebalancers
whose name starts with `ccm-`, which means that if you still have
Kubernetes clusters, their load balancers will be deleted as well!

Eventually, I hope to add more scripts for other providers, and make
them more selective and more robust, but for now, that's better than
nothing.
4 changes: 4 additions & 0 deletions prepare-tf/linode-delete-ccm-loadbalancers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
linode-cli nodebalancers list --json |
jq '.[] | select(.label | startswith("ccm-")) | .id' |
xargs -n1 -P10 linode-cli nodebalancers delete

0 comments on commit 1aa0e06

Please sign in to comment.