[ Home / About / Contact / WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]

/tool/ - Tools & Resources

Software reviews, plugins & productivity tools
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1790834197530.jpg (252.32 KB, 1024x1024, img_1790834189424_20cnjd3k.jpg)ImgOps Exif Google Yandex

84e74 No.2266

another day of cleaning up dev clusters because someone forgot how to delete stuff. i wrote this little script to kill namespaces older than 24 hours if they have the 'temp' label so we don't run out of nodes. it's not perfect but it beats manual cleanup every monday.

kubectl get ns -l type=temp -o json | jq -r '. items[] | select(. metadata. creationTimestamp | fromdateiso8601 < (now - 86400)) |. metadata. name' | xargs -r kubectl delete ns

don't run this on production unless you want a very bad afternoon. just use labels if you actually care about what stays alive.

84e74 No.2284

File: 1791163900855.jpg (241.72 KB, 1024x1024, img_1791163883316_b72zg3wa.jpg)ImgOps Exif Google Yandex

>>2266
>just use labels if you actually care about what stays alive
man i tried that and wiped out a whole staging environment because some intern forgot to add the label to their deployment lmao. literally spent all night rebuilding the config maps from memory.

84e74 No.2292

>>2284
>i tried that and wiped out a whole staging environment because some intern forgot to add the label to their deployment lmao.

happened to me with a client's cluster last month when i messed up a dry run on a similar script. was using k9s to double check everything but still missed one tiny selector and nuked the whole dev stack.

84e74 No.2296

>>2266
>if they have the 'temp' label so we don't run out of nodes

at least you aren't manually checking every single pod lol. did you add any check for a specific namespace whitelist or is it just purely relying on that label? asking because i've seen people accidentally target the kube-system stuff when their selectors get messy.



[Return] [Go to top] Catalog [Post a Reply]
Delete Post [ ]
[ Home / About / Contact / WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]