From 1aa0e062d03a284d916a842c48bff5e0e65a3f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Petazzoni?= Date: Sat, 4 Feb 2023 10:48:42 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20Add=20script=20to=20cle?= =?UTF-8?q?an=20up=20Linode=20nodebalancers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prepare-tf/README.md | 18 ++++++++++++++++++ prepare-tf/linode-delete-ccm-loadbalancers.sh | 4 ++++ 2 files changed, 22 insertions(+) create mode 100755 prepare-tf/linode-delete-ccm-loadbalancers.sh diff --git a/prepare-tf/README.md b/prepare-tf/README.md index 957de6a4..d7677b82 100644 --- a/prepare-tf/README.md +++ b/prepare-tf/README.md @@ -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. diff --git a/prepare-tf/linode-delete-ccm-loadbalancers.sh b/prepare-tf/linode-delete-ccm-loadbalancers.sh new file mode 100755 index 00000000..141e009a --- /dev/null +++ b/prepare-tf/linode-delete-ccm-loadbalancers.sh @@ -0,0 +1,4 @@ +#!/bin/sh +linode-cli nodebalancers list --json | + jq '.[] | select(.label | startswith("ccm-")) | .id' | + xargs -n1 -P10 linode-cli nodebalancers delete