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

https://github.com/civo/cli/blob/master/cmd/kubernetes_remove.go #19

Closed
manuelh2410 opened this issue Aug 24, 2020 · 5 comments
Closed

Comments

@manuelh2410
Copy link

manuelh2410 commented Aug 24, 2020

"civo kubernetes remove CLUSTER_NAME", doesnt seem to support wild card characters .
example "civo kubernetes remove ."
the CLI seems to be missing a "Bulk Delete" feature

@andyjeffries
Copy link
Contributor

Hi @manuelh2410 , this is intentionally so. We've made the CLI fairly scriptable, but don't want to risk someone accidentally deleting a cluster they didn't intend. You could do this like this:

for i in `civo k3s ls -o custom -f ID | grep something`; do civo k3s rm $i; done

@manuelh2410
Copy link
Author

manuelh2410 commented Aug 25, 2020

Good Day,

Thanks for getting back to me .

How does your suggested command string deal with the confirmation request required by the API prior to deleting the cluster?

for i in civo k3s ls -o custom -f ID | grep something; do civo k3s rm $i; done

also wouldnt the command need to be civo k3s ls -o custom -f Name ? instead of ID

I tested this and the API only returned 20 results out of 50 clusters .

root@Pegasus:/home/manuelh# civo k3s ls -o custom -f Name
manueltest1
manueltest2
manueltest3
manueltest4
manueltest5
manueltest6
manueltest7
manueltest8
manueltest9
manueltest10
manueltest11
manueltest12
manueltest13
manueltest14
manueltest15
manueltest16
manueltest17
manueltest18
manueltest19
manueltest20

@andyjeffries
Copy link
Contributor

for i in civo k3s ls -o custom -f ID | grep something; do civo k3s rm -y $i; done

Add the -y flag to auto-confirm, missed that. Also it will delete by ID or name, so I'd go with name.

@manuelh2410
Copy link
Author

Hi Andy ,
The following seems to work

for i in civo k3s ls -o custom -f Name ; do civo k3s rm -y $i; done

But it is only shown to delete 20 clusters at a time

Error: sorry we found more than one Kubernetes cluster with that name in your account
Error: sorry we found more than one Kubernetes cluster with that name in your account
The Kubernetes cluster called manueltest3 with ID 12a85bd3-4002-43f4-a16f-9320e4893ba7 was deleted
The Kubernetes cluster called manueltest4 with ID 4d427f6f-604d-477b-a2e9-3e2f80e2bb0d was deleted
The Kubernetes cluster called manueltest5 with ID 44ac9be3-f432-468d-a2e5-a12aef43dac7 was deleted
The Kubernetes cluster called manueltest6 with ID 1ede3310-be8e-49e5-80e6-325594e1c753 was deleted
The Kubernetes cluster called manueltest7 with ID 13a3adfb-3b2f-41ab-a5f3-e26da782bc4e was deleted
The Kubernetes cluster called manueltest8 with ID e490e768-9342-4494-8860-2ad9947f9feb was deleted
The Kubernetes cluster called manueltest9 with ID 2115b299-3c98-412a-8f85-8ac9fda057be was deleted
The Kubernetes cluster called manueltest10 with ID ed28e54e-8b0c-43cc-9d7d-fa188289faec was deleted
The Kubernetes cluster called manueltest11 with ID 54428a31-d640-4f54-9c31-a3d86fb1e066 was deleted
The Kubernetes cluster called manueltest12 with ID ded857a2-b1a2-43fa-a76e-3c12760c5743 was deleted
The Kubernetes cluster called manueltest13 with ID 3d21550b-6917-4d3e-93a4-aefe1f56f6f6 was deleted
The Kubernetes cluster called manueltest14 with ID e550cd90-aad3-449e-9f45-a1afc74e8757 was deleted
The Kubernetes cluster called manueltest15 with ID ce11141c-654c-4416-a716-790e7ff8ffb2 was deleted
The Kubernetes cluster called manueltest16 with ID 76921e80-063e-49c1-8762-7a26dd04837e was deleted
The Kubernetes cluster called manueltest17 with ID 5fbd2ac7-8172-4dbf-9891-9a4ab12d729d was deleted
The Kubernetes cluster called manueltest18 with ID 59cabb0b-d102-4a34-95f3-75dad2a9ebc9 was deleted
The Kubernetes cluster called manueltest19 with ID 14492526-bdcd-47f5-b5bb-ba94f00201a1 was deleted
The Kubernetes cluster called manueltest20 with ID 59ac2c4f-50cc-45c3-8f01-2e79c211859b was deleted
root@Pegasus:/home/manuelh#

@andyjeffries
Copy link
Contributor

Because you're doing it by name and there are often more than one cluster that matches that name (it doesn't do a full match, but a partial match). That's why I used ID. I wrote incorrectly in my comment though "so I'd go with name". Use the ID, it's always unique.

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